From b4774099d658e45d15d004310b5e3b590ec5f3ba Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 29 Jan 2004 20:14:20 +0000 Subject: [PATCH] Fixed the clampProjectionMatrix method so it doesn't modify the input znar and zfar, by avoid the use of float/double&. --- include/osgUtil/CullVisitor | 16 ++++++++-------- src/osgUtil/CullVisitor.cpp | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/osgUtil/CullVisitor b/include/osgUtil/CullVisitor index 3e009d1ec..c7fc15b03 100644 --- a/include/osgUtil/CullVisitor +++ b/include/osgUtil/CullVisitor @@ -194,9 +194,9 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac _currentRenderBin = rb; } - inline float getCalculatedNearPlane() const { return _computed_znear; } + inline value_type getCalculatedNearPlane() const { return _computed_znear; } - inline float getCalculatedFarPlane() const { return _computed_zfar; } + inline value_type getCalculatedFarPlane() const { return _computed_zfar; } void updateCalculatedNearFar(const osg::Matrix& matrix,const osg::Drawable& drawable) { updateCalculatedNearFar(matrix,drawable.getBound()); } void updateCalculatedNearFar(const osg::Matrix& matrix,const osg::BoundingBox& bb); @@ -220,8 +220,8 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac * can target either Matrix data type, configured at compile time.*/ struct ClampProjectionMatrixCallback : public osg::Referenced { - virtual bool clampProjectionMatrixImplementation(osg::Matrixf& projection, double& znear, double& zfar) const = 0; - virtual bool clampProjectionMatrixImplementation(osg::Matrixd& projection, double& znear, double& zfar) const = 0; + virtual bool clampProjectionMatrixImplementation(osg::Matrixf& projection, double znear, double zfar) const = 0; + virtual bool clampProjectionMatrixImplementation(osg::Matrixd& projection, double znear, double zfar) const = 0; }; /** set the ClampProjectionMatrixCallback.*/ @@ -233,14 +233,14 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac /** CullVisitor's default clamping of the projection float matrix to computed near and far values. * Note, do not call this method directly, use clampProjectionMatrix(..) instead, unless you want to bypass the callback.*/ - virtual bool clampProjectionMatrixImplementation(osg::Matrixf& projection, double& znear, double& zfar) const; + virtual bool clampProjectionMatrixImplementation(osg::Matrixf& projection, double znear, double zfar) const; /** CullVisitor's default clamping of the projection double matrix to computed near and far values. * Note, do not call this method directly, use clampProjectionMatrix(..) instead, unless you want to bypass the callback.*/ - virtual bool clampProjectionMatrixImplementation(osg::Matrixd& projection, double& znear, double& zfar) const; + virtual bool clampProjectionMatrixImplementation(osg::Matrixd& projection, double znear, double zfar) const; /** clamp the projection float matrix to computed near and far values, use callback if it exists, otherwise use default CullVisitro implemntation.*/ - inline bool clampProjectionMatrix(osg::Matrixf& projection, value_type& znear, value_type& zfar) const + inline bool clampProjectionMatrix(osg::Matrixf& projection, value_type znear, value_type zfar) const { double zn = znear; double zf = zfar; @@ -259,7 +259,7 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac } /** clamp the projection double matrix to computed near and far values, use callback if it exists, otherwise use default CullVisitro implemntation.*/ - inline bool clampProjectionMatrix(osg::Matrixd& projection, value_type& znear, value_type& zfar) const + inline bool clampProjectionMatrix(osg::Matrixd& projection, value_type znear, value_type zfar) const { double zn = znear; double zf = zfar; diff --git a/src/osgUtil/CullVisitor.cpp b/src/osgUtil/CullVisitor.cpp index 46ff531a4..d2163bbd5 100644 --- a/src/osgUtil/CullVisitor.cpp +++ b/src/osgUtil/CullVisitor.cpp @@ -187,7 +187,7 @@ void CullVisitor::popProjectionMatrix() } template -bool _clampProjectionMatrix(matrix_type& projection, double& znear, double& zfar, value_type nearFarRatio) +bool _clampProjectionMatrix(matrix_type& projection, double znear, double zfar, value_type nearFarRatio) { if (zfar>0.0f) { @@ -251,12 +251,12 @@ bool _clampProjectionMatrix(matrix_type& projection, double& znear, double& zfar } -bool CullVisitor::clampProjectionMatrixImplementation(osg::Matrixf& projection, double& znear, double& zfar) const +bool CullVisitor::clampProjectionMatrixImplementation(osg::Matrixf& projection, double znear, double zfar) const { return _clampProjectionMatrix( projection, znear, zfar, _nearFarRatio ); } -bool CullVisitor::clampProjectionMatrixImplementation(osg::Matrixd& projection, double& znear, double& zfar) const +bool CullVisitor::clampProjectionMatrixImplementation(osg::Matrixd& projection, double znear, double zfar) const { return _clampProjectionMatrix( projection, znear, zfar, _nearFarRatio ); }