From: "Chris 'Xenon' Hanson" <xe...@alphapixel.com>
Sent: Saturday, September 19, 2009 12:17 AM
To: "OpenSceneGraph Users" <osg-users@lists.openscenegraph.org>
Subject: Re: [osg-users] Could I update the structure of scene in a nodevisitor?

zhuliangxi...@hotmail.com wrote:
Hi there,
i wrote a class inherit from NodeVistor to remove all the scribe node
from the scene. However, after the execution leave my apply function,
the system crashed. I think that's because i changed the structure of
the scene since i removed nodes from scene when visiting, and that may
make some iterator unusable.

 I believe you are correct.

so, is it available to change the structure of scene in a NodeVistor
?  If yes, is there anything to take care?

Before running the NodeVisitor, I would create an vector container of ref_ptrs to Nodes. During the apply/visit, fill the container with pointers to the nodes you wish to remove. After the apply/visit is done, examine the container of Node pointers, and remove them all
from the scenegraph then, when there aren't any iterators in progress.

So that means we shouldn't update scene in a NodeVistor? That will be crazy!
What ever, your solution works !

Thank you so much!

Regards,
Abe Zhu


_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to