Added new clear, removeAttribute, removeMode, removeTextureAttribute and

removeTextureMode method and deprecated the setToInherit equivilants.
This commit is contained in:
Robert Osfield
2004-10-07 09:40:03 +00:00
parent c27bf441e2
commit d77e6a0829
8 changed files with 97 additions and 70 deletions

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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();

View File

@@ -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];

View File

@@ -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;