Added osg::CullSettings class as a way of collecting all the various
settings related to the cull traversal in one place, so we can keep APIs for settings these values more consistent.
This commit is contained in:
53
src/osg/CullSettings.cpp
Normal file
53
src/osg/CullSettings.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#include <osg/CullSettings>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
void CullSettings::setDefaults()
|
||||
{
|
||||
_cullingMode = DEFAULT_CULLING;
|
||||
_LODScale = 1.0f;
|
||||
_smallFeatureCullingPixelSize = 2.0f;
|
||||
|
||||
_computeNearFar = COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES;
|
||||
_nearFarRatio = 0.0005f;
|
||||
_impostorActive = true;
|
||||
_depthSortImpostorSprites = false;
|
||||
_impostorPixelErrorThreshold = 4.0f;
|
||||
_numFramesToKeepImpostorSprites = 10;
|
||||
_cullMask = 0xffffffff;
|
||||
_cullMaskLeft = 0xffffffff;
|
||||
_cullMaskRight = 0xffffffff;
|
||||
|
||||
// override during testing
|
||||
_computeNearFar = COMPUTE_NEAR_FAR_USING_PRIMITIVES;
|
||||
_nearFarRatio = 0.0005f;
|
||||
}
|
||||
|
||||
void CullSettings::setCullSettings(const CullSettings& settings)
|
||||
{
|
||||
_computeNearFar = settings._computeNearFar;
|
||||
_nearFarRatio = settings._nearFarRatio;
|
||||
_impostorActive = settings._impostorActive;
|
||||
_depthSortImpostorSprites = settings._depthSortImpostorSprites;
|
||||
_impostorPixelErrorThreshold = settings._impostorPixelErrorThreshold;
|
||||
_numFramesToKeepImpostorSprites = settings._numFramesToKeepImpostorSprites;
|
||||
_cullMask = settings._cullMask;
|
||||
_cullMaskLeft = settings._cullMaskLeft;
|
||||
_cullMaskRight = settings._cullMaskRight;
|
||||
_cullingMode = settings._cullingMode;
|
||||
_LODScale = settings._LODScale;
|
||||
_smallFeatureCullingPixelSize = settings._smallFeatureCullingPixelSize;
|
||||
}
|
||||
@@ -17,9 +17,6 @@ using namespace osg;
|
||||
|
||||
CullStack::CullStack()
|
||||
{
|
||||
_cullingMode = DEFAULT_CULLING;
|
||||
_LODScale = 1.0f;
|
||||
_smallFeatureCullingPixelSize = 2.0f;
|
||||
_frustumVolume=-1.0f;
|
||||
_bbCornerNear = 0;
|
||||
_bbCornerFar = 7;
|
||||
|
||||
@@ -25,6 +25,7 @@ CXXFILES =\
|
||||
CullFace.cpp\
|
||||
CullingSet.cpp\
|
||||
CullStack.cpp\
|
||||
CullSettings.cpp\
|
||||
Depth.cpp\
|
||||
DisplaySettings.cpp\
|
||||
Drawable.cpp\
|
||||
|
||||
@@ -95,14 +95,8 @@ CullVisitor::CullVisitor():
|
||||
NodeVisitor(CULL_VISITOR,TRAVERSE_ACTIVE_CHILDREN),
|
||||
_currentRenderGraph(NULL),
|
||||
_currentRenderBin(NULL),
|
||||
_computeNearFar(COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES),
|
||||
_nearFarRatio(0.0005f),
|
||||
_computed_znear(FLT_MAX),
|
||||
_computed_zfar(-FLT_MAX),
|
||||
_impostorActive(true),
|
||||
_depthSortImpostorSprites(false),
|
||||
_impostorPixelErrorThreshold(4.0f),
|
||||
_numFramesToKeepImpostorSprites(10),
|
||||
_currentReuseRenderLeafIndex(0)
|
||||
{
|
||||
_impostorSpriteManager = new ImpostorSpriteManager;
|
||||
|
||||
@@ -36,12 +36,6 @@ SceneView::SceneView(DisplaySettings* ds)
|
||||
|
||||
_clearColor.set(0.2f, 0.2f, 0.4f, 1.0f);
|
||||
|
||||
_computeNearFar = CullVisitor::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES;
|
||||
//_computeNearFar = CullVisitor::COMPUTE_NEAR_FAR_USING_PRIMITIVES;
|
||||
|
||||
_cullingMode = osg::CullStack::DEFAULT_CULLING;
|
||||
_LODScale = 1.0f;
|
||||
_smallFeatureCullingPixelSize = 3.0f;
|
||||
|
||||
_fusionDistanceMode = PROPORTIONAL_TO_SCREEN_DISTANCE;
|
||||
_fusionDistanceValue = 1.0f;
|
||||
@@ -54,9 +48,6 @@ SceneView::SceneView(DisplaySettings* ds)
|
||||
|
||||
_initCalled = false;
|
||||
|
||||
_cullMask = 0xffffffff;
|
||||
_cullMaskLeft = 0xffffffff;
|
||||
_cullMaskRight = 0xffffffff;
|
||||
|
||||
_drawBufferValue = GL_BACK;
|
||||
|
||||
@@ -71,6 +62,8 @@ SceneView::~SceneView()
|
||||
|
||||
void SceneView::setDefaults()
|
||||
{
|
||||
CullSettings::setDefaults();
|
||||
|
||||
_projectionMatrix.makePerspective(50.0f,1.4f,1.0f,10000.0f);
|
||||
_viewMatrix.makeIdentity();
|
||||
|
||||
@@ -134,10 +127,6 @@ void SceneView::setDefaults()
|
||||
_globalStateSet->setAttributeAndModes(lightmodel, osg::StateAttribute::ON);
|
||||
|
||||
_clearColor.set(0.2f, 0.2f, 0.4f, 1.0f);
|
||||
|
||||
_cullMask = 0xffffffff;
|
||||
_cullMaskLeft = 0xffffffff;
|
||||
_cullMaskRight = 0xffffffff;
|
||||
}
|
||||
|
||||
void SceneView::init()
|
||||
@@ -485,6 +474,8 @@ void SceneView::cullStage(const osg::Matrixd& projection,const osg::Matrixd& mod
|
||||
|
||||
if (!_collectOccludersVisistor) _collectOccludersVisistor = new osg::CollectOccludersVisitor;
|
||||
|
||||
_collectOccludersVisistor->setCullSettings(*this);
|
||||
|
||||
_collectOccludersVisistor->reset();
|
||||
|
||||
_collectOccludersVisistor->setFrameStamp(_frameStamp.get());
|
||||
@@ -528,10 +519,7 @@ void SceneView::cullStage(const osg::Matrixd& projection,const osg::Matrixd& mod
|
||||
cullVisitor->setTraversalNumber(_frameStamp->getFrameNumber());
|
||||
}
|
||||
|
||||
cullVisitor->setCullingMode(_cullingMode);
|
||||
cullVisitor->setComputeNearFarMode(_computeNearFar);
|
||||
cullVisitor->setLODScale(_LODScale);
|
||||
cullVisitor->setSmallFeatureCullingPixelSize(_smallFeatureCullingPixelSize);
|
||||
cullVisitor->setCullSettings(*this);
|
||||
|
||||
cullVisitor->setClearNode(NULL); // reset earth sky on each frame.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user