[osg-users] How to add some new nodes at runtime
robert.osfield at gmail.com
Tue Apr 12 05:25:06 PDT 2011
You can modify the scene graph in different ways, and at different
points in the frame, some are easier to fit within the context of
multi-threaded viewer and others aren't. Nodes and viewer level
objects it generally safe to modifying the outside the viewer.frame()
call. You're example should be just fine.
It's only drawable levels and contents of StateSet that are used in
seperate threads that one has to be extra careful about when using the
DrawThreadPerContext and CullThreadPerCameraDrawThreadPerContext
threading models as these let the next frame move on while the draw
threads are still dispatching the drawable and state data to OpenGL.
If you do wish to modify the drawable and stateset then you simply set
their DataVariance field to DYNAMIC and the draw traversal holds back
the next frame till all these dynamic objects are dispatched.
This topic has been discussed lots of the years so having a look
through the archive will provide a good insight into what is and what
isn't safe to do.
On Tue, Apr 12, 2011 at 1:15 PM, Per Nordqvist <nordqvist at gmail.com> wrote:
> On a related note, it says in Rui Wang's new OSG 3.0 book that it is
> dangerous to
> do scene graph updates in the frame loop due to multithreading issues.
> (Chapter 8, p193)
> Snippet from the specific example:
> while ( !viewer.done() )
> rttcamera->setViewMatrixAsLookat(...); // unsafe!?
> Instead, Rui is recommending callbacks.
> So is the above unsafe, and is this true for all kinds of scene graph updates?
> osg-users mailing list
> osg-users at lists.openscenegraph.org
More information about the osg-users