From d5bff107973fa4610dafe61b342193d2877e820f Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 4 Oct 2001 14:39:24 +0000 Subject: [PATCH] Changed the ordering of comparing modes and attributes in osg::StateAttribute::compare() as part of an investigration into state sorting. --- src/osg/StateSet.cpp | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/osg/StateSet.cpp b/src/osg/StateSet.cpp index 3570f1a90..d1a0785dd 100644 --- a/src/osg/StateSet.cpp +++ b/src/osg/StateSet.cpp @@ -31,26 +31,7 @@ StateSet::~StateSet() int StateSet::compare(const StateSet& rhs) const { - // check to see how the modes compare. - ModeList::const_iterator lhs_mode_itr = _modeList.begin(); - ModeList::const_iterator rhs_mode_itr = rhs._modeList.begin(); - while (lhs_mode_itr!=_modeList.end() && rhs_mode_itr!=rhs._modeList.end()) - { - if (lhs_mode_itr->firstfirst) return -1; - else if (rhs_mode_itr->firstfirst) return 1; - if (lhs_mode_itr->secondsecond) return -1; - else if (rhs_mode_itr->secondsecond) return 1; - ++lhs_mode_itr; - ++rhs_mode_itr; - } - if (lhs_mode_itr==_modeList.end()) - { - if (rhs_mode_itr!=rhs._modeList.end()) return -1; - } - else if (rhs_mode_itr == rhs._modeList.end()) return 1; - // we've got here so modes must be equal... - // now check to see how the attributes compare. AttributeList::const_iterator lhs_attr_itr = _attributeList.begin(); AttributeList::const_iterator rhs_attr_itr = rhs._attributeList.begin(); @@ -71,6 +52,27 @@ int StateSet::compare(const StateSet& rhs) const } else if (rhs_attr_itr == rhs._attributeList.end()) return 1; + // we've got here so attributes must be equal... + + // check to see how the modes compare. + + ModeList::const_iterator lhs_mode_itr = _modeList.begin(); + ModeList::const_iterator rhs_mode_itr = rhs._modeList.begin(); + while (lhs_mode_itr!=_modeList.end() && rhs_mode_itr!=rhs._modeList.end()) + { + if (lhs_mode_itr->firstfirst) return -1; + else if (rhs_mode_itr->firstfirst) return 1; + if (lhs_mode_itr->secondsecond) return -1; + else if (rhs_mode_itr->secondsecond) return 1; + ++lhs_mode_itr; + ++rhs_mode_itr; + } + if (lhs_mode_itr==_modeList.end()) + { + if (rhs_mode_itr!=rhs._modeList.end()) return -1; + } + else if (rhs_mode_itr == rhs._modeList.end()) return 1; + return 0; }