[osg-users] Removing stateset for all assoc nodes without traverse

Robert Osfield robert.osfield at gmail.com
Wed Apr 12 05:53:43 PDT 2017

Hi Yura,

On 12 April 2017 at 13:10, Yura Ivanov <dev3d at protonmail.com> wrote:
> How can I remove stateset for all associated nodes without calling setStateset(NULL) to each node? Or what is the fastest way to do it?

The way you remove a stateset from a Node is via setStateSet().  To
remove it from all the nodes that are associated with you can get the
StateSet::ParentList using StateSet'::getParents() then traverse
through this list calling setStateSet(0) on each one.

There isn't an more efficient way to do this than the above approach,
setStateSet() does all the internal house keeping required and no
more, you can't short cut this otherwise the scene graph would end up
with a mess of dangling pointers, memory leaks or crashes.

The fact that you raise this as a performance issue SCREAMs out to me
that you are again trying to solve a problem because of poor choice of
scene graph construction.  You are trying to solve the problem with
the wrong tools.

The basic approach you have taken sounds wrong, and you are hitting
performance issues because of this and trying to look to "optimize"
stuff in the OSG to solve the bottlenecks rather than look at the
basic approach you are taking.

I think the best thing you can do right now is take a step back,
accept that the approach you have taken thus far is inefficient and
call for suggestions form the community how they would solve the
particular task you are trying to tackle.  I've requested you provide
more high level details like this in previous threads but so far there
hasn't been enough to go on to know what the best route would be.


More information about the osg-users mailing list