コード例 #1
0
ファイル: osgocclusionquery.cpp プロジェクト: joevandyk/osg
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 ) );
        }
    }
}
コード例 #2
0
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();
}
コード例 #3
0
ファイル: osgocclusionquery.cpp プロジェクト: joevandyk/osg
void 
DebugDisplayVisitor::apply( osg::OcclusionQueryNode& oqn )
{
    oqn.setDebugDisplay( _debug );

    traverse( oqn );
}
コード例 #4
0
ファイル: osgocclusionquery.cpp プロジェクト: joevandyk/osg
void
EnableQueryVisitor::apply( osg::OcclusionQueryNode& oqn )
{
    oqn.setQueriesEnabled( _enabled );

    traverse( oqn );
}
コード例 #5
0
ファイル: osgocclusionquery.cpp プロジェクト: joevandyk/osg
void
QueryFrameCountVisitor::apply( osg::OcclusionQueryNode& oqn )
{
    oqn.setQueryFrameCount( _count );

    traverse( oqn );
}
コード例 #6
0
ファイル: osgocclusionquery.cpp プロジェクト: joevandyk/osg
void
VisibilityThresholdVisitor::apply( osg::OcclusionQueryNode& oqn )
{
    oqn.setVisibilityThreshold( _visThreshold );

    traverse( oqn );
}
コード例 #7
0
ファイル: osgocclusionquery.cpp プロジェクト: joevandyk/osg
void
StatisticsVisitor::apply( osg::OcclusionQueryNode& oqn )
{
    _numOQNs++;
    if (oqn.getPassed())
        _numPassed++;

    traverse( oqn );
}
コード例 #8
0
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;
}