OpenSceneGraph/include/osgUtil/OptimizeStateVisitor
Don BURNS 736e0f73c3 o Added osgUtil::StateOptimizeVisitor which traversing the scene
graph and builds up a map of all StateAttributes and StateSets
    and then removes the duplicates. This promotes state sharing
    throughout the scene graph which inturn can significantly improve
    performance thanks to reduced state changing. Particularily
    effective on datasets where a great deal of duplicated state
exists.
  o Added pure virtual compare(const osg::StateAttribute&)
    method to osg::StateAttribute, and implemented it in all the
    subclasses from StateAttribute. Added <,== & != operator
    on StateAttribute and Matrix to support new StateOptimizeVisitor.
  o Added META_Object, META_Node and META_StateAttribute macros to
    Object, Node and StateAttribute respectively which define the
    standard pure virtual methods such as clone, className
    & isSameKindAs.  Changed all the appropriate header files to
    use these macro's rather define them in each header, these cleans
    up the headers considerably.
  o Corrected the implementation of osg::Light::getType so it correctly
    uses a unique type for each of the OpenGL lights (GL_LIGHT0..
    GL_LIGHT7 relates to osg::StateAttriburte::LIGHT_0..LIGHT_7.
  o Changed the definition of osg::StateStateAttribute::Type to
    is now a unsigned int rather than an enum, and have changed the
    name of the previous Type enum list to be Types.  This makes it
    more consistent with the difination of values found in
StateAttribute
    and also easier to extend with having to cast to an enum.
  o From Pail Fredrikson, updated Maitrx.new implemention which uses
    the same matrix orientation as the original Matrix implemention.
2001-09-19 23:46:48 +00:00

41 lines
874 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();
void addStateSet(osg::StateSet* stateset);
virtual void apply(osg::Node& node);
virtual void apply(osg::Geode& geode);
void optimize();
protected:
typedef std::set<osg::StateSet*> StateSetList;
StateSetList _statesets;
};
};
#endif