Added CullingSettngs::s/getInheritanceMask() and inheritCullSettings(,) method.
This commit is contained in:
parent
840ae915e9
commit
4192ef796b
@ -51,10 +51,45 @@ class SG_EXPORT CullSettings
|
||||
return *this;
|
||||
}
|
||||
|
||||
void setCullSettings(const CullSettings& settings);
|
||||
|
||||
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.*/
|
||||
void readEnvironmentalVariables();
|
||||
|
||||
@ -181,6 +216,7 @@ class SG_EXPORT CullSettings
|
||||
|
||||
protected:
|
||||
|
||||
unsigned int _inheritanceMask;
|
||||
|
||||
ComputeNearFarMode _computeNearFar;
|
||||
CullingMode _cullingMode;
|
||||
|
@ -26,6 +26,7 @@ CullSettings::CullSettings(const CullSettings& cs)
|
||||
|
||||
void CullSettings::setDefaults()
|
||||
{
|
||||
_inheritanceMask = ALL_VARIABLES;
|
||||
_cullingMode = DEFAULT_CULLING;
|
||||
_LODScale = 1.0f;
|
||||
_smallFeatureCullingPixelSize = 2.0f;
|
||||
@ -45,22 +46,24 @@ void CullSettings::setDefaults()
|
||||
//_nearFarRatio = 0.00005f;
|
||||
}
|
||||
|
||||
void CullSettings::setCullSettings(const CullSettings& settings)
|
||||
void CullSettings::inheritCullSettings(const CullSettings& settings, unsigned int inheritanceMask)
|
||||
{
|
||||
_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;
|
||||
if (inheritanceMask & COMPUTE_NEAR_FAR_MODE) _computeNearFar = settings._computeNearFar;
|
||||
if (inheritanceMask & NEAR_FAR_RATIO) _nearFarRatio = settings._nearFarRatio;
|
||||
if (inheritanceMask & IMPOSTOR_ACTIVE) _impostorActive = settings._impostorActive;
|
||||
if (inheritanceMask & DEPTH_SORT_IMPOSTOR_SPRITES) _depthSortImpostorSprites = settings._depthSortImpostorSprites;
|
||||
if (inheritanceMask & IMPOSTOR_PIXEL_ERROR_THRESHOLD) _impostorPixelErrorThreshold = settings._impostorPixelErrorThreshold;
|
||||
if (inheritanceMask & NUM_FRAMES_TO_KEEP_IMPOSTORS_SPRITES) _numFramesToKeepImpostorSprites = settings._numFramesToKeepImpostorSprites;
|
||||
if (inheritanceMask & CULL_MASK) _cullMask = settings._cullMask;
|
||||
if (inheritanceMask & CULL_MASK_LEFT) _cullMaskLeft = settings._cullMaskLeft;
|
||||
if (inheritanceMask & CULL_MASK_RIGHT) _cullMaskRight = settings._cullMaskRight;
|
||||
if (inheritanceMask & CULLING_MODE) _cullingMode = settings._cullingMode;
|
||||
if (inheritanceMask & LOD_SCALE) _LODScale = settings._LODScale;
|
||||
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_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.");
|
||||
|
||||
|
@ -618,7 +618,7 @@ void OsgCameraGroup::frame()
|
||||
itr != _shvec.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->getSceneView()->setCullSettings(_cullSettings);
|
||||
(*itr)->getSceneView()->inheritCullSettings(_cullSettings);
|
||||
}
|
||||
|
||||
|
||||
|
@ -483,7 +483,7 @@ void SceneView::cullStage(const osg::Matrixd& projection,const osg::Matrixd& mod
|
||||
|
||||
if (!_collectOccludersVisistor) _collectOccludersVisistor = new osg::CollectOccludersVisitor;
|
||||
|
||||
_collectOccludersVisistor->setCullSettings(*this);
|
||||
_collectOccludersVisistor->inheritCullSettings(*this);
|
||||
|
||||
_collectOccludersVisistor->reset();
|
||||
|
||||
@ -528,7 +528,7 @@ void SceneView::cullStage(const osg::Matrixd& projection,const osg::Matrixd& mod
|
||||
cullVisitor->setTraversalNumber(_frameStamp->getFrameNumber());
|
||||
}
|
||||
|
||||
cullVisitor->setCullSettings(*this);
|
||||
cullVisitor->inheritCullSettings(*this);
|
||||
|
||||
cullVisitor->setClearNode(NULL); // reset earth sky on each frame.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user