diff --git a/include/osg/State b/include/osg/State index c34533295..beab1600f 100644 --- a/include/osg/State +++ b/include/osg/State @@ -411,9 +411,9 @@ class SG_EXPORT State : public Referenced /** Get the DisplaySettings */ inline const DisplaySettings* getDisplaySettings() const { return _displaySettings.get(); } - typedef std::pair AttributePair; - typedef std::vector AttributeVec; - typedef std::vector ValueVec; + typedef std::pair AttributePair; + typedef std::vector AttributeVec; + typedef std::vector ValueVec; private: @@ -590,7 +590,7 @@ inline void State::pushModeList(ModeMap& modeMap,const StateSet::ModeList& modeL // first pair so simply push incomming pair to back. ms.valueVec.push_back(mitr->second); } - else if (ms.valueVec.back() & StateAttribute::OVERRIDE) // check the existing override flag + else if ((ms.valueVec.back() & StateAttribute::OVERRIDE) && !(mitr->second & StateAttribute::PROTECTED)) // check the existing override flag { // push existing back since override keeps the previoius value. ms.valueVec.push_back(ms.valueVec.back()); @@ -618,7 +618,7 @@ inline void State::pushAttributeList(AttributeMap& attributeMap,const StateSet:: as.attributeVec.push_back( AttributePair(aitr->second.first.get(),aitr->second.second)); } - else if (as.attributeVec.back().second & StateAttribute::OVERRIDE) // check the existing override flag + else if ((as.attributeVec.back().second & StateAttribute::OVERRIDE) && !(aitr->second.second & StateAttribute::PROTECTED)) // check the existing override flag { // push existing back since override keeps the previoius value. as.attributeVec.push_back(as.attributeVec.back()); @@ -720,7 +720,7 @@ inline void State::applyModeList(ModeMap& modeMap,const StateSet::ModeList& mode ModeStack& ms = this_mitr->second; - if (!ms.valueVec.empty() && ms.valueVec.back() & StateAttribute::OVERRIDE) + if (!ms.valueVec.empty() && (ms.valueVec.back() & StateAttribute::OVERRIDE) && !(ds_mitr->second & StateAttribute::PROTECTED)) { // override is on, there just treat as a normal apply on modes. @@ -835,14 +835,14 @@ inline void State::applyAttributeList(AttributeMap& attributeMap,const StateSet: } else { - // this_mitr & ds_mitr refer to the same mode, check the overide - // if any otherwise just apply the incomming mode. + // this_mitr & ds_mitr refer to the same attribute, check the overide + // if any otherwise just apply the incomming attribute AttributeStack& as = this_aitr->second; - if (!as.attributeVec.empty() && as.attributeVec.back().second) + if (!as.attributeVec.empty() && (as.attributeVec.back().second & StateAttribute::OVERRIDE) && !(ds_aitr->second.second & StateAttribute::PROTECTED)) { - // override is os, there just treat as a normal apply on modes. + // override is on, there just treat as a normal apply on modes. if (as.changed) { diff --git a/include/osg/StateAttribute b/include/osg/StateAttribute index eb3c367d0..0e7b793be 100644 --- a/include/osg/StateAttribute +++ b/include/osg/StateAttribute @@ -78,14 +78,18 @@ class SG_EXPORT StateAttribute : public Object OFF = 0x0, /** means that associated GLMode is enabled and Override is disabled.*/ ON = 0x1, - /** Overriding of GLMode's or StateAttributes is enabled.*/ + /** Overriding of GLMode's or StateAttributes is enabled, so that state below it is overriden.*/ OVERRIDE = 0x2, + /** Protecting of GLMode's os StateAttributes is enabled, so that state from above connot override this and below state.*/ + PROTECTED = 0x4, +#ifdef USE_DEPRECATED_API /** Equivilant to OFF | OVERRIDE.*/ OVERRIDE_OFF = 0x2, /** Equivilant to ON | OVERRIDE.*/ OVERRIDE_ON = 0x3, +#endif /** means that GLMode or StateAttribute should in inherited from above.*/ - INHERIT = 0x4 + INHERIT = 0x8 }; /** Type identifier to differentiate between different state types. */