Fixed indendation and line endings
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
@@ -32,9 +32,9 @@
|
||||
namespace osgUtil {
|
||||
|
||||
/**
|
||||
* Statistics base class. Used to extract primitive information from
|
||||
* Statistics base class. Used to extract primitive information from
|
||||
* the renderBin(s). Add a case of getStats(osgUtil::Statistics *stat)
|
||||
* for any new drawable (or drawable derived class) that you generate
|
||||
* for any new drawable (or drawable derived class) that you generate
|
||||
* (eg see Geometry.cpp). There are 20 types of drawable counted - actually only
|
||||
* 14 cases can occur in reality. these represent sets of GL_POINTS, GL_LINES
|
||||
* GL_LINESTRIPS, LOOPS, TRIANGLES, TRI-fans, tristrips, quads, quadstrips etc
|
||||
@@ -42,7 +42,7 @@ namespace osgUtil {
|
||||
* each triangle = 1 triangle (number of vertices/3)
|
||||
* each quad = 2 triangles (nverts/2)
|
||||
* each trifan or tristrip = (length-2) triangles and so on.
|
||||
*/
|
||||
*/
|
||||
|
||||
class OSGUTIL_EXPORT Statistics : public osg::PrimitiveFunctor
|
||||
{
|
||||
@@ -58,19 +58,19 @@ class OSGUTIL_EXPORT Statistics : public osg::PrimitiveFunctor
|
||||
enum StatsType
|
||||
{
|
||||
STAT_NONE, // default
|
||||
STAT_FRAMERATE,
|
||||
STAT_FRAMERATE,
|
||||
STAT_GRAPHS,
|
||||
STAT_PRIMS,
|
||||
STAT_PRIMSPERVIEW,
|
||||
STAT_PRIMS,
|
||||
STAT_PRIMSPERVIEW,
|
||||
STAT_PRIMSPERBIN,
|
||||
STAT_DC,
|
||||
STAT_RESTART // hint to restart the stats
|
||||
};
|
||||
|
||||
|
||||
void reset();
|
||||
|
||||
void setType(StatsType t) {stattype=t;}
|
||||
|
||||
void setType(StatsType t) { stattype=t; }
|
||||
|
||||
virtual void setVertexArray(unsigned int count,const osg::Vec3*) { _vertexCount += count; }
|
||||
virtual void setVertexArray(unsigned int count,const osg::Vec2*) { _vertexCount += count; }
|
||||
virtual void setVertexArray(unsigned int count,const osg::Vec4*) { _vertexCount += count; }
|
||||
@@ -85,13 +85,13 @@ class OSGUTIL_EXPORT Statistics : public osg::PrimitiveFunctor
|
||||
|
||||
virtual void begin(GLenum mode);
|
||||
|
||||
inline void vertex()
|
||||
{
|
||||
PrimitivePair& prim = _primitiveCount[_currentPrimitiveFunctorMode];
|
||||
++prim.second;
|
||||
_number_of_vertexes++;
|
||||
inline void vertex()
|
||||
{
|
||||
PrimitivePair& prim = _primitiveCount[_currentPrimitiveFunctorMode];
|
||||
++prim.second;
|
||||
_number_of_vertexes++;
|
||||
}
|
||||
|
||||
|
||||
virtual void vertex(float,float,float) { vertex(); }
|
||||
virtual void vertex(const osg::Vec3&) { vertex(); }
|
||||
virtual void vertex(const osg::Vec2&) { vertex(); }
|
||||
@@ -100,7 +100,7 @@ class OSGUTIL_EXPORT Statistics : public osg::PrimitiveFunctor
|
||||
virtual void vertex(float,float,float,float) { vertex(); }
|
||||
|
||||
virtual void end();
|
||||
|
||||
|
||||
void addDrawable() { numDrawables++;}
|
||||
void addFastDrawable() { numFastDrawables++;}
|
||||
void addMatrix() { nummat++;}
|
||||
@@ -113,14 +113,14 @@ class OSGUTIL_EXPORT Statistics : public osg::PrimitiveFunctor
|
||||
void setBinNo(int n) { _binNo=n;}
|
||||
void addStateGraphs(int n) { numStateGraphs += n; }
|
||||
void addOrderedLeaves(int n) { numOrderedLeaves += n; }
|
||||
|
||||
|
||||
void add(const Statistics& stats);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
PrimitiveCountMap& getPrimitiveCountMap() { return _primitives_count; }
|
||||
const PrimitiveCountMap& getPrimitiveCountMap() const { return _primitives_count; }
|
||||
|
||||
|
||||
PrimitiveValueMap& getPrimitiveValueMap() { return _primitiveCount; }
|
||||
const PrimitiveValueMap& getPrimitiveValueMap() const { return _primitiveCount; }
|
||||
|
||||
@@ -138,7 +138,7 @@ class OSGUTIL_EXPORT Statistics : public osg::PrimitiveFunctor
|
||||
StatsType stattype;
|
||||
int nimpostor; // number of impostors rendered
|
||||
int numOrderedLeaves; // leaves from RenderBin fine grain ordering
|
||||
|
||||
|
||||
unsigned int _vertexCount;
|
||||
PrimitiveValueMap _primitiveCount;
|
||||
GLenum _currentPrimitiveFunctorMode;
|
||||
@@ -156,16 +156,16 @@ inline unsigned int Statistics::_calculate_primitives_number_by_mode(GLenum mode
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case GL_POINTS:
|
||||
case GL_POINTS:
|
||||
case GL_LINE_LOOP:
|
||||
case GL_POLYGON: return count;
|
||||
case GL_LINES: return count / 2;
|
||||
case GL_LINE_STRIP: return count - 1;
|
||||
case GL_TRIANGLES: return count / 3;
|
||||
case GL_POLYGON: return count;
|
||||
case GL_LINES: return count / 2;
|
||||
case GL_LINE_STRIP: return count - 1;
|
||||
case GL_TRIANGLES: return count / 3;
|
||||
case GL_TRIANGLE_STRIP:
|
||||
case GL_TRIANGLE_FAN: return count - 2;
|
||||
case GL_QUADS: return count / 4;
|
||||
case GL_QUAD_STRIP: return count / 2 - 1;
|
||||
case GL_TRIANGLE_FAN: return count - 2;
|
||||
case GL_QUADS: return count / 4;
|
||||
case GL_QUAD_STRIP: return count / 2 - 1;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
@@ -180,29 +180,23 @@ public:
|
||||
typedef std::set<osg::StateSet*> StateSetSet;
|
||||
|
||||
StatsVisitor();
|
||||
|
||||
|
||||
META_NodeVisitor("osgUtil","StatsVisitor")
|
||||
|
||||
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);
|
||||
|
||||
void totalUpStats();
|
||||
|
||||
|
||||
void print(std::ostream& out);
|
||||
|
||||
|
||||
unsigned int _numInstancedGroup;
|
||||
unsigned int _numInstancedSwitch;
|
||||
unsigned int _numInstancedLOD;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
@@ -48,7 +48,7 @@ void Statistics::reset()
|
||||
numOrderedLeaves=0;
|
||||
|
||||
_vertexCount=0;
|
||||
_primitiveCount.clear();
|
||||
_primitiveCount.clear();
|
||||
|
||||
_currentPrimitiveFunctorMode=0;
|
||||
|
||||
@@ -57,53 +57,53 @@ void Statistics::reset()
|
||||
_number_of_vertexes=0;
|
||||
}
|
||||
|
||||
void Statistics::drawArrays(GLenum mode,GLint,GLsizei count)
|
||||
{
|
||||
PrimitivePair& prim = _primitiveCount[mode];
|
||||
++prim.first;
|
||||
prim.second+=count;
|
||||
void Statistics::drawArrays(GLenum mode,GLint,GLsizei count)
|
||||
{
|
||||
PrimitivePair& prim = _primitiveCount[mode];
|
||||
++prim.first;
|
||||
prim.second+=count;
|
||||
_primitives_count[mode] += _calculate_primitives_number_by_mode(mode, count);
|
||||
}
|
||||
}
|
||||
|
||||
void Statistics::drawElements(GLenum mode,GLsizei count,const GLubyte*)
|
||||
{
|
||||
PrimitivePair& prim = _primitiveCount[mode];
|
||||
++prim.first;
|
||||
prim.second+=count;
|
||||
void Statistics::drawElements(GLenum mode,GLsizei count,const GLubyte*)
|
||||
{
|
||||
PrimitivePair& prim = _primitiveCount[mode];
|
||||
++prim.first;
|
||||
prim.second+=count;
|
||||
_primitives_count[mode] += _calculate_primitives_number_by_mode(mode, count);
|
||||
}
|
||||
}
|
||||
|
||||
void Statistics::drawElements(GLenum mode,GLsizei count,const GLushort*)
|
||||
{
|
||||
PrimitivePair& prim = _primitiveCount[mode];
|
||||
++prim.first;
|
||||
prim.second+=count;
|
||||
{
|
||||
PrimitivePair& prim = _primitiveCount[mode];
|
||||
++prim.first;
|
||||
prim.second+=count;
|
||||
_primitives_count[mode] += _calculate_primitives_number_by_mode(mode, count);
|
||||
}
|
||||
}
|
||||
|
||||
void Statistics::drawElements(GLenum mode,GLsizei count,const GLuint*)
|
||||
{
|
||||
PrimitivePair& prim = _primitiveCount[mode];
|
||||
++prim.first;
|
||||
prim.second+=count;
|
||||
{
|
||||
PrimitivePair& prim = _primitiveCount[mode];
|
||||
++prim.first;
|
||||
prim.second+=count;
|
||||
_primitives_count[mode] += _calculate_primitives_number_by_mode(mode, count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Statistics::begin(GLenum mode)
|
||||
{
|
||||
_currentPrimitiveFunctorMode=mode;
|
||||
PrimitivePair& prim = _primitiveCount[mode];
|
||||
++prim.first;
|
||||
void Statistics::begin(GLenum mode)
|
||||
{
|
||||
_currentPrimitiveFunctorMode=mode;
|
||||
PrimitivePair& prim = _primitiveCount[mode];
|
||||
++prim.first;
|
||||
_number_of_vertexes = 0;
|
||||
}
|
||||
|
||||
void Statistics::end()
|
||||
void Statistics::end()
|
||||
{
|
||||
_primitives_count[_currentPrimitiveFunctorMode] +=
|
||||
_calculate_primitives_number_by_mode(_currentPrimitiveFunctorMode, _number_of_vertexes);
|
||||
_primitives_count[_currentPrimitiveFunctorMode] +=
|
||||
_calculate_primitives_number_by_mode(_currentPrimitiveFunctorMode, _number_of_vertexes);
|
||||
|
||||
_vertexCount += _number_of_vertexes;
|
||||
_vertexCount += _number_of_vertexes;
|
||||
}
|
||||
|
||||
void Statistics::add(const Statistics& stats)
|
||||
@@ -119,7 +119,7 @@ void Statistics::add(const Statistics& stats)
|
||||
numOrderedLeaves += stats.numOrderedLeaves;
|
||||
|
||||
_vertexCount += stats._vertexCount;
|
||||
// _primitiveCount += stats._primitiveCount;
|
||||
// _primitiveCount += stats._primitiveCount;
|
||||
for(PrimitiveValueMap::const_iterator pitr = stats._primitiveCount.begin();
|
||||
pitr != stats._primitiveCount.end();
|
||||
++pitr)
|
||||
@@ -178,11 +178,11 @@ void StatsVisitor::reset()
|
||||
|
||||
_uniqueStats.reset();
|
||||
_instancedStats.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void StatsVisitor::apply(osg::Node& node)
|
||||
{
|
||||
if (node.getStateSet())
|
||||
if (node.getStateSet())
|
||||
{
|
||||
++_numInstancedStateSet;
|
||||
_statesetSet.insert(node.getStateSet());
|
||||
@@ -192,7 +192,7 @@ void StatsVisitor::apply(osg::Node& node)
|
||||
|
||||
void StatsVisitor::apply(osg::Group& node)
|
||||
{
|
||||
if (node.getStateSet())
|
||||
if (node.getStateSet())
|
||||
{
|
||||
++_numInstancedStateSet;
|
||||
_statesetSet.insert(node.getStateSet());
|
||||
@@ -205,7 +205,7 @@ void StatsVisitor::apply(osg::Group& node)
|
||||
|
||||
void StatsVisitor::apply(osg::Transform& node)
|
||||
{
|
||||
if (node.getStateSet())
|
||||
if (node.getStateSet())
|
||||
{
|
||||
++_numInstancedStateSet;
|
||||
_statesetSet.insert(node.getStateSet());
|
||||
@@ -218,7 +218,7 @@ void StatsVisitor::apply(osg::Transform& node)
|
||||
|
||||
void StatsVisitor::apply(osg::LOD& node)
|
||||
{
|
||||
if (node.getStateSet())
|
||||
if (node.getStateSet())
|
||||
{
|
||||
++_numInstancedStateSet;
|
||||
_statesetSet.insert(node.getStateSet());
|
||||
@@ -231,7 +231,7 @@ void StatsVisitor::apply(osg::LOD& node)
|
||||
|
||||
void StatsVisitor::apply(osg::Switch& node)
|
||||
{
|
||||
if (node.getStateSet())
|
||||
if (node.getStateSet())
|
||||
{
|
||||
++_numInstancedStateSet;
|
||||
_statesetSet.insert(node.getStateSet());
|
||||
@@ -244,7 +244,7 @@ void StatsVisitor::apply(osg::Switch& node)
|
||||
|
||||
void StatsVisitor::apply(osg::Geode& node)
|
||||
{
|
||||
if (node.getStateSet())
|
||||
if (node.getStateSet())
|
||||
{
|
||||
++_numInstancedStateSet;
|
||||
_statesetSet.insert(node.getStateSet());
|
||||
@@ -263,7 +263,7 @@ void StatsVisitor::apply(osg::Geode& node)
|
||||
|
||||
void StatsVisitor::apply(osg::Drawable& drawable)
|
||||
{
|
||||
if (drawable.getStateSet())
|
||||
if (drawable.getStateSet())
|
||||
{
|
||||
++_numInstancedStateSet;
|
||||
_statesetSet.insert(drawable.getStateSet());
|
||||
@@ -274,7 +274,7 @@ void StatsVisitor::apply(osg::Drawable& drawable)
|
||||
drawable.accept(_instancedStats);
|
||||
|
||||
_drawableSet.insert(&drawable);
|
||||
|
||||
|
||||
osg::Geometry* geometry = drawable.asGeometry();
|
||||
if (geometry)
|
||||
{
|
||||
@@ -303,7 +303,6 @@ void StatsVisitor::totalUpStats()
|
||||
|
||||
void StatsVisitor::print(std::ostream& out)
|
||||
{
|
||||
|
||||
unsigned int unique_primitives = 0;
|
||||
osgUtil::Statistics::PrimitiveCountMap::iterator pcmitr;
|
||||
for(pcmitr = _uniqueStats.GetPrimitivesBegin();
|
||||
@@ -336,4 +335,4 @@ void StatsVisitor::print(std::ostream& out)
|
||||
out << std::setw(12) << "Vertices " << std::setw(10) << _uniqueStats._vertexCount << std::setw(10) << _instancedStats._vertexCount << std::endl;
|
||||
out << std::setw(12) << "Primitives " << std::setw(10) << unique_primitives << std::setw(10) << instanced_primitives << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user