Rewrote osg:Statistics so that it is PrimitiveFunctor as is now completely
decoupled from osg::Drawable. The Drawable::getStats() virtual method no longer exists. Updated the Viewer to use the osg::Statistics incarnation and reformated stats to clean it up.
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
|
||||
#include <osg/GeoSet>
|
||||
#include <osg/Notify>
|
||||
#include <osg/Statistics>
|
||||
|
||||
#include <osg/Geometry>
|
||||
#include <osg/ShadeModel>
|
||||
@@ -887,98 +886,6 @@ Drawable::AttributeBitMask GeoSet::applyAttributeOperation(AttributeFunctor& auf
|
||||
return ramb;
|
||||
}
|
||||
|
||||
bool GeoSet::getStats(Statistics &stat)
|
||||
{ // analyse the drawable GeoSet
|
||||
const int np=getNumPrims(); // number of primitives in this geoset
|
||||
stat.addNumPrims(np);
|
||||
const int type=getPrimType();
|
||||
int nprimlens=0, numprimtypes=0, primverts=0;
|
||||
switch (type) {
|
||||
case osg::GeoSet::POINTS:
|
||||
case osg::GeoSet::LINES:
|
||||
case osg::GeoSet::LINE_STRIP:
|
||||
case osg::GeoSet::FLAT_LINE_STRIP:
|
||||
case osg::GeoSet::LINE_LOOP:
|
||||
case osg::GeoSet::TRIANGLE_STRIP:
|
||||
case osg::GeoSet::FLAT_TRIANGLE_STRIP:
|
||||
case osg::GeoSet::TRIANGLE_FAN:
|
||||
case osg::GeoSet::FLAT_TRIANGLE_FAN:
|
||||
case osg::GeoSet::QUAD_STRIP:
|
||||
case osg::GeoSet::POLYGON:
|
||||
break;
|
||||
case osg::GeoSet::TRIANGLES: // should not have any lengths for tris & quads
|
||||
nprimlens=np;
|
||||
numprimtypes=np;
|
||||
primverts=3*np;
|
||||
break;
|
||||
case osg::GeoSet::QUADS:
|
||||
nprimlens=np*2;
|
||||
primverts=4*np;
|
||||
numprimtypes=np;
|
||||
break;
|
||||
case osg::GeoSet::NO_TYPE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// now count the lengths, ie efficiency of triangulation
|
||||
const int *lens=getPrimLengths(); // primitive lengths
|
||||
if (lens) { // then count for each length
|
||||
for (int i=0; i<np; i++) {
|
||||
switch (type) {
|
||||
case osg::GeoSet::POINTS:
|
||||
case osg::GeoSet::LINES:
|
||||
case osg::GeoSet::LINE_STRIP:
|
||||
case osg::GeoSet::FLAT_LINE_STRIP:
|
||||
case osg::GeoSet::LINE_LOOP:
|
||||
case osg::GeoSet::TRIANGLES: // should not have any lengths for tris & quads
|
||||
case osg::GeoSet::QUADS:
|
||||
case osg::GeoSet::QUAD_STRIP:
|
||||
nprimlens+=lens[i];
|
||||
break;
|
||||
case osg::GeoSet::POLYGON: // moved Nov 2001 to count triangles cf lengths
|
||||
case osg::GeoSet::TRIANGLE_STRIP:
|
||||
case osg::GeoSet::FLAT_TRIANGLE_STRIP:
|
||||
case osg::GeoSet::TRIANGLE_FAN:
|
||||
case osg::GeoSet::FLAT_TRIANGLE_FAN:
|
||||
nprimlens+=lens[i]-2; // tri strips & fans create lens[i]-2 triangles
|
||||
break;
|
||||
case osg::GeoSet::NO_TYPE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (type) {
|
||||
case osg::GeoSet::POINTS:
|
||||
case osg::GeoSet::LINES:
|
||||
case osg::GeoSet::LINE_STRIP:
|
||||
case osg::GeoSet::FLAT_LINE_STRIP:
|
||||
case osg::GeoSet::LINE_LOOP:
|
||||
case osg::GeoSet::TRIANGLES:
|
||||
case osg::GeoSet::QUADS:
|
||||
case osg::GeoSet::TRIANGLE_STRIP:
|
||||
case osg::GeoSet::FLAT_TRIANGLE_STRIP:
|
||||
case osg::GeoSet::TRIANGLE_FAN:
|
||||
case osg::GeoSet::FLAT_TRIANGLE_FAN:
|
||||
case osg::GeoSet::QUAD_STRIP:
|
||||
case osg::GeoSet::POLYGON:
|
||||
numprimtypes++;
|
||||
primverts+=lens[i];
|
||||
break;
|
||||
case osg::GeoSet::NO_TYPE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else { // no lengths - num prims is the length of a point set
|
||||
switch (type) {
|
||||
case osg::GeoSet::POINTS:
|
||||
numprimtypes++;
|
||||
primverts+=np;
|
||||
break;
|
||||
}
|
||||
}
|
||||
stat.addNumPrims(type, nprimlens, numprimtypes, primverts);
|
||||
return true;
|
||||
}
|
||||
|
||||
void GeoSet::applyPrimitiveOperation(PrimitiveFunctor& functor)
|
||||
{
|
||||
|
||||
@@ -192,13 +192,6 @@ void Geometry::drawImmediateMode(State& state)
|
||||
|
||||
}
|
||||
|
||||
/** Statistics collection for each drawable- 26.09.01
|
||||
*/
|
||||
bool Geometry::getStats(Statistics &)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Drawable::AttributeBitMask Geometry::suppportsAttributeOperation() const
|
||||
{
|
||||
// we do support coords,normals,texcoords and colors so return true.
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/AlphaFunc>
|
||||
#include <osg/Notify>
|
||||
#include <osg/Statistics>
|
||||
|
||||
|
||||
using namespace osg;
|
||||
@@ -268,12 +267,3 @@ ImpostorSprite* ImpostorSpriteManager::createOrReuseImpostorSprite(int s,int t,i
|
||||
return is;
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool ImpostorSprite::getStats(Statistics &stat)
|
||||
{ // analyse the drawable Impostor Sprite
|
||||
stat.addNumPrims(1); // use new member functions of Statistics class to update
|
||||
stat.addNumPrims(Statistics::QUADS, 2, 1, 4);
|
||||
stat.addImpostor(1);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
#include <osg/Math>
|
||||
#include <osg/Statistics>
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -535,7 +537,7 @@ void Viewer::showStats(const unsigned int /*viewport*/)
|
||||
glEnd();
|
||||
glLineWidth(1.0f);
|
||||
}
|
||||
if (_printStats==Statistics::STAT_PRIMS) { // yet more stats - add triangles, number of strips...
|
||||
if (_printStats==osg::Statistics::STAT_PRIMS) { // yet more stats - add triangles, number of strips...
|
||||
/*
|
||||
* Use the new renderStage. Required mods to RenderBin.cpp, and RenderStage.cpp (add getPrims)
|
||||
* also needed to define a new class called Statistic (see osgUtil/Statistic).
|
||||
@@ -1503,128 +1505,84 @@ void displaytext(int x, int y, char *s)
|
||||
glListBase(0);
|
||||
// glPopAttrib ();
|
||||
}
|
||||
/*
|
||||
void writePrims( const int ypos, osg::Statistics& stats)
|
||||
{
|
||||
char clin[100]; // buffer to print
|
||||
char ctmp[12];
|
||||
int i; // a counter
|
||||
static char *prtypes[]={"Total",
|
||||
" Pt", " Ln", " Lstr", " LSTf", " Llop", // 1- 5
|
||||
" Tris", " TStr", " TSfl", " TFan", " TFnf", // 6-10
|
||||
" Quad", " QStr", " Pols", "", "", // 11-15
|
||||
"", "", "", "", ""};
|
||||
glColor3f(.9f,.9f,0.0f);
|
||||
|
||||
sprintf(clin,"%d Prims %d Matxs %d Gsets %d nlts %d bins %d imps",
|
||||
stats.nprims, stats.nummat, stats.numOpaque, stats.nlights, stats.nbins, stats.nimpostor);
|
||||
displaytext(0,ypos,clin);
|
||||
strcpy(clin," ");
|
||||
for (i=0; i<15; i++) {
|
||||
if (i==0 || stats.primtypes[i]) {
|
||||
strcat(clin, prtypes[i]);
|
||||
}
|
||||
}
|
||||
displaytext(0,ypos-12,clin);
|
||||
strcpy(clin,"GSet type: ");
|
||||
for (i=0; i<15; i++) {
|
||||
if (stats.primtypes[i]) {
|
||||
sprintf(ctmp,"%5d", stats.primtypes[i]);
|
||||
strcat(clin, ctmp);
|
||||
}
|
||||
}
|
||||
displaytext(0,ypos-24,clin);
|
||||
strcpy(clin,"Prims: ");
|
||||
for (i=0; i<15; i++) {
|
||||
if (stats.primtypes[i]) {
|
||||
sprintf(ctmp,"%5d", stats.numprimtypes[i]);
|
||||
strcat(clin, ctmp);
|
||||
}
|
||||
}
|
||||
displaytext(0,ypos-36,clin);
|
||||
strcpy(clin,"Triangles: ");
|
||||
for (i=0; i<15; i++) {
|
||||
if (stats.primtypes[i]) {
|
||||
sprintf(ctmp,"%5d", stats.primlens[i]);
|
||||
strcat(clin, ctmp);
|
||||
}
|
||||
}
|
||||
displaytext(0,ypos-48,clin);
|
||||
strcpy(clin,"Vertices: ");
|
||||
for (i=0; i<15; i++) {
|
||||
if (stats.primtypes[i]) {
|
||||
sprintf(ctmp,"%5d", stats.primverts[i]);
|
||||
strcat(clin, ctmp);
|
||||
}
|
||||
}
|
||||
displaytext(0,ypos-60,clin);
|
||||
}
|
||||
*/
|
||||
|
||||
int writePrims( const int ypos, osg::Statistics& stats)
|
||||
{
|
||||
char clin[100]; // buffer to print
|
||||
char ctmp[12];
|
||||
int i; // a counter
|
||||
int npix=0; // offset from ypos
|
||||
char intro[12]; // start of first line
|
||||
static char *prtypes[]={"Total",
|
||||
" Pt", " Ln", " Lstr", " LSTf", " Llop", // 1- 5
|
||||
" Tris", " TStr", " TSfl", " TFan", " TFnf", // 6-10
|
||||
" Quad", " QStr", " Pols", "", "", // 11-15
|
||||
"", "", "", "", ""};
|
||||
static char *prtypes[]=
|
||||
{
|
||||
" Point", // GL_POINTS 0x0000
|
||||
" Lines", // GL_LINES 0x0001
|
||||
" LnLoop", // GL_LINE_LOOP 0x0002
|
||||
" LnStr", // GL_LINE_SRIP 0x0002
|
||||
" Tris", // GL_TRIANGLES 0x0004
|
||||
" TriStr", // GL_TRIANGLE_STRIP 0x0005
|
||||
" TriFan", // GL_TRIANGLE_FAN 0x0006
|
||||
" Quads", // GL_QUADS 0x0007
|
||||
" QudStr", // GL_QUAD_STRIP 0x0008
|
||||
" Poly" // GL_POLYGON 0x0009
|
||||
};
|
||||
|
||||
glColor3f(.9f,.9f,0.0f);
|
||||
|
||||
if (stats.depth==1) sprintf(intro,"==> Bin %2d", stats._binNo);
|
||||
else sprintf(intro," ");
|
||||
sprintf(clin,"%s %d Prims %d Matxs %d Gsets %d nlts %d bins %d imps",
|
||||
intro ,stats.nprims, stats.nummat, stats.numOpaque, stats.nlights, stats.nbins, stats.nimpostor);
|
||||
else sprintf(intro,"General Stats: ");
|
||||
sprintf(clin,"%s %d Opaque Drawables %d Lights %d Bins %d Impostors",
|
||||
intro ,stats.numOpaque, stats.nlights, stats.nbins, stats.nimpostor);
|
||||
displaytext(0,ypos-npix,clin);
|
||||
npix+=12;
|
||||
strcpy(clin," ");
|
||||
for (i=0; i<=osg::Statistics::POLYGON; i++) {
|
||||
if (i==0 || stats.primtypes[i]) {
|
||||
strcat(clin, prtypes[i]);
|
||||
}
|
||||
npix+=24;
|
||||
|
||||
strcpy(clin," Total");
|
||||
|
||||
unsigned int totalNumPrimives = 0;
|
||||
unsigned int totalNumIndices = 0;
|
||||
osg::Statistics::PrimtiveValueMap::iterator pItr;
|
||||
for(pItr=stats._primitiveCount.begin();
|
||||
pItr!=stats._primitiveCount.end();
|
||||
++pItr)
|
||||
{
|
||||
totalNumPrimives += (pItr->second.first);
|
||||
totalNumIndices += (pItr->second.second);
|
||||
strcat(clin, prtypes[pItr->first]);
|
||||
}
|
||||
displaytext(0,ypos-npix,clin);
|
||||
npix+=12;
|
||||
strcpy(clin,"GSet type: ");
|
||||
for (i=0; i<=osg::Statistics::POLYGON; i++) {
|
||||
if (stats.primtypes[i]) {
|
||||
sprintf(ctmp,"%5d", stats.primtypes[i]);
|
||||
strcat(clin, ctmp);
|
||||
}
|
||||
|
||||
strcpy(clin,"Primitives: ");
|
||||
sprintf(ctmp,"%7d", totalNumPrimives);
|
||||
strcat(clin, ctmp);
|
||||
for(pItr=stats._primitiveCount.begin();
|
||||
pItr!=stats._primitiveCount.end();
|
||||
++pItr)
|
||||
{
|
||||
sprintf(ctmp,"%7d", pItr->second.first);
|
||||
strcat(clin, ctmp);
|
||||
}
|
||||
displaytext(0,ypos-npix,clin);
|
||||
npix+=12;
|
||||
strcpy(clin,"Prims: ");
|
||||
for (i=0; i<=osg::Statistics::POLYGON; i++) {
|
||||
if (stats.primtypes[i]) {
|
||||
sprintf(ctmp,"%5d", stats.numprimtypes[i]);
|
||||
strcat(clin, ctmp);
|
||||
}
|
||||
|
||||
strcpy(clin,"Indices: ");
|
||||
sprintf(ctmp,"%7d", totalNumIndices);
|
||||
strcat(clin, ctmp);
|
||||
for(pItr=stats._primitiveCount.begin();
|
||||
pItr!=stats._primitiveCount.end();
|
||||
++pItr)
|
||||
{
|
||||
sprintf(ctmp,"%7d", pItr->second.second);
|
||||
strcat(clin, ctmp);
|
||||
}
|
||||
displaytext(0,ypos-npix,clin);
|
||||
npix+=12;
|
||||
strcpy(clin,"Triangles: ");
|
||||
for (i=0; i<=osg::Statistics::POLYGON; i++) {
|
||||
if (stats.primtypes[i]) {
|
||||
sprintf(ctmp,"%5d", stats.primlens[i]);
|
||||
strcat(clin, ctmp);
|
||||
}
|
||||
}
|
||||
|
||||
strcpy(clin,"Vertices: ");
|
||||
sprintf(ctmp,"%7d", stats._vertexCount);
|
||||
strcat(clin, ctmp);
|
||||
displaytext(0,ypos-npix,clin);
|
||||
npix+=12;
|
||||
strcpy(clin,"Vertices: ");
|
||||
for (i=0; i<=osg::Statistics::POLYGON; i++) {
|
||||
if (stats.primverts[i]) {
|
||||
sprintf(ctmp,"%5d", stats.primverts[i]);
|
||||
strcat(clin, ctmp);
|
||||
}
|
||||
}
|
||||
displaytext(0,ypos-npix,clin);
|
||||
npix+=12;
|
||||
if (stats.stattype!=osg::Statistics::STAT_PRIMSPERBIN) {
|
||||
}
|
||||
|
||||
return npix;
|
||||
}
|
||||
|
||||
@@ -493,7 +493,7 @@ void IntersectVisitor::apply(Geode& geode)
|
||||
{
|
||||
if (!enterNode(geode)) return;
|
||||
|
||||
for(int i = 0; i < geode.getNumDrawables(); i++ )
|
||||
for(unsigned int i = 0; i < geode.getNumDrawables(); i++ )
|
||||
{
|
||||
intersect(*geode.getDrawable(i));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <osgUtil/RenderBin>
|
||||
#include <osgUtil/RenderStage>
|
||||
|
||||
#include <osg/Statistics>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace osg;
|
||||
@@ -186,13 +188,10 @@ bool RenderBin::getStats(osg::Statistics* primStats)
|
||||
Drawable* dw= rl->_drawable;
|
||||
primStats->addOpaque(); // number of geosets
|
||||
if (rl->_modelview.get()) primStats->addMatrix(); // number of matrices
|
||||
if (dw) { // then tot up the types 1-14
|
||||
// commenting out as having intrusive stats in base classes is
|
||||
// undersirable.
|
||||
dw->getStats(*primStats); // use sub-class to find the stats for each drawable
|
||||
|
||||
// use an AttributeOption to get the stats we require.
|
||||
dw->applyAttributeOperation(*primStats);
|
||||
if (dw)
|
||||
{
|
||||
// then tot up the primtive types and no vertices.
|
||||
dw->applyPrimitiveOperation(*primStats); // use sub-class to find the stats for each drawable
|
||||
}
|
||||
}
|
||||
somestats=true;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <osg/Notify>
|
||||
#include <osg/Statistics>
|
||||
|
||||
#include <osgUtil/RenderStage>
|
||||
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgUtil;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user