Added CullingSettngs::s/getInheritanceMask() and inheritCullSettings(,) method.

This commit is contained in:
Robert Osfield 2004-10-12 09:54:03 +00:00
parent 840ae915e9
commit 4192ef796b
4 changed files with 57 additions and 18 deletions

View File

@ -51,10 +51,45 @@ class SG_EXPORT CullSettings
return *this; return *this;
} }
void setCullSettings(const CullSettings& settings);
void setDefaults(); void setDefaults();
enum VariablesMask
{
COMPUTE_NEAR_FAR_MODE = 0x0001,
CULLING_MODE = 0x0002,
LOD_SCALE = 0x0004,
SMALL_FEATURE_CULLING_PIXEL_SIZE = 0x0008,
CLAMP_PROJECTION_MATRIX_CALLBACK = 0x0010,
NEAR_FAR_RATIO = 0x0020,
IMPOSTOR_ACTIVE = 0x0040,
DEPTH_SORT_IMPOSTOR_SPRITES = 0x0080,
IMPOSTOR_PIXEL_ERROR_THRESHOLD = 0x0100,
NUM_FRAMES_TO_KEEP_IMPOSTORS_SPRITES = 0x0200,
CULL_MASK = 0x0400,
CULL_MASK_LEFT = 0x0800,
CULL_MASK_RIGHT = 0x1000,
NO_VARIABLES = 0x0000,
ALL_VARIABLES = 0xFFFF
};
/** Set the inheritance mask used in inheritCullSettings to control which variables get overritten by the passed in CullSettings object.*/
void setInheritanceMask(unsigned int mask) { _inheritanceMask = mask; }
/** Get the inheritance mask used in inheritCullSettings to control which variables get overritten by the passed in CullSettings object.*/
unsigned int getInheritanceMask() const { return _inheritanceMask; }
/** Set the local cull settings values from specified CullSettings object.*/
void setCullSettings(const CullSettings& settings) { inheritCullSettings(settings, ALL_VARIABLES); }
/** Inherit the local cull settings variable from specified CullSettings object, according to the inheritance mask.*/
void inheritCullSettings(const CullSettings& settings) { inheritCullSettings(settings, _inheritanceMask); }
/** Inherit the local cull settings variable from specified CullSettings object, according to the inheritance mask.*/
void inheritCullSettings(const CullSettings& settings, unsigned int inheritanceMask);
/** read the environmental variables.*/ /** read the environmental variables.*/
void readEnvironmentalVariables(); void readEnvironmentalVariables();
@ -181,6 +216,7 @@ class SG_EXPORT CullSettings
protected: protected:
unsigned int _inheritanceMask;
ComputeNearFarMode _computeNearFar; ComputeNearFarMode _computeNearFar;
CullingMode _cullingMode; CullingMode _cullingMode;

View File

@ -26,6 +26,7 @@ CullSettings::CullSettings(const CullSettings& cs)
void CullSettings::setDefaults() void CullSettings::setDefaults()
{ {
_inheritanceMask = ALL_VARIABLES;
_cullingMode = DEFAULT_CULLING; _cullingMode = DEFAULT_CULLING;
_LODScale = 1.0f; _LODScale = 1.0f;
_smallFeatureCullingPixelSize = 2.0f; _smallFeatureCullingPixelSize = 2.0f;
@ -45,22 +46,24 @@ void CullSettings::setDefaults()
//_nearFarRatio = 0.00005f; //_nearFarRatio = 0.00005f;
} }
void CullSettings::setCullSettings(const CullSettings& settings) void CullSettings::inheritCullSettings(const CullSettings& settings, unsigned int inheritanceMask)
{ {
_computeNearFar = settings._computeNearFar; if (inheritanceMask & COMPUTE_NEAR_FAR_MODE) _computeNearFar = settings._computeNearFar;
_nearFarRatio = settings._nearFarRatio; if (inheritanceMask & NEAR_FAR_RATIO) _nearFarRatio = settings._nearFarRatio;
_impostorActive = settings._impostorActive; if (inheritanceMask & IMPOSTOR_ACTIVE) _impostorActive = settings._impostorActive;
_depthSortImpostorSprites = settings._depthSortImpostorSprites; if (inheritanceMask & DEPTH_SORT_IMPOSTOR_SPRITES) _depthSortImpostorSprites = settings._depthSortImpostorSprites;
_impostorPixelErrorThreshold = settings._impostorPixelErrorThreshold; if (inheritanceMask & IMPOSTOR_PIXEL_ERROR_THRESHOLD) _impostorPixelErrorThreshold = settings._impostorPixelErrorThreshold;
_numFramesToKeepImpostorSprites = settings._numFramesToKeepImpostorSprites; if (inheritanceMask & NUM_FRAMES_TO_KEEP_IMPOSTORS_SPRITES) _numFramesToKeepImpostorSprites = settings._numFramesToKeepImpostorSprites;
_cullMask = settings._cullMask; if (inheritanceMask & CULL_MASK) _cullMask = settings._cullMask;
_cullMaskLeft = settings._cullMaskLeft; if (inheritanceMask & CULL_MASK_LEFT) _cullMaskLeft = settings._cullMaskLeft;
_cullMaskRight = settings._cullMaskRight; if (inheritanceMask & CULL_MASK_RIGHT) _cullMaskRight = settings._cullMaskRight;
_cullingMode = settings._cullingMode; if (inheritanceMask & CULLING_MODE) _cullingMode = settings._cullingMode;
_LODScale = settings._LODScale; if (inheritanceMask & LOD_SCALE) _LODScale = settings._LODScale;
_smallFeatureCullingPixelSize = settings._smallFeatureCullingPixelSize; if (inheritanceMask & SMALL_FEATURE_CULLING_PIXEL_SIZE) _smallFeatureCullingPixelSize = settings._smallFeatureCullingPixelSize;
if (inheritanceMask & CLAMP_PROJECTION_MATRIX_CALLBACK) _clampProjectionMatrixCallback = settings._clampProjectionMatrixCallback;
} }
static ApplicationUsageProxy ApplicationUsageProxyCullSettings_e0(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_COMPUTE_NEAR_FAR_MODE <mode>","DO_NOT_COMPUTE_NEAR_FAR | COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES | COMPUTE_NEAR_FAR_USING_PRIMITIVES"); static ApplicationUsageProxy ApplicationUsageProxyCullSettings_e0(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_COMPUTE_NEAR_FAR_MODE <mode>","DO_NOT_COMPUTE_NEAR_FAR | COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES | COMPUTE_NEAR_FAR_USING_PRIMITIVES");
static ApplicationUsageProxy ApplicationUsageProxyCullSettings_e1(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_NEAR_FAR_RATIO <float>","Set the ratio between near and far planes - must greater than 0.0 but less than 1.0."); static ApplicationUsageProxy ApplicationUsageProxyCullSettings_e1(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_NEAR_FAR_RATIO <float>","Set the ratio between near and far planes - must greater than 0.0 but less than 1.0.");

View File

@ -618,7 +618,7 @@ void OsgCameraGroup::frame()
itr != _shvec.end(); itr != _shvec.end();
++itr) ++itr)
{ {
(*itr)->getSceneView()->setCullSettings(_cullSettings); (*itr)->getSceneView()->inheritCullSettings(_cullSettings);
} }

View File

@ -483,7 +483,7 @@ void SceneView::cullStage(const osg::Matrixd& projection,const osg::Matrixd& mod
if (!_collectOccludersVisistor) _collectOccludersVisistor = new osg::CollectOccludersVisitor; if (!_collectOccludersVisistor) _collectOccludersVisistor = new osg::CollectOccludersVisitor;
_collectOccludersVisistor->setCullSettings(*this); _collectOccludersVisistor->inheritCullSettings(*this);
_collectOccludersVisistor->reset(); _collectOccludersVisistor->reset();
@ -528,7 +528,7 @@ void SceneView::cullStage(const osg::Matrixd& projection,const osg::Matrixd& mod
cullVisitor->setTraversalNumber(_frameStamp->getFrameNumber()); cullVisitor->setTraversalNumber(_frameStamp->getFrameNumber());
} }
cullVisitor->setCullSettings(*this); cullVisitor->inheritCullSettings(*this);
cullVisitor->setClearNode(NULL); // reset earth sky on each frame. cullVisitor->setClearNode(NULL); // reset earth sky on each frame.