OpenSceneGraph/include/osgUtil/OptimizeStateVisitor
Robert Osfield fc1fa57275 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.
2001-10-01 23:02:14 +00:00

44 lines
973 B
Plaintext

#ifndef OSGUTIL_OPTIMIZESTATEVISITOR
#define OSGUTIL_OPTIMIZESTATEVISITOR
#include <osg/NodeVisitor>
#include <osgUtil/Export>
namespace osgUtil {
/** Insert impostor nodes into scene graph.
* For example of usage see src/Demos/osgimpostor.
*/
class OSGUTIL_EXPORT OptimizeStateVisitor : public osg::NodeVisitor
{
public:
/// default to traversing all children.
OptimizeStateVisitor() : osg::NodeVisitor(TRAVERSE_ALL_CHILDREN) {}
/** empty visitor, make it ready for next traversal.*/
virtual void reset();
virtual void apply(osg::Node& node);
virtual void apply(osg::Geode& geode);
void optimize();
protected:
void addStateSet(osg::StateSet* stateset,osg::Object* obj);
typedef std::set<osg::Object*> ObjectSet;
typedef std::map<osg::StateSet*,ObjectSet> StateSetMap;
StateSetMap _statesets;
};
};
#endif