From 9ba424e8b29e94f964ccd7073eb5c54f22ebed8d Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 17 May 2007 13:20:32 +0000 Subject: [PATCH] Added saving and restoring of the near/far planes during Camera setup --- src/osgUtil/CullVisitor.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/osgUtil/CullVisitor.cpp b/src/osgUtil/CullVisitor.cpp index 665bd2773..b2da939a4 100644 --- a/src/osgUtil/CullVisitor.cpp +++ b/src/osgUtil/CullVisitor.cpp @@ -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