[osg-users] Setting CullVisitor

Jean-Sébastien Guay jean-sebastien.guay at cm-labs.com
Tue Nov 10 05:57:38 PST 2009


Hi Paul,

> Why do I have multiple SceneViews? 

There are always two SceneViews if you're using multithreading - they're 
used on alternating frames as you've seen. Just set your CullVisitor for 
both, or a separate instance of your CullVisitor for each instance.

Whenever I've had to change something on SceneView instances, I had to 
do it on both instances. I expect if your CullVisitor has some local 
state, you'd have to use two separate instances, one for each SceneView, 
so that threading works correctly and doesn't try to modify data that's 
being read in another thread.

> I need my own CullVisitor because I've defined my own node type that needs special cull handling.

You could just override the traverse() method of your node type, that's 
how I normally do it. It keeps changes local to the overridden node 
class instead of propagating changes to other parts of the app.

   void traverse(osg::NodeVisitor& nv)
   {
       if (nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR)
       {
           osgUtil::CullVisitor* cv =
                dynamic_cast<osgUtil::CullVisitor*>(&nv);

           // ...
       }
       osg::Node::traverse(nv);  // call base class version.
       // (replace Node by whatever the base class of your overridden
       //  node type is)
   }

Hope this helps,

J-S
-- 
______________________________________________________
Jean-Sebastien Guay    jean-sebastien.guay at cm-labs.com
                                http://www.cm-labs.com/
                         http://whitestar02.webhop.org/


More information about the osg-users mailing list