Collision detection
In order to prevent our surface from intersecting itself, we need a way to detect collisions between parts of the surface as it grows and to introduce forces to prevent it from overlapping. We use a particle-based collision system. Each vertex of the mesh has an ellipsoid-shaped collision body around it, which has a radius equal to some collision distance normal to the surface and a radius proportional to the ring of vertices around it in the tangent plane. When two collision bodies intersect, we introduce a stiff spring-like force that pushes them away from each other. Detecting nearby collision bodies is accelerated with a simple spatial binning structure.