[osg-users] how i can remove a sphere that is in a vector in the scene

Christian Buchner christian.buchner at gmail.com
Thu Oct 22 05:39:34 PDT 2015


I believe your vector has to be storing pointers to the sphere objects, not
entire sphere objects themselves. And indeed the same pointer is passed to
addChild, as to removeChild afterwards, things *should* work as intended.
To make sure, print the pointer values you pass to addChild/removeChild to
verify.

some background:
Due to the private destructor of any child of osg::Referenced any such
object cannot be put into standard containers. OSG wants to stay in control
of object creation and destruction using its internal reference counting
system, and hence the destructor cannot be made public or the container
class would destroy the object whenever it wants (even when still
referenced by the OSG graph).

Christian


2015-10-22 13:52 GMT+02:00 Alvaro Ginestar <alvaroginestar at hotmail.com>:

> hi everyone!!
> i try remove a sphere, with "removechild" it doesn't work.
> i use root->addChild(vector[x]); for to add the sphere in a node root and
> then i try to remove with root->removeChild(vector[x]);
> In the scene is draw a sphere, but it doesn't remove the sphere.
> someone know I'm doing wrong?
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20151022/a7c6ecc0/attachment-0003.htm>


More information about the osg-users mailing list