From fdd5a72115f754461f3c66cce5e76dfebf979871 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 21 Dec 2003 13:11:36 +0000 Subject: [PATCH] Added extra clampProjectionMatrix methods to handle both Matrixd and Matrixf pathways. --- include/osgUtil/CullVisitor | 3 ++- src/osgUtil/CullVisitor.cpp | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/include/osgUtil/CullVisitor b/include/osgUtil/CullVisitor index 68c1ef910..80f16e36c 100644 --- a/include/osgUtil/CullVisitor +++ b/include/osgUtil/CullVisitor @@ -214,7 +214,8 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac /** reimplement CullStack's popProjectionMatrix() adding clamping of the projection matrix to the computed near and far.*/ virtual void popProjectionMatrix(); - bool clampProjectionMatrix(osg::Matrix& projection, value_type& znear, value_type& zfar) const; + bool clampProjectionMatrix(osg::Matrixf& projection, value_type& znear, value_type& zfar) const; + bool clampProjectionMatrix(osg::Matrixd& projection, value_type& znear, value_type& zfar) const; void setState(osg::State* state) { _state = state; } osg::State* getState() { return _state.get(); } diff --git a/src/osgUtil/CullVisitor.cpp b/src/osgUtil/CullVisitor.cpp index 4f76e0ea6..65341bd41 100644 --- a/src/osgUtil/CullVisitor.cpp +++ b/src/osgUtil/CullVisitor.cpp @@ -186,7 +186,8 @@ void CullVisitor::popProjectionMatrix() CullStack::popProjectionMatrix(); } -bool CullVisitor::clampProjectionMatrix(osg::Matrix& projection, value_type& znear, value_type& zfar) const +template +bool _clampProjectionMatrix(matrix_type& projection, value_type& znear, value_type& zfar, value_type nearFarRatio) { if (zfar>0.0f) { @@ -225,7 +226,7 @@ bool CullVisitor::clampProjectionMatrix(osg::Matrix& projection, value_type& zne value_type desired_zfar = zfar *1.02; // near plane clamping. - double min_near_plane = zfar*_nearFarRatio; + double min_near_plane = zfar*nearFarRatio; if (desired_znear