Skip to content

Commit

Permalink
Added saving and restoring of the near/far planes during Camera setup
Browse files Browse the repository at this point in the history
  • Loading branch information
robertosfield committed May 17, 2007
1 parent fec8b86 commit 9ba424e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/osgUtil/CullVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,17 @@ void CullVisitor::apply(osg::Camera& camera)

if (camera.getViewport()) pushViewport(camera.getViewport());

// 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;

pushProjectionMatrix(projection);
pushModelViewMatrix(modelview, camera.getReferenceFrame());

Expand Down Expand Up @@ -1289,6 +1300,15 @@ void CullVisitor::apply(osg::Camera& camera)
// restore the previous model view matrix.
popProjectionMatrix();


// restore the original near and far values
_computed_znear = previous_znear;
_computed_zfar = previous_zfar;

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


if (camera.getViewport()) popViewport();

// restore the previous cull settings
Expand Down

0 comments on commit 9ba424e

Please sign in to comment.