Added set/getNearFarRatio() to CullVisitor.

This commit is contained in:
Robert Osfield
2003-05-01 19:56:02 +00:00
parent 2d360c344c
commit d2d9b97953
2 changed files with 7 additions and 1 deletions

View File

@@ -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;

View File

@@ -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<min_near_plane) desired_znear=min_near_plane;
// assign the clamped values back to the computed values.