Added new clear, removeAttribute, removeMode, removeTextureAttribute and
removeTextureMode method and deprecated the setToInherit equivilants.
This commit is contained in:
parent
c27bf441e2
commit
d77e6a0829
@ -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; }
|
||||
|
@ -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 )
|
||||
|
@ -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<StateAttribute::GLMode,StateAttribute::GLModeValue> 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<ref_ptr<StateAttribute>,StateAttribute::OverrideValue> RefAttributePair;
|
||||
/** a container to map StateAttribyte::Types to their respective RefAttributePair.*/
|
||||
typedef std::map<StateAttribute::Type,RefAttributePair> 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<ModeList> 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<AttributeList> 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; }
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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."<<std::endl;
|
||||
notify(NOTICE)<<" please change calling code to use appropriate call."<<std::endl;
|
||||
|
||||
setTextureModeToInherit(0,mode);
|
||||
removeTextureMode(0,mode);
|
||||
}
|
||||
|
||||
}
|
||||
@ -573,7 +573,7 @@ void StateSet::setAttributeAndModes(StateAttribute *attribute, StateAttribute::G
|
||||
{
|
||||
if (value&StateAttribute::INHERIT)
|
||||
{
|
||||
setAttributeToInherit(attribute->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."<<std::endl;
|
||||
notify(NOTICE)<<" please change calling code to use appropriate call."<<std::endl;
|
||||
|
||||
setModeToInherit(mode);
|
||||
removeMode(mode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -696,7 +710,7 @@ void StateSet::setTextureAttributeAndModes(unsigned int unit,StateAttribute *att
|
||||
{
|
||||
if (value&StateAttribute::INHERIT)
|
||||
{
|
||||
setTextureAttributeToInherit(unit,attribute->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];
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user