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);
|
META_Object(osgShadow, ShadowSettings);
|
||||||
|
|
||||||
void setLightNum(unsigned int lightNum) { _lightNum = lightNum; }
|
/** Set the LightNum of the light in the scene to assign a shadow for.
|
||||||
unsigned int getLightNum() const { return _lightNum; }
|
* 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; }
|
void setBaseShadowTextureUnit(unsigned int unit) { _baseShadowTextureUnit = unit; }
|
||||||
unsigned int getBaseShadowTextureUnit() const { return _baseShadowTextureUnit; }
|
unsigned int getBaseShadowTextureUnit() const { return _baseShadowTextureUnit; }
|
||||||
@ -79,7 +82,7 @@ class OSGSHADOW_EXPORT ShadowSettings : public osg::Object
|
|||||||
|
|
||||||
virtual ~ShadowSettings();
|
virtual ~ShadowSettings();
|
||||||
|
|
||||||
unsigned int _lightNum;
|
int _lightNum;
|
||||||
unsigned int _baseShadowTextureUnit;
|
unsigned int _baseShadowTextureUnit;
|
||||||
osg::Vec2s _textureSize;
|
osg::Vec2s _textureSize;
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
using namespace osgShadow;
|
using namespace osgShadow;
|
||||||
|
|
||||||
ShadowSettings::ShadowSettings():
|
ShadowSettings::ShadowSettings():
|
||||||
|
_lightNum(-1),
|
||||||
_baseShadowTextureUnit(1),
|
_baseShadowTextureUnit(1),
|
||||||
_textureSize(2048,2048),
|
_textureSize(2048,2048),
|
||||||
_minimumShadowMapNearFarRatio(0.01),
|
_minimumShadowMapNearFarRatio(0.01),
|
||||||
@ -29,6 +30,7 @@ ShadowSettings::ShadowSettings():
|
|||||||
|
|
||||||
ShadowSettings::ShadowSettings(const ShadowSettings& ss, const osg::CopyOp& copyop):
|
ShadowSettings::ShadowSettings(const ShadowSettings& ss, const osg::CopyOp& copyop):
|
||||||
Object(ss,copyop),
|
Object(ss,copyop),
|
||||||
|
_lightNum(ss._lightNum),
|
||||||
_baseShadowTextureUnit(ss._baseShadowTextureUnit),
|
_baseShadowTextureUnit(ss._baseShadowTextureUnit),
|
||||||
_textureSize(ss._textureSize),
|
_textureSize(ss._textureSize),
|
||||||
_minimumShadowMapNearFarRatio(ss._minimumShadowMapNearFarRatio),
|
_minimumShadowMapNearFarRatio(ss._minimumShadowMapNearFarRatio),
|
||||||
|
@ -790,6 +790,9 @@ bool ViewDependentShadowMap::selectActiveLights(osgUtil::CullVisitor* cv, ViewDe
|
|||||||
osgUtil::PositionalStateContainer::AttrMatrixList& aml =
|
osgUtil::PositionalStateContainer::AttrMatrixList& aml =
|
||||||
rs->getPositionalStateContainer()->getAttrMatrixList();
|
rs->getPositionalStateContainer()->getAttrMatrixList();
|
||||||
|
|
||||||
|
|
||||||
|
const ShadowSettings* settings = getShadowedScene()->getShadowSettings();
|
||||||
|
|
||||||
for(osgUtil::PositionalStateContainer::AttrMatrixList::reverse_iterator itr = aml.rbegin();
|
for(osgUtil::PositionalStateContainer::AttrMatrixList::reverse_iterator itr = aml.rbegin();
|
||||||
itr != aml.rend();
|
itr != aml.rend();
|
||||||
++itr)
|
++itr)
|
||||||
@ -797,6 +800,9 @@ bool ViewDependentShadowMap::selectActiveLights(osgUtil::CullVisitor* cv, ViewDe
|
|||||||
const osg::Light* light = dynamic_cast<const osg::Light*>(itr->first.get());
|
const osg::Light* light = dynamic_cast<const osg::Light*>(itr->first.get());
|
||||||
if (light)
|
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();
|
LightDataList::iterator pll_itr = pll.begin();
|
||||||
for(; pll_itr != pll.end(); ++pll_itr)
|
for(; pll_itr != pll.end(); ++pll_itr)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user