HI Hannes,
The osgViewer has a mechanism for avoid multiple traversals of shared
scene graphs if mutlple View's share the same root node of the scene
graph. If shared component isn't the topmost node then the OSG has no
straight forward way to know whether a subgraph has been traversed or
not that frame. One could implement a mechanism to avoid this
visiting a node multiple times in one frame but it would be really
costly to do, an expense that would only be a benefit for a very small
number of users, but would slow performance for everyone else.
The most efficient way to avoid this multiple traversals issue is to
implement to have a custom callback that is tailored to the specific
usage case that a user has. I don't know enough about the specific
callbacks and scene graph set up you have so I can't pinpoint the best
route.
If you have a shared subgraph that you don't want traversed multiple
times per frame then use an UpdateCallback that has a frameNumber
member variable that keep track of the the frameNumber (use
NodeVisitor::getFrameStamp()'s FrameNumber) of the last traversal,
when a traversal calls the update callback you only traverse the
subgraph if the frameNumber is different and then set the frameNumber
to the present frame, if the frameNumber is the same then you just
return immediately. This custom UpdateCallback you'd place as high as
you can in your scene graph to make sure the traversal stops as soon
as possible.
Another approach is to move this frameNumber tracking into your
existing update callbacks, and simple return right away with the
frameNumber is the same. This requires a small tweak to the callbacks
but is such a small change it's generally pretty easy to integrate.
Finally you can simple make your callbacks resilient so that the are
no ill effects from being called multiple times.
Robert.
>> >
osg-...@lists.openscenegraph.org
>>
osg-...@lists.openscenegraph.org
>
osg-...@lists.openscenegraph.org
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org