Added osg::UnfiromBase* StateSet::getUniformBase(..) and osg::Uniform* StateSet::getUniform(..) methods to help with backwards compatibility

This commit is contained in:
Robert Osfield 2018-03-19 12:08:28 +00:00
parent 10e1c29d2e
commit 76c584ab25
2 changed files with 14 additions and 4 deletions

View File

@ -320,7 +320,11 @@ class OSG_EXPORT StateSet : public Object
/** Get Uniform for specified name.
* Returns NULL if no matching Uniform is contained within StateSet.*/
UniformBase* getUniform(const std::string& name);
UniformBase* getUniformBase(const std::string& name);
/** Get Uniform for specified name.
* Returns NULL if no matching Uniform is contained within StateSet.*/
Uniform* getUniform(const std::string& name) { return dynamic_cast<Uniform*>(getUniformBase(name)); }
/** Get Uniform for specified name, if one is not available create it, add it to this StateSet and return a pointer to it.*/
Uniform* getOrCreateUniform(const std::string& name, Uniform::Type type, unsigned int numElements=1);
@ -347,7 +351,13 @@ class OSG_EXPORT StateSet : public Object
/** Get const Uniform for specified name.
* Returns NULL if no matching Uniform is contained within StateSet.*/
const UniformBase* getUniform(const std::string& name) const;
const UniformBase* getUniformBase(const std::string& name) const;
/** Get const Uniform for specified name.
* Returns NULL if no matching Uniform is contained within StateSet.*/
const Uniform* getUniform(const std::string& name) const { return dynamic_cast<const Uniform*>(getUniformBase(name)); }
/** Get specified RefUniformPair for specified Uniform name.
* Returns NULL if no Uniform is contained within StateSet.*/

View File

@ -1341,7 +1341,7 @@ void StateSet::removeUniform(UniformBase* uniform)
}
}
UniformBase* StateSet::getUniform(const std::string& name)
UniformBase* StateSet::getUniformBase(const std::string& name)
{
UniformList::iterator itr = _uniformList.find(name);
if (itr!=_uniformList.end()) return itr->second.first.get();
@ -1367,7 +1367,7 @@ Uniform* StateSet::getOrCreateUniform(const std::string& name, Uniform::Type typ
}
const UniformBase* StateSet::getUniform(const std::string& name) const
const UniformBase* StateSet::getUniformBase(const std::string& name) const
{
UniformList::const_iterator itr = _uniformList.find(name);
if (itr!=_uniformList.end()) return itr->second.first.get();