Hi Jan,

On 1/31/07, Jan Ciger <[EMAIL PROTECTED]> wrote:
What does this mean? Does this break the old model of:

while(1)
{
  sync();
  update();
  cull();
  draw();
}

I.e. is it still OK to change the scenegraph in the update() part?

Yes :-)

The main loop is a bit different in osgViewer though -  frame() does
everything, so the main viewer loop is:

while (!viewer.done())
{
   viewer.frame();
}

And the frame just wraps up the variious stages, you can just call
these explicitly:

while (!viewer.done())
{
   viewer.advance();
   viewer.eventTraversal();
   viewer.updateTraversal();
   viewer.renderingTraverals(); // does both cull and draw
}

Note, no public sync() any more, this is now done internally in the
the viewer.renderingTraversals(), which doesn't complete till is safe
to modify the scene graph again.  This means its safe to  modify the
scene graph before and after the viewer.renderingTraversals().  My
hope is that will make it easier to understand and use.


Since the viewer.renderingTraversals() has manages all the various
barrier and blocks required for safe multi-threading it is able to
change the implementation without the main loop changing.  This means
you can swap the threading model without any changes to your
application, you simply call viewer.setThreadingModel(threadingModel).

Its also safe to change threading model while the app is running - the
viewer will stop all threads, reset up the required barriers and
blocks and then restart threads as appropriate all within the
setThreadingModel() method.  You can also start and stop threading
explictly with the stopThreading() and startThreading() methods.   The
new osgviewer has an event handler for changing the threading model -
this is where the 'm' key press comes - have a look at
applications/osgviewer/osgviewer.cpp to see how its done.


Or does it
have to be completely static in order to not break anything?

You just need to set the DataVariance parameter of the StateSet's and
Drawables that you will be changing to DYNAMIC, and it'll be safe to
change these.   Modifying them and their contents which their
DataVariance is STATIC could cause problems.

The way that the STATIC vs DYNAMIC data variance is used is that the
draw traversal delays the next frame till all the DYNAMIC StateSet's
and Drawables have been drawn, then it releases the block that
prevents the Viewer::renderingTraverals method from completing.  The
more of your scene graphs StateSet's and Drawable are static the
better as it releases the main thread sooner.


Robert.
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to