diff --git a/include/osgUtil/CullVisitor b/include/osgUtil/CullVisitor index 76f45c4ad..23fd52919 100644 --- a/include/osgUtil/CullVisitor +++ b/include/osgUtil/CullVisitor @@ -121,6 +121,10 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac void setComputeNearFarMode(ComputeNearFarMode cnfm) { _computeNearFar=cnfm; } ComputeNearFarMode getComputeNearFarMode() const { return _computeNearFar;} + void setNearFarRatio(float ratio) { _nearFarRatio = ratio; } + float getNearFarRatio() const { return _nearFarRatio; } + + /** Push state set on the current state group. * If the state exists in a child state group of the current * state group then move the current state group to that child. @@ -245,6 +249,7 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac RenderBin* _currentRenderBin; ComputeNearFarMode _computeNearFar; + float _nearFarRatio; float _computed_znear; float _computed_zfar; diff --git a/src/osgUtil/CullVisitor.cpp b/src/osgUtil/CullVisitor.cpp index 3913177d2..5f2e5a48a 100644 --- a/src/osgUtil/CullVisitor.cpp +++ b/src/osgUtil/CullVisitor.cpp @@ -91,6 +91,7 @@ CullVisitor::CullVisitor(): _currentRenderGraph(NULL), _currentRenderBin(NULL), _computeNearFar(COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES), + _nearFarRatio(0.0005f), _computed_znear(FLT_MAX), _computed_zfar(-FLT_MAX), _impostorActive(true), @@ -179,7 +180,7 @@ void CullVisitor::popProjectionMatrix() double desired_znear = _computed_znear*0.98f; double desired_zfar = _computed_zfar*1.02f; - double min_near_plane = _computed_zfar*0.0005f; + double min_near_plane = _computed_zfar*_nearFarRatio; if (desired_znear