From 423105c2996c4b5b988bfe4503d15507fa44ecf8 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 14 Jul 2015 08:25:17 +0000 Subject: [PATCH] Added _defineList into the osg::StateSet::compare() implementation to address issues with osgUtil::Optimizer ignoring defines. git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14948 16af8721-9629-0410-8352-f15c8da7e697 --- src/osg/StateSet.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/osg/StateSet.cpp b/src/osg/StateSet.cpp index 7853945ec..181259298 100644 --- a/src/osg/StateSet.cpp +++ b/src/osg/StateSet.cpp @@ -310,7 +310,11 @@ int StateSet::compare(const StateSet& rhs,bool compareAttributeContents) const if (_uniformList.size()rhs._uniformList.size()) return 1; - // check render bin details + if (_defineList.size()rhs._defineList.size()) return 1; + + + // check render bin details if ( _binMode < rhs._binMode ) return -1; else if ( _binMode > rhs._binMode ) return 1; @@ -487,6 +491,28 @@ int StateSet::compare(const StateSet& rhs,bool compareAttributeContents) const } else if (rhs_uniform_itr == rhs._uniformList.end()) return 1; + + // check defines. + DefineList::const_iterator lhs_define_itr = _defineList.begin(); + DefineList::const_iterator rhs_define_itr = rhs._defineList.begin(); + while (lhs_define_itr!=_defineList.end() && rhs_define_itr!=rhs._defineList.end()) + { + if (lhs_define_itr->firstfirst) return -1; + else if (rhs_define_itr->firstfirst) return 1; + if (lhs_define_itr->second.firstsecond.first) return -1; + else if (rhs_define_itr->second.firstsecond.first) return 1; + if (lhs_define_itr->second.secondsecond.second) return -1; + else if (rhs_define_itr->second.secondsecond.second) return 1; + ++lhs_define_itr; + ++rhs_define_itr; + } + if (lhs_define_itr==_defineList.end()) + { + if (rhs_define_itr!=rhs._defineList.end()) return -1; + } + else if (rhs_define_itr == rhs._defineList.end()) return 1; + + return 0; }