|
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.
(comments are locked)
|
|
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.
(comments are locked)
|
|
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[6] now could be newVertices[3]. On which line are you getting the overflow? newTriangles[i] = tri; ?
(comments are locked)
|
