Example #1
0
void CVRCullVisitor::apply(osg::Projection& node)
{

    // push the culling mode.
    pushCurrentMask();

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

    // record previous near and far values.
    float previous_znear = _computed_znear;
    float previous_zfar = _computed_zfar;

    // take a copy of the current near plane candidates
    DistanceMatrixDrawableMap previousNearPlaneCandidateMap;
    previousNearPlaneCandidateMap.swap(_nearPlaneCandidateMap);

    _computed_znear = FLT_MAX;
    _computed_zfar = -FLT_MAX;

    ref_ptr<RefMatrix> matrix = createOrReuseMatrix(node.getMatrix());
    pushProjectionMatrix(matrix.get());

    //OSG_NOTIFY(osg::INFO)<<"Push projection "<<*matrix<<std::endl;

    // note do culling check after the frustum has been updated to ensure
    // that the node is not culled prematurely.

    bool status = _cullingStatus;
    bool firstStatus = _firstCullStatus;

    if(!isCulled(node))
    {
        handle_cull_callbacks_and_traverse(node);
    }

    _firstCullStatus = firstStatus;
    _cullingStatus = status;

    popProjectionMatrix();

    //OSG_NOTIFY(osg::INFO)<<"Pop projection "<<*matrix<<std::endl;

    _computed_znear = previous_znear;
    _computed_zfar = previous_zfar;

    // swap back the near plane candidates
    previousNearPlaneCandidateMap.swap(_nearPlaneCandidateMap);

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

    // pop the culling mode.
    popCurrentMask();
}
void PickVisitor::apply(osg::Projection& projection)
{
    runNestedPickVisitor( projection,
                          _lastViewport.get(),
                          projection.getMatrix(),
                          _lastViewMatrix,
                          _mx, _my );
}
Example #3
0
void IntersectionVisitor::apply(osg::Projection& projection)
{
    if (!enter(projection)) return;

    pushProjectionMatrix(new osg::RefMatrix(projection.getMatrix()) );

    // now push an new intersector clone transform to the new local coordinates
    push_clone();

    traverse(projection);
    
    // pop the clone.
    pop_clone();
    
    popProjectionMatrix();

    leave();
}
void CollectOccludersVisitor::apply(osg::Projection &node)
{
    if (isCulled(node))
        return;

    // push the culling mode.
    pushCurrentMask();

    ref_ptr<osg::RefMatrix> matrix = createOrReuseMatrix(node.getMatrix());
    pushProjectionMatrix(matrix.get());

    handle_cull_callbacks_and_traverse(node);

    popProjectionMatrix();

    // pop the culling mode.
    popCurrentMask();
}
void CURRENT_CLASS::apply(osg::Projection &proj)
{
    if(shouldContinueTraversal(proj))
    {
        // Push the new projection matrix view frustum
        _projectionMatrices.push_back(proj.getMatrix());
        pushLocalFrustum();

        // Traverse the group
        ++_currentDepth;
        traverse(proj);
        --_currentDepth;

        // Reload original matrix and frustum
        _localFrusta.pop_back();
        _bbCorners.pop_back();
        _projectionMatrices.pop_back();
    }
}