From Jan Peciva, "attaching improved StatsVisitor. Changes:
- apply() and reset() methods made virtual to allow overriding - added apply(StateSet&) to make more easier to gather StateAttribute statistics in user-derived classes "
This commit is contained in:
@@ -89,7 +89,7 @@ class OSGUTIL_EXPORT Statistics : public osg::PrimitiveFunctor
|
||||
{
|
||||
PrimitivePair& prim = _primitiveCount[_currentPrimitiveFunctorMode];
|
||||
++prim.second;
|
||||
_number_of_vertexes++;
|
||||
_number_of_vertexes++;
|
||||
}
|
||||
|
||||
virtual void vertex(float,float,float) { vertex(); }
|
||||
@@ -183,19 +183,20 @@ public:
|
||||
|
||||
META_NodeVisitor("osgUtil","StatsVisitor")
|
||||
|
||||
void reset();
|
||||
virtual void reset();
|
||||
|
||||
void apply(osg::Node& node);
|
||||
void apply(osg::Group& node);
|
||||
void apply(osg::Transform& node);
|
||||
void apply(osg::LOD& node);
|
||||
void apply(osg::Switch& node);
|
||||
void apply(osg::Geode& node);
|
||||
void apply(osg::Drawable& drawable);
|
||||
virtual void apply(osg::Node& node);
|
||||
virtual void apply(osg::Group& node);
|
||||
virtual void apply(osg::Transform& node);
|
||||
virtual void apply(osg::LOD& node);
|
||||
virtual void apply(osg::Switch& node);
|
||||
virtual void apply(osg::Geode& node);
|
||||
virtual void apply(osg::Drawable& drawable);
|
||||
virtual void apply(osg::StateSet& ss);
|
||||
|
||||
void totalUpStats();
|
||||
virtual void totalUpStats();
|
||||
|
||||
void print(std::ostream& out);
|
||||
virtual void print(std::ostream& out);
|
||||
|
||||
unsigned int _numInstancedGroup;
|
||||
unsigned int _numInstancedSwitch;
|
||||
|
||||
@@ -119,7 +119,6 @@ void Statistics::add(const Statistics& stats)
|
||||
numOrderedLeaves += stats.numOrderedLeaves;
|
||||
|
||||
_vertexCount += stats._vertexCount;
|
||||
// _primitiveCount += stats._primitiveCount;
|
||||
for(PrimitiveValueMap::const_iterator pitr = stats._primitiveCount.begin();
|
||||
pitr != stats._primitiveCount.end();
|
||||
++pitr)
|
||||
@@ -184,9 +183,9 @@ void StatsVisitor::apply(osg::Node& node)
|
||||
{
|
||||
if (node.getStateSet())
|
||||
{
|
||||
++_numInstancedStateSet;
|
||||
_statesetSet.insert(node.getStateSet());
|
||||
apply(*node.getStateSet());
|
||||
}
|
||||
|
||||
traverse(node);
|
||||
}
|
||||
|
||||
@@ -194,12 +193,12 @@ void StatsVisitor::apply(osg::Group& node)
|
||||
{
|
||||
if (node.getStateSet())
|
||||
{
|
||||
++_numInstancedStateSet;
|
||||
_statesetSet.insert(node.getStateSet());
|
||||
apply(*node.getStateSet());
|
||||
}
|
||||
|
||||
++_numInstancedGroup;
|
||||
_groupSet.insert(&node);
|
||||
|
||||
traverse(node);
|
||||
}
|
||||
|
||||
@@ -207,12 +206,12 @@ void StatsVisitor::apply(osg::Transform& node)
|
||||
{
|
||||
if (node.getStateSet())
|
||||
{
|
||||
++_numInstancedStateSet;
|
||||
_statesetSet.insert(node.getStateSet());
|
||||
apply(*node.getStateSet());
|
||||
}
|
||||
|
||||
++_numInstancedTransform;
|
||||
_transformSet.insert(&node);
|
||||
|
||||
traverse(node);
|
||||
}
|
||||
|
||||
@@ -220,12 +219,12 @@ void StatsVisitor::apply(osg::LOD& node)
|
||||
{
|
||||
if (node.getStateSet())
|
||||
{
|
||||
++_numInstancedStateSet;
|
||||
_statesetSet.insert(node.getStateSet());
|
||||
apply(*node.getStateSet());
|
||||
}
|
||||
|
||||
++_numInstancedLOD;
|
||||
_lodSet.insert(&node);
|
||||
|
||||
traverse(node);
|
||||
}
|
||||
|
||||
@@ -233,12 +232,12 @@ void StatsVisitor::apply(osg::Switch& node)
|
||||
{
|
||||
if (node.getStateSet())
|
||||
{
|
||||
++_numInstancedStateSet;
|
||||
_statesetSet.insert(node.getStateSet());
|
||||
apply(*node.getStateSet());
|
||||
}
|
||||
|
||||
++_numInstancedSwitch;
|
||||
_switchSet.insert(&node);
|
||||
|
||||
traverse(node);
|
||||
}
|
||||
|
||||
@@ -246,8 +245,7 @@ void StatsVisitor::apply(osg::Geode& node)
|
||||
{
|
||||
if (node.getStateSet())
|
||||
{
|
||||
++_numInstancedStateSet;
|
||||
_statesetSet.insert(node.getStateSet());
|
||||
apply(*node.getStateSet());
|
||||
}
|
||||
|
||||
++_numInstancedGeode;
|
||||
@@ -265,8 +263,7 @@ void StatsVisitor::apply(osg::Drawable& drawable)
|
||||
{
|
||||
if (drawable.getStateSet())
|
||||
{
|
||||
++_numInstancedStateSet;
|
||||
_statesetSet.insert(drawable.getStateSet());
|
||||
apply(*drawable.getStateSet());
|
||||
}
|
||||
|
||||
++_numInstancedDrawable;
|
||||
@@ -289,6 +286,12 @@ void StatsVisitor::apply(osg::Drawable& drawable)
|
||||
}
|
||||
}
|
||||
|
||||
void StatsVisitor::apply(osg::StateSet& stateSet)
|
||||
{
|
||||
++_numInstancedStateSet;
|
||||
_statesetSet.insert(&stateSet);
|
||||
}
|
||||
|
||||
void StatsVisitor::totalUpStats()
|
||||
{
|
||||
_uniqueStats.reset();
|
||||
|
||||
Reference in New Issue
Block a user