Added handling the ShadowSettings::LightNum for selecting which light to use.
This commit is contained in:
parent
b2fd8f4059
commit
83524f958e
@ -28,8 +28,11 @@ class OSGSHADOW_EXPORT ShadowSettings : public osg::Object
|
||||
|
||||
META_Object(osgShadow, ShadowSettings);
|
||||
|
||||
void setLightNum(unsigned int lightNum) { _lightNum = lightNum; }
|
||||
unsigned int getLightNum() const { return _lightNum; }
|
||||
/** Set the LightNum of the light in the scene to assign a shadow for.
|
||||
* Default value is -1, which signifies that shadow technique should automatically select an active light
|
||||
* to assign a shadow, typically this will be the first active light found. */
|
||||
void setLightNum(int lightNum) { _lightNum = lightNum; }
|
||||
int getLightNum() const { return _lightNum; }
|
||||
|
||||
void setBaseShadowTextureUnit(unsigned int unit) { _baseShadowTextureUnit = unit; }
|
||||
unsigned int getBaseShadowTextureUnit() const { return _baseShadowTextureUnit; }
|
||||
@ -79,7 +82,7 @@ class OSGSHADOW_EXPORT ShadowSettings : public osg::Object
|
||||
|
||||
virtual ~ShadowSettings();
|
||||
|
||||
unsigned int _lightNum;
|
||||
int _lightNum;
|
||||
unsigned int _baseShadowTextureUnit;
|
||||
osg::Vec2s _textureSize;
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
using namespace osgShadow;
|
||||
|
||||
ShadowSettings::ShadowSettings():
|
||||
_lightNum(-1),
|
||||
_baseShadowTextureUnit(1),
|
||||
_textureSize(2048,2048),
|
||||
_minimumShadowMapNearFarRatio(0.01),
|
||||
@ -29,6 +30,7 @@ ShadowSettings::ShadowSettings():
|
||||
|
||||
ShadowSettings::ShadowSettings(const ShadowSettings& ss, const osg::CopyOp& copyop):
|
||||
Object(ss,copyop),
|
||||
_lightNum(ss._lightNum),
|
||||
_baseShadowTextureUnit(ss._baseShadowTextureUnit),
|
||||
_textureSize(ss._textureSize),
|
||||
_minimumShadowMapNearFarRatio(ss._minimumShadowMapNearFarRatio),
|
||||
|
@ -790,6 +790,9 @@ bool ViewDependentShadowMap::selectActiveLights(osgUtil::CullVisitor* cv, ViewDe
|
||||
osgUtil::PositionalStateContainer::AttrMatrixList& aml =
|
||||
rs->getPositionalStateContainer()->getAttrMatrixList();
|
||||
|
||||
|
||||
const ShadowSettings* settings = getShadowedScene()->getShadowSettings();
|
||||
|
||||
for(osgUtil::PositionalStateContainer::AttrMatrixList::reverse_iterator itr = aml.rbegin();
|
||||
itr != aml.rend();
|
||||
++itr)
|
||||
@ -797,6 +800,9 @@ bool ViewDependentShadowMap::selectActiveLights(osgUtil::CullVisitor* cv, ViewDe
|
||||
const osg::Light* light = dynamic_cast<const osg::Light*>(itr->first.get());
|
||||
if (light)
|
||||
{
|
||||
// is LightNum matched to that defined in settings
|
||||
if (settings && settings->getLightNum()>=0 && light->getLightNum()!=settings->getLightNum()) break;
|
||||
|
||||
LightDataList::iterator pll_itr = pll.begin();
|
||||
for(; pll_itr != pll.end(); ++pll_itr)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user