# holes in procedural mesh

I’m new to procedural 3d modeling. I have an existing mesh that I want to alter. When I alter the vertices though all the faces separate. How can I make sure all the triangles stay connected in order to keep a solid mesh? It would also be great to better understand how to smooth the mesh. See the image and code below for examples:

[1636-image+21.jpg|1636]

``````            Vector3[] vertices = mesh.vertices;
Vector3[] normals = mesh.normals;
``````

for (int i=0; i

The holes in your mesh are because you have hard edges (two vertices that share a position, but not a normal direction) in the initial mesh. When you apply a random movement to each vertex, those vertices that share a position will not move together, which creates your holes.

The solutions to this are (in order of complicated-ness and awesome-ness):

1. Make your input mesh 100% smooth. No hard edges, no duplicated vertices along normal-creases. No more using mesh.RecalculateNormals()

2. Do a pass first to group vertices together based on some epsilon distance. Vertices that are very close together count as the same vertex and you apply the same offset value to each group along the shared average of the vertex normals.

3. Use a mesh-adjacency structure to calculate shared vertices. Half-Edge with a vertex list is a good option. This is also going to take you right down the rabbit-hole in terms of procedural mesh creation, so prepare to be awesome. (Article to get you started: Half-edge based mesh representations: theory | The ryg blog)