diff --git a/Make/debugtests.bat b/Make/debugtests.bat index 6e8bfab6c..54a19359b 100755 --- a/Make/debugtests.bat +++ b/Make/debugtests.bat @@ -22,6 +22,10 @@ echo osgcube osgcube more memleaks.log +echo osgclip +osgclip cow.osg +more memleaks.log + echo osghud glider.osg osghud glider.osg more memleaks.log diff --git a/Make/osgtests.bat b/Make/osgtests.bat index e8e5ee3e6..20a9d686c 100755 --- a/Make/osgtests.bat +++ b/Make/osgtests.bat @@ -8,6 +8,8 @@ osgbillboard lz.rgb osgcube +osgclip cow.osg + osghud glider.osg osgimpostor Town.osg diff --git a/include/osg/LightSource b/include/osg/LightSource index 65592a9d1..7e2062767 100644 --- a/include/osg/LightSource +++ b/include/osg/LightSource @@ -7,24 +7,26 @@ #include #include +#include namespace osg { /** Leaf Node for defining a light in the scene.*/ -class SG_EXPORT LightSource : public Node +class SG_EXPORT LightSource : public Group { public: LightSource(); - LightSource(const LightSource& es, const CopyOp& copyop=CopyOp::SHALLOW_COPY): - Node(es,copyop), - _light(dynamic_cast(copyop(es._light.get()))) {} + LightSource(const LightSource& ls, const CopyOp& copyop=CopyOp::SHALLOW_COPY): + Group(ls,copyop), + _value(ls._value), + _light(dynamic_cast(copyop(ls._light.get()))) {} META_Node(LightSource); /** Set the attached light.*/ - inline void setLight(Light* light) { _light = light; } + void setLight(Light* light); /** Get the attached light.*/ inline Light* getLight() { return _light.get(); } @@ -32,12 +34,19 @@ class SG_EXPORT LightSource : public Node /** Get the const attached light.*/ inline const Light* getLight() const { return _light.get(); } + /** Set the GLModes on StateSet associated with the LightSource.*/ + void setStateSetModes(StateSet&,const StateAttribute::GLModeValue) const; + + /** Set up the local StateSet */ + void setLocalStateSetModes(const StateAttribute::GLModeValue=StateAttribute::ON); + protected: virtual ~LightSource(); virtual const bool computeBound() const; + StateAttribute::GLModeValue _value; ref_ptr _light; }; diff --git a/src/osg/LightSource.cpp b/src/osg/LightSource.cpp index f7c1bc0a2..cb1e81fbb 100644 --- a/src/osg/LightSource.cpp +++ b/src/osg/LightSource.cpp @@ -6,6 +6,9 @@ LightSource::LightSource() { // switch off culling of light source nodes by default. setCullingActive(false); + _dstate = osgNew StateSet; + _value = StateAttribute::ON; + _light = osgNew Light; } @@ -14,6 +17,29 @@ LightSource::~LightSource() // ref_ptr<> automactially decrements the reference count of attached lights. } + +void LightSource::setLight(Light* light) +{ + _light = light; + setLocalStateSetModes(_value); +} + +// Set the GLModes on StateSet associated with the ClipPlanes. +void LightSource::setStateSetModes(StateSet& stateset,const StateAttribute::GLModeValue value) const +{ + if (_light.valid()) + { + _light->setStateSetModes(stateset,value); + } +} + +void LightSource::setLocalStateSetModes(const StateAttribute::GLModeValue value) +{ + if (!_dstate) _dstate = osgNew StateSet; + _dstate->setAllToInherit(); + setStateSetModes(*_dstate,value); +} + const bool LightSource::computeBound() const { // note, don't do anything right now as the light itself is not