fc1fa57275
added support in osgUtil::OptimizeStateVisitor for removing duplicate StateSet's from the scene graph, previously only duplicated StateAttributes we're removed.
44 lines
973 B
Plaintext
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
|