I’ve created my own GeomNode representing a box.
I can click on the box and recolor it to something else. I can also move the box around.
Note that this is not done via the “nodepath” but directly by rewriting the vertex buffer of my geomnode.
After this operation my geometry is displayed correctly in the position I’ve moved it to but I cannot pick the node anymore. The collision doesn’t seem to happen anymore.
Do I need to recompute the physics bounds or something similar ?
Normally, the correct way to modify a vertex buffer is to access the vertex buffer from the Geom first with nodePath.node()->modify_geom()->modify_vertex_data(). If you do this, it tells the Geom that you are moving vertices around, and that it therefore needs to invalidate caches and recompute its bounding volume.
If, instead, you keep a pointer to the vertex data after you created the Geom, and simply modify that pointer directly instead of re-obtaining it from the Geom, then the Geom has no way to know what you are doing beneath it and its cached values can become invalid.
Where did you get the mVertexGeom pointer? Did you store it after creating it? That’s a similar problem. It’s also important to tell the GeomNode that you’re modifying its internal Geom object, by re-obtaining the Geom pointer each time you intend to change it with GeomNode::modify_geom().
Same problem with mVertices and mColors. You need to re-obtain them from the Geom pointer (which you re-obtained from the GeomNode).
the reason why I did store these values is because the class is intended to be usable within the scenegraph and I thougt it shouldn’t really contain a NodePath for the “debug box” of my vertex - but rather the GeomNode which I’ve created for it.