Beispiel #1
0
void
RemoveOcclusionQueryVisitor::apply( osg::OcclusionQueryNode& oqn )
{
    if (oqn.getNumParents() == 0)
    {
        // Even if this is an OQN, can't delete it because it's the root.
        traverse( oqn );
        return;
    }

    osg::ref_ptr<osg::OcclusionQueryNode> oqnPtr = &oqn;

    unsigned int np = oqn.getNumParents();
    while (np--)
    {
        osg::Group* parent = dynamic_cast<osg::Group*>( oqn.getParent( np ) );
        if (parent != NULL)
        {
            // Remove OQN from parent.
            parent->removeChild( oqnPtr.get() );

            // Add OQN's children to parent.
            unsigned int nc = oqn.getNumChildren();
            while (nc--)
                parent->addChild( oqn.getChild( nc ) );
        }
    }
}
void CullVisitor::apply(osg::OcclusionQueryNode& node)
{
    if (isCulled(node)) return;

    // push the culling mode.
    pushCurrentMask();

    // push the node's state.
    StateSet* node_state = node.getStateSet();
    if (node_state) pushStateSet(node_state);


    osg::Camera* camera = getCurrentCamera();
    
    // If previous query indicates visible, then traverse as usual.
    if (node.getPassed( camera, *this ))
        handle_cull_callbacks_and_traverse(node);

    // Traverse the query subtree if OcclusionQueryNode needs to issue another query.
    node.traverseQuery( camera, *this );

    // Traverse the debug bounding geometry, if enabled.
    node.traverseDebug( *this );


    // pop the node's state off the render graph stack.    
    if (node_state) popStateSet();

    // pop the culling mode.
    popCurrentMask();
}
Beispiel #3
0
void 
DebugDisplayVisitor::apply( osg::OcclusionQueryNode& oqn )
{
    oqn.setDebugDisplay( _debug );

    traverse( oqn );
}
Beispiel #4
0
void
EnableQueryVisitor::apply( osg::OcclusionQueryNode& oqn )
{
    oqn.setQueriesEnabled( _enabled );

    traverse( oqn );
}
Beispiel #5
0
void
QueryFrameCountVisitor::apply( osg::OcclusionQueryNode& oqn )
{
    oqn.setQueryFrameCount( _count );

    traverse( oqn );
}
Beispiel #6
0
void
VisibilityThresholdVisitor::apply( osg::OcclusionQueryNode& oqn )
{
    oqn.setVisibilityThreshold( _visThreshold );

    traverse( oqn );
}
Beispiel #7
0
void
StatisticsVisitor::apply( osg::OcclusionQueryNode& oqn )
{
    _numOQNs++;
    if (oqn.getPassed())
        _numPassed++;

    traverse( oqn );
}
void ScreenMVCullVisitor::apply(osg::OcclusionQueryNode& node)
{
    bool status = _cullingStatus;
    bool firstStatus = _firstCullStatus;

    if(isCulled(node))
    {
        _firstCullStatus = firstStatus;
        _cullingStatus = status;
        return;
    }

    // push the culling mode.
    pushCurrentMask();

    // push the node's state.
    StateSet* node_state = node.getStateSet();
    if(node_state)
        pushStateSet(node_state);

    osg::Camera* camera = getCurrentCamera();

    // If previous query indicates visible, then traverse as usual.
#if (OPENSCENEGRAPH_MAJOR_VERSION == 2) && (OPENSCENEGRAPH_MINOR_VERSION == 9) && (OPENSCENEGRAPH_PATCH_VERSION <= 7)
    if (node.getPassed( camera, getDistanceToEyePoint( node.getBound()._center, false ) ))
#else
    if(node.getPassed(camera,*this))
#endif
        handle_cull_callbacks_and_traverse(node);

    // Traverse the query subtree if OcclusionQueryNode needs to issue another query.
    node.traverseQuery(camera,*this);

    // Traverse the debug bounding geometry, if enabled.
    node.traverseDebug(*this);

    // pop the node's state off the render graph stack.    
    if(node_state)
        popStateSet();

    // pop the culling mode.
    popCurrentMask();

    _firstCullStatus = firstStatus;
    _cullingStatus = status;
}