Question about ofMesh removeVertex / removeIndex

Hi there,

I’m wondering why i cannot found the “remover” functions in the ofMesh.cpp.
They are declared in the ofMesh.h file, but no implementation… is that normal for the current version?

undefined reference to `ofMesh::removeVertex(int)’

Thanks,

Yeah, they’re not implemented right now, so if you want to remove a vertex you can just do:

  
  
vector<ofVec3f> verts = mesh.getVertices();  
  

and then remove it from there, but keep in mind that you need to redo all your indices, colors, normals, and tex coords. I’m guessing that’s why those remove methods aren’t implemented yet.

i think you need to use a reference instead of a copy:

  
  
vector<ofVec3f>& verts = mesh.getVertices();    
  

but in general it’s a bad idea to modify the contents of a data structure stored inside a class in any other way than using the methods of the class. this is one of the things const/non-const is supposed to indicate, but it isn’t used consistently throughout OF so you should just be careful with what you modify from outside the class.

Gah, nice catch :slight_smile:

I wonder if that wasn’t marked const b/c it’s there for just that purpose? There should be a way to remove a vertex/index/etc, even if it’s just maintaining a separate array/vector and resetting things ala ofVbo::updateVertexData() etc. That does means redoing all the indices and anything else set per vertex, which is a bit of work, but there’s no way to build up or modify a mesh w/o them.

Thanks for the clarifications,

i will find a way to not add the unwanted vertices instead of added them then removed them.

Bye for now!