I'm probably doing this really inefficiently, but I'm having trouble recalculating the triangles array of a mesh I'm deleting vertices from. I can delete the vertices without issue (I think), but I'm getting hung up on the triangles array.
What I have so far works for deleting vertices, but it overflows the length of the new triangles array I'm initializing.
asked Aug 05 '10 at 04:04 AM
Before you start messing with the vertices array of a mesh, you need to issue a mesh.Clear().
At the end of your code, you need to assign the vertices first, and the triangles last. mesh.RecalculateBounds() will be called automatically by reassigning mesh.triangles.
answered Aug 19 '10 at 10:07 AM
I'm not sure why you get the overflow, but even if it wouldn't, your triangles would point to vertex indices that were relevant in the old vertices array and are probably irrelevant in the new one, as you deleted some vertices in between and vertices now could be newVertices.
On which line are you getting the overflow? newTriangles[i] = tri; ?
answered Aug 05 '10 at 09:09 AM