Is it possible with the GeomVertex* classes (or things that work on GeomNodes->geom->prim/vertexData) to remove a triangle or vertices? It seems possible to add them rather easily, but to remove a vertice and all triangles attached to it or a triangle and then any unconnected vertices seems daunting and any sort of remove/delete/destroy for individual rows in the vertex columns seems to be missing. Can someone point me in the correct direction?
One way i can think of is to recreate the whole geom and skipping the verts and prims you want to remove.
So load all the vert and prim data, create it again while skipping the ones you dont want anymore. Might not be the fastest and best solution but it should work.
I have never tried this, and it could go wrong, but what about getting the vertex data of the model like this (sorry, it’s c++, but python equivalent should be easy).
Then put that vertex data into a GeomVertexWriter as explained here:
Note: I see that the comments on get_geom() reference a certain function called get_unique_geom that doesn’t exist, does that mean that the warning no longer applies?
Ah, the comment should refer to modify_geom() instead. I’ll fix it.
GeomVertexWriter/Rewriter/reader all seem to be able to modify/read/add vertices, but not remove them. There seems to be no way to remove triangles from primitives either. I am a little bit worried about performance if I rebuild the mesh every couple frames or every frame; would it be better perhaps to use the new callback node and implement this particular mesh in straight opengl–eventually porting it to C? (I am looking for speed rather than simple…)
If you’re willing to be very careful in your calculations, you can remove vertices by directly manipulation the underlying GeomVertexArrayData. You can use GeomVertexArrayDataHandle.setSubdata() to remove n bytes in the middle of the block, by something like handle.setSubdata(start, size, ‘’), which sets bytes from start to start + size - 1 to the empty string, meaning no bytes at all. This will reposition byte start + size onto byte start, and so on to the end of the buffer.
So, if you computer start and size correctly based on the row stride (which you can query from the GeomVertexArrayFormat), then you can remove any vertices arbitrarily. Note that doing so will also change the vertex index numbers higher than those vertices, thus likely requiring you to rebuild the primitive index array anyway.
If you only want to remove primitive index numbers without affecting the vertex data, you can do the same trick there (the index numbers are stored in their own GeomVertexArrayData internally).