Hi Paul,

On 7/3/07, Paul Martz <[EMAIL PROTECTED]> wrote:
Okay, but because computeBounds() is const, I have to cast away const in
order to perform operations on the scene graph within this function.

Casting away const'ness is should be see as "advanced" usage, some
that most usage models won't require, but if you know what your are
doing and that it won't break any threading then you'll be OK to just
go ahead and cast away constness.

Furthermore, when I do this, I see crashes in multidisplay environments,
probably due to a thread collision caused by modifying the scene graph in
one thread while another accesses the same part of the scene graph.

Well you'll need to write the code so its thread safe... one way
around this is to stick a viewer->getSceneData()->getBound() before
the call to renderingTraversals();  Crude way of forcing a single
threading computeBound() but effective.

Taking a look at CullVisitor, it's not clear to me how you ensure that
computeBounds() is only called once per frame in multidisplay environments
(where multiple cull traversals would be running concurrently). Can you
explain how this is handled?

The computeBounds() themselves just compute a bounding volume they
don't actually modify anything.  The getBound itself does the
modification of the cached bounding volume, and can do so virtual of
the _boundingBox/_boundingSphere being mutable.  The getBound does try
to make the serialize the access to the bounding volume variable,
rather it lets multiple threads go and do the compute and lets them
all apply their values - they will all compute the same values anyway
so there isn't any danger in this.

Robert.
_______________________________________________
osg-users mailing list
osg-users@openscenegraph.net
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to