Added support for osg::StateSet comparison operators and using this new feature
added support in osgUtil::OptimizeStateVisitor for removing duplicate StateSet's from the scene graph, previously only duplicated StateAttributes we're removed.
This commit is contained in:
@@ -28,6 +28,13 @@ class SG_EXPORT StateSet : public Object
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const StateSet*>(obj)!=NULL; }
|
||||
virtual const char* className() const { return "StateSet"; }
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
int compare(const StateSet& rhs) const;
|
||||
|
||||
bool operator < (const StateSet& rhs) const { return compare(rhs)<0; }
|
||||
bool operator == (const StateSet& rhs) const { return compare(rhs)==0; }
|
||||
bool operator != (const StateSet& rhs) const { return compare(rhs)!=0; }
|
||||
|
||||
/** set all the modes to on or off so that it defines a
|
||||
complete state, typically used for a default global state.*/
|
||||
void setGlobalDefaults();
|
||||
|
||||
@@ -20,7 +20,6 @@ class OSGUTIL_EXPORT OptimizeStateVisitor : public osg::NodeVisitor
|
||||
/** empty visitor, make it ready for next traversal.*/
|
||||
virtual void reset();
|
||||
|
||||
void addStateSet(osg::StateSet* stateset);
|
||||
|
||||
virtual void apply(osg::Node& node);
|
||||
|
||||
@@ -30,8 +29,12 @@ class OSGUTIL_EXPORT OptimizeStateVisitor : public osg::NodeVisitor
|
||||
|
||||
protected:
|
||||
|
||||
typedef std::set<osg::StateSet*> StateSetList;
|
||||
StateSetList _statesets;
|
||||
void addStateSet(osg::StateSet* stateset,osg::Object* obj);
|
||||
|
||||
typedef std::set<osg::Object*> ObjectSet;
|
||||
typedef std::map<osg::StateSet*,ObjectSet> StateSetMap;
|
||||
|
||||
StateSetMap _statesets;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user