Added extra clampProjectionMatrix methods to handle both Matrixd and Matrixf

pathways.
This commit is contained in:
Robert Osfield
2003-12-21 13:11:36 +00:00
parent 315065df24
commit fdd5a72115
2 changed files with 15 additions and 3 deletions

View File

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

View File

@@ -186,7 +186,8 @@ void CullVisitor::popProjectionMatrix()
CullStack::popProjectionMatrix();
}
bool CullVisitor::clampProjectionMatrix(osg::Matrix& projection, value_type& znear, value_type& zfar) const
template<class matrix_type, class value_type>
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<min_near_plane) desired_znear=min_near_plane;
// assign the clamped values back to the computed values.
@@ -250,6 +251,16 @@ bool CullVisitor::clampProjectionMatrix(osg::Matrix& projection, value_type& zne
}
bool CullVisitor::clampProjectionMatrix(osg::Matrixf& projection, value_type& znear, value_type& zfar) const
{
return _clampProjectionMatrix( projection, znear, zfar, _nearFarRatio );
}
bool CullVisitor::clampProjectionMatrix(osg::Matrixd& projection, value_type& znear, value_type& zfar) const
{
return _clampProjectionMatrix( projection, znear, zfar, _nearFarRatio );
}
void CullVisitor::updateCalculatedNearFar(const osg::Matrix& matrix,const osg::BoundingBox& bb)
{
#if 0