Added saving and restoring of the near/far planes during Camera setup

This commit is contained in:
Robert Osfield
2007-05-17 13:20:32 +00:00
parent fec8b86a00
commit 9ba424e8b2

View File

@@ -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());
@@ -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