diff --git a/include/osg/AutoTransform b/include/osg/AutoTransform index 144cc73a5..7dfd62d59 100644 --- a/include/osg/AutoTransform +++ b/include/osg/AutoTransform @@ -73,24 +73,6 @@ class SG_EXPORT AutoTransform : public Transform AutoRotateMode getAutoRotateMode() const { return _autoRotateMode; } -#ifdef USE_DEPRECATED_API - void setAutoRotateToScreen(bool autoRotateToScreen) - { - setAutoRotateMode(autoRotateToScreen?ROTATE_TO_SCREEN:NO_ROTATION); - } - - bool getAutoRotateToCamera() const { return _autoRotateMode==ROTATE_TO_SCREEN; } - - void setAutoRotateToCamera(bool autoRotateToCamera) - { - setAutoRotateMode(autoRotateToScreen?ROTATE_TO_CAMERA:NO_ROTATION); - } - - bool getAutoRotateToCamera() const { return _autoRotateMode==ROTATE_TO_SCREEN; } -#endif - - - void setAutoScaleToScreen(bool autoScaleToScreen) { _autoScaleToScreen = autoScaleToScreen; _matrixDirty=true; } bool getAutoScaleToScreen() const { return _autoScaleToScreen; } diff --git a/include/osg/Export b/include/osg/Export index 0df5bf545..6df01ae8b 100644 --- a/include/osg/Export +++ b/include/osg/Export @@ -17,7 +17,7 @@ // define USE_DEPRECATED_API is used to include in API which is being fazed out // if you can compile your apps with this turned off you are // well placed for compatablity with future versions. -// #define USE_DEPRECATED_API +#define USE_DEPRECATED_API #if defined(_MSC_VER) #pragma warning( disable : 4244 ) diff --git a/include/osg/StateSet b/include/osg/StateSet index d5a8970c2..6e2953cd4 100644 --- a/include/osg/StateSet +++ b/include/osg/StateSet @@ -57,14 +57,19 @@ class SG_EXPORT StateSet : public Object bool operator == (const StateSet& rhs) const { return compare(rhs)==0; } bool operator != (const StateSet& rhs) const { return compare(rhs)!=0; } - /** set all the modes to on or off so that it defines a + /** Set all the modes to on or off so that it defines a complete state, typically used for a default global state.*/ void setGlobalDefaults(); - /** set all the modes to inherit, typically used to signify +#ifdef USE_DEPRECATED_API + /** Set all the modes to inherit, typically used to signify nodes which inherit all of their modes for the global state.*/ - void setAllToInherit(); - + void setAllToInherit() { clear(); } +#endif + + /** Clear the StateSet of all modes and attributes.*/ + void clear(); + /** merge this stateset with stateset rhs, this overrides * the rhs if OVERRIDE is specified, otherwise rhs takes precedence.*/ void merge(const StateSet& rhs); @@ -72,14 +77,18 @@ class SG_EXPORT StateSet : public Object /** a container to map GLModes to their respective GLModeValues.*/ typedef std::map ModeList; - /** set this StateSet to contain specified GLMode and value.*/ + /** Set this StateSet to contain specified GLMode and value.*/ void setMode(StateAttribute::GLMode mode, StateAttribute::GLModeValue value); - /** set this StateSet to inherit specified GLMode type from parents. +#ifdef USE_DEPRECATED_API + /** Set this StateSet to inherit specified GLMode type from parents. * Has the effect of deleting any GLMode of specified type from StateSet.*/ - void setModeToInherit(StateAttribute::GLMode mode); + void setModeToInherit(StateAttribute::GLMode mode) { removeMode(mode); } +#endif + /** Remove mode from StateSet.*/ + void removeMode(StateAttribute::GLMode mode); - /** get specified GLModeValue for specified GLMode. + /** Get specified GLModeValue for specified GLMode. * returns INHERIT if no GLModeValue is contained within StateSet.*/ StateAttribute::GLModeValue getMode(StateAttribute::GLMode mode) const; @@ -91,28 +100,36 @@ class SG_EXPORT StateSet : public Object - /** simple pairing between an attribute and its override flag.*/ + /** Simple pairing between an attribute and its override flag.*/ typedef std::pair,StateAttribute::OverrideValue> RefAttributePair; /** a container to map StateAttribyte::Types to their respective RefAttributePair.*/ typedef std::map AttributeList; - /** set this StateSet to contain specified attribute and override flag.*/ + /** Set this StateSet to contain specified attribute and override flag.*/ void setAttribute(StateAttribute *attribute, StateAttribute::OverrideValue value=StateAttribute::OFF); - /** set this StateSet to contain specified attribute and set the associated GLMode's to specified value.*/ + /** Set this StateSet to contain specified attribute and set the associated GLMode's to specified value.*/ void setAttributeAndModes(StateAttribute *attribute, StateAttribute::GLModeValue value=StateAttribute::ON); - /** set this StateSet to inherit specified attribute type from parents. - * has the effect of deleting any state attributes of specified type from StateSet.*/ - void setAttributeToInherit(StateAttribute::Type type); - /** get specified StateAttribute for specified type. +#ifdef USE_DEPRECATED_API + /** Set this StateSet to inherit specified attribute type from parents. + * has the effect of deleting any state attributes of specified type from StateSet.*/ + void setAttributeToInherit(StateAttribute::Type type) { removeAttribute(type); } +#endif + /** remove attribute of specified type from StateSet.*/ + void removeAttribute(StateAttribute::Type type); + + /** remove attribute from StateSet.*/ + void removeAttribute(StateAttribute *attribute); + + /** Get specified StateAttribute for specified type. * Returns NULL if no type is contained within StateSet.*/ StateAttribute* getAttribute(StateAttribute::Type type); - /** get specified const StateAttribute for specified type. + /** Get specified const StateAttribute for specified type. * Returns NULL if no type is contained within const StateSet.*/ const StateAttribute* getAttribute(StateAttribute::Type type) const; - /** get specified RefAttributePair for specified type. + /** Get specified RefAttributePair for specified type. * Returns NULL if no type is contained within StateSet.*/ const RefAttributePair* getAttributePair(StateAttribute::Type type) const; @@ -126,13 +143,18 @@ class SG_EXPORT StateSet : public Object typedef std::vector TextureModeList; - /** set this StateSet to contain specified GLMode and value.*/ + /** Set this StateSet to contain specified GLMode and value.*/ void setTextureMode(unsigned int unit,StateAttribute::GLMode mode, StateAttribute::GLModeValue value); - /** set this StateSet to inherit specified GLMode type from parents. - * has the effect of deleting any GLMode of specified type from StateSet.*/ - void setTextureModeToInherit(unsigned int unit,StateAttribute::GLMode mode); - /** get specified GLModeValue for specified GLMode. +#ifdef USE_DEPRECATED_API + /** Set this StateSet to inherit specified GLMode type from parents. + * has the effect of deleting any GLMode of specified type from StateSet.*/ + void setTextureModeToInherit(unsigned int unit,StateAttribute::GLMode mode) { removeTextureMode(unit,mode); } +#endif + /** Remove texture mode from StateSet.*/ + void removeTextureMode(unsigned int unit,StateAttribute::GLMode mode); + + /** Get specified GLModeValue for specified GLMode. * returns INHERIT if no GLModeValue is contained within StateSet.*/ StateAttribute::GLModeValue getTextureMode(unsigned int unit,StateAttribute::GLMode mode) const; @@ -145,23 +167,32 @@ class SG_EXPORT StateSet : public Object typedef std::vector TextureAttributeList; - /** set this StateSet to contain specified attribute and override flag.*/ + /** Set this StateSet to contain specified attribute and override flag.*/ void setTextureAttribute(unsigned int unit,StateAttribute *attribute, StateAttribute::OverrideValue value=StateAttribute::OFF); - /** set this StateSet to contain specified attribute and set the associated GLMode's to specified value.*/ + /** Set this StateSet to contain specified attribute and set the associated GLMode's to specified value.*/ void setTextureAttributeAndModes(unsigned int unit,StateAttribute *attribute, StateAttribute::GLModeValue value=StateAttribute::ON); - /** set this StateSet to inherit specified attribute type from parents. - * Has the effect of deleting any state attributes of specified type from StateSet.*/ - void setTextureAttributeToInherit(unsigned int unit,StateAttribute::Type type); - /** get specified Texture related StateAttribute for specified type. +#ifdef USE_DEPRECATED_API + /** Set this StateSet to inherit specified attribute type from parents. + * Has the effect of deleting any state attributes of specified type from StateSet.*/ + void setTextureAttributeToInherit(unsigned int unit,StateAttribute::Type type) { removeTextureAttribute(unit,type); } +#endif + + /** remove texture attribute of specified type from StateSet.*/ + void removeTextureAttribute(unsigned int unit, StateAttribute::Type type); + + /** remove texture attribute from StateSet.*/ + void removeTextureAttribute(unsigned int unit, StateAttribute *attribute); + + /** Get specified Texture related StateAttribute for specified type. * Returns NULL if no type is contained within StateSet.*/ StateAttribute* getTextureAttribute(unsigned int unit,StateAttribute::Type type); - /** get specified Texture related const StateAttribute for specified type. + /** Get specified Texture related const StateAttribute for specified type. * Returns NULL if no type is contained within const StateSet.*/ const StateAttribute* getTextureAttribute(unsigned int unit,StateAttribute::Type type) const; - /** get specified Texture related RefAttributePair for specified type. + /** Get specified Texture related RefAttributePair for specified type. * Returns NULL if no type is contained within StateSet.*/ const RefAttributePair* getTextureAttributePair(unsigned int unit,StateAttribute::Type type) const; @@ -183,14 +214,14 @@ class SG_EXPORT StateSet : public Object TRANSPARENT_BIN = 2 }; - /** set the RenderingHint of the StateSet. + /** Set the RenderingHint of the StateSet. * RenderingHint is used by osgUtil::Renderer to determine which * draw bin to drop associated osg::Drawables in. For opaque * objects OPAQUE_BIN would typical used, which TRANSPARENT_BIN * should be used for objects which need to be depth sorted.*/ void setRenderingHint(int hint); - /** get the RenderingHint of the StateSet.*/ + /** Get the RenderingHint of the StateSet.*/ inline int getRenderingHint() const { return _renderingHint; } enum RenderBinMode @@ -201,22 +232,22 @@ class SG_EXPORT StateSet : public Object ENCLOSE_RENDERBIN_DETAILS }; - /** set the render bin details.*/ + /** Set the render bin details.*/ void setRenderBinDetails(int binNum,const std::string& binName,RenderBinMode mode=USE_RENDERBIN_DETAILS); - /** set the render bin details to inherit.*/ + /** Set the render bin details to inherit.*/ void setRenderBinToInherit(); - /** get the render bin mode.*/ + /** Get the render bin mode.*/ inline RenderBinMode getRenderBinMode() const { return _binMode; } - /** get whether the render bin details are set and should be used.*/ + /** Get whether the render bin details are set and should be used.*/ inline bool useRenderBinDetails() const { return _binMode!=INHERIT_RENDERBIN_DETAILS; } - /** get the render bin number.*/ + /** Get the render bin number.*/ inline int getBinNumber() const { return _binNum; } - /** get the render bin name.*/ + /** Get the render bin name.*/ inline const std::string& getBinName() const { return _binName; } diff --git a/src/osg/ClipNode.cpp b/src/osg/ClipNode.cpp index 713ea9861..ff069dbee 100644 --- a/src/osg/ClipNode.cpp +++ b/src/osg/ClipNode.cpp @@ -121,7 +121,7 @@ void ClipNode::setStateSetModes(StateSet& stateset,const StateAttribute::GLModeV void ClipNode::setLocalStateSetModes(const StateAttribute::GLModeValue value) { if (!_stateset) _stateset = new StateSet; - _stateset->setAllToInherit(); + _stateset->clear(); setStateSetModes(*_stateset,value); } diff --git a/src/osg/LightSource.cpp b/src/osg/LightSource.cpp index 3c215c9af..7cbc7f846 100644 --- a/src/osg/LightSource.cpp +++ b/src/osg/LightSource.cpp @@ -54,7 +54,7 @@ void LightSource::setStateSetModes(StateSet& stateset,StateAttribute::GLModeValu void LightSource::setLocalStateSetModes(StateAttribute::GLModeValue value) { if (!_stateset) _stateset = new StateSet; - _stateset->setAllToInherit(); + _stateset->clear(); setStateSetModes(*_stateset,value); } diff --git a/src/osg/State.cpp b/src/osg/State.cpp index de135a12b..f1f2d1e6d 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -192,7 +192,7 @@ void State::popStateSet() void State::captureCurrentState(StateSet& stateset) const { // empty the stateset first. - stateset.setAllToInherit(); + stateset.clear(); for(ModeMap::const_iterator mitr=_modeMap.begin(); mitr!=_modeMap.end(); diff --git a/src/osg/StateSet.cpp b/src/osg/StateSet.cpp index a09bbff44..7013c7bcd 100644 --- a/src/osg/StateSet.cpp +++ b/src/osg/StateSet.cpp @@ -368,7 +368,7 @@ void StateSet::setGlobalDefaults() } -void StateSet::setAllToInherit() +void StateSet::clear() { _renderingHint = DEFAULT_BIN; @@ -513,7 +513,7 @@ void StateSet::setMode(StateAttribute::GLMode mode, StateAttribute::GLModeValue } } -void StateSet::setModeToInherit(StateAttribute::GLMode mode) +void StateSet::removeMode(StateAttribute::GLMode mode) { if (!s_textureGLModeSet.isTextureMode(mode)) { @@ -525,7 +525,7 @@ void StateSet::setModeToInherit(StateAttribute::GLMode mode) notify(NOTICE)<<" assuming setTextureModeToInherit(unit=0,mode) instead."<getType()); + removeAttribute(attribute->getType()); } else { @@ -592,7 +592,7 @@ void StateSet::setAttributeAndModes(StateAttribute *attribute, StateAttribute::G } } -void StateSet::setAttributeToInherit(StateAttribute::Type type) +void StateSet::removeAttribute(StateAttribute::Type type) { AttributeList::iterator itr = _attributeList.find(type); if (itr!=_attributeList.end()) @@ -602,6 +602,20 @@ void StateSet::setAttributeToInherit(StateAttribute::Type type) } } +void StateSet::removeAttribute(StateAttribute* attribute) +{ + if (!attribute) return; + + AttributeList::iterator itr = _attributeList.find(attribute->getType()); + if (itr!=_attributeList.end()) + { + if (itr->second.first != attribute) return; + + setAssociatedModes(itr->second.first.get(),StateAttribute::INHERIT); + _attributeList.erase(itr); + } +} + StateAttribute* StateSet::getAttribute(StateAttribute::Type type) { return getAttribute(_attributeList,type); @@ -633,7 +647,7 @@ void StateSet::setTextureMode(unsigned int unit,StateAttribute::GLMode mode, Sta } } -void StateSet::setTextureModeToInherit(unsigned int unit,StateAttribute::GLMode mode) +void StateSet::removeTextureMode(unsigned int unit,StateAttribute::GLMode mode) { if (s_textureGLModeSet.isTextureMode(mode)) { @@ -646,7 +660,7 @@ void StateSet::setTextureModeToInherit(unsigned int unit,StateAttribute::GLMode notify(NOTICE)<<" assuming setModeToInherit(unit=0,mode) instead."<getType()); + removeTextureAttribute(unit,attribute->getType()); } else { @@ -715,7 +729,7 @@ void StateSet::setTextureAttributeAndModes(unsigned int unit,StateAttribute *att } -void StateSet::setTextureAttributeToInherit(unsigned int unit,StateAttribute::Type type) +void StateSet::removeTextureAttribute(unsigned int unit,StateAttribute::Type type) { if (unit>=_textureAttributeList.size()) return; AttributeList& attributeList = _textureAttributeList[unit]; diff --git a/src/osgPlugins/Inventor/ConvertFromInventor.cpp b/src/osgPlugins/Inventor/ConvertFromInventor.cpp index 461e6d512..bcba2115f 100644 --- a/src/osgPlugins/Inventor/ConvertFromInventor.cpp +++ b/src/osgPlugins/Inventor/ConvertFromInventor.cpp @@ -432,7 +432,7 @@ osg::StateSet* ConvertFromInventor::getStateSet(SoCallbackAction* action) osg::StateSet* stateSet = new osg::StateSet; // Inherit modes from the global state - stateSet->setAllToInherit(); + stateSet->clear(); SbColor ambient, diffuse, specular, emission; float shininess, transparency;