# What is a efficient way for adding and removing vertices and indices in C++?

So I have this middle-large mesh that is composed from vertices and respective indices. At some point I need to add new ones and remove some. But that brings me into trouble. Because if I have, for example, a 10k array (or vector) of indices and I want to remove one with index n, I have todo lot of processing on the array:

a) Find n b) Slice n c) Slice the respective Vertex from other array (the easiest part) d) Shift the array e) Shift the indices (worst part). If I remove 6, 7 needs to become new 6, 8 new 7 and so on...

Another strategy is to recreate Vertex and Index arrays/vectors every time something changes, but that isn't efficient neither.

• Can you cut down the mesh into smaller chunks, where you'd have only a subset of ~1k to worry about instead of 10? Sep 9 at 13:19
• So I would have 10 meshes with own stack of vertices and indices? Sep 9 at 13:43
• Yes, if that makes sense for your application. Sep 9 at 13:43