diff --git a/include/osg/StateSet b/include/osg/StateSet index eb8910324..79683a602 100644 --- a/include/osg/StateSet +++ b/include/osg/StateSet @@ -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(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(getUniformBase(name)); } + /** Get specified RefUniformPair for specified Uniform name. * Returns NULL if no Uniform is contained within StateSet.*/ diff --git a/src/osg/StateSet.cpp b/src/osg/StateSet.cpp index fbf5bbef7..3e0f68606 100644 --- a/src/osg/StateSet.cpp +++ b/src/osg/StateSet.cpp @@ -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();