I'm making a program where a large and complicated mesh is procedurally generated. At first I generated a large number of smaller meshes, which works just fine, but then I decided to merge them together and some triangles got corrupted.
After a bit of looking i managed to pinpoint the problem:
Debug.Log(fullTriangles == fullTriangles);
boxMesh.triangles = fullTriangles;
Debug.Log(boxMesh.triangles == fullTriangles);
This only occurs when I use the large mesh. For the many smaller meshes both debugs return true.
Here's a picture of the mesh. It loops on itself in many places, is in no way convex, has several floating islands, and is in general very difficult from a rendering perspective.
Other information that might matter:
- The many small meshes in the large mesh do not share any verticies in the large mesh, but some verticies have the same positions
- Each small mesh is made of one or several triangles, that do share verticies
- The small meshes are not submeshes
Why does this happend, and what can I do to fix it?