Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void MyNode::traverse(osg::NodeVisitor& nv)
- {
- if ( nv.getVisitorType() == nv.CULL_VISITOR )
- {
- osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
- osg::ref_ptr<osgUtil::RenderBin> newBin;
- osgUtil::RenderBin* bin = cv->getCurrentRenderBin();
- osgUtil::RenderBin* parentBin = bin->getParent();
- if ( parentBin )
- {
- // If a parent bin exists, "allocate" the first unused bin number from its list of children
- // and use that to force the creation of a new traversal-order bin:
- int newBinNumber = parentBin->getRenderBinList().rbegin()->first + 1;
- newBin = parentBin->find_or_insert(newBinNumber, "TraversalOrderBin");
- }
- else
- {
- // If there is no parent, fall back on the stage and allocate a new child bin there:
- int newBinNumber = bin->getStage()->getBinNum() + 1;
- newBin = bin->getStage()->find_or_insert(newBinNumber, "TraversalOrderBin");
- }
- // activate our new bin and traverse:
- cv->setCurrentRenderBin( newBin.get() );
- osg::Group::traverse(nv);
- // restore the previous bin:
- cv->setCurrentRenderBin( bin );
- }
- else
- {
- osg::Group::traverse( nv );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement