Added osg::Object::asStateSet() implementation and usage to avoid use of dynamic_cast<>

This commit is contained in:
Robert Osfield
2016-01-18 20:05:20 +00:00
parent 340615de55
commit 3e92c1fc43
4 changed files with 22 additions and 6 deletions

View File

@@ -92,8 +92,8 @@ bool osg::isTextureMode(StateAttribute::GLMode mode)
//
bool StateSet::Callback::run(osg::Object* object, osg::Object* data)
{
osg::StateSet* ss = dynamic_cast<osg::StateSet*>(object);
osg::NodeVisitor* nv = dynamic_cast<osg::NodeVisitor*>(data);
osg::StateSet* ss = object->asStateSet();
osg::NodeVisitor* nv = data->asNodeVisitor();
if (ss && nv)
{
operator()(ss, nv);
@@ -313,7 +313,7 @@ int StateSet::compare(const StateSet& rhs,bool compareAttributeContents) const
if (_defineList.size()<rhs._defineList.size()) return -1;
if (_defineList.size()>rhs._defineList.size()) return 1;
// check render bin details
if ( _binMode < rhs._binMode ) return -1;
@@ -512,7 +512,7 @@ int StateSet::compare(const StateSet& rhs,bool compareAttributeContents) const
}
else if (rhs_define_itr == rhs._defineList.end()) return 1;
return 0;
}