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