Added Stats::collectStats(string,bool) controls, getAveragedAttribute methods into osg::Stats class, and

related support into osgViewer::Viewer and osgViewer::StatsHandler.

Added lazy updating of text in StatsHandler HUD to minimize the impact of
slow text updating on observed frame rates.
This commit is contained in:
Robert Osfield
2007-01-30 11:40:23 +00:00
parent 7b9b13b6c0
commit ecedc8d86a
14 changed files with 253 additions and 26 deletions

View File

@@ -80,6 +80,37 @@ bool Stats::getAttribute(int frameNumber, const std::string& attributeName, doub
return true;
}
bool Stats::getAveragedAttribute(const std::string& attributeName, double& value) const
{
return getAveragedAttribute(getEarliestFrameNumber(), getLatestFrameNumber(), attributeName, value);
}
bool Stats::getAveragedAttribute(int startFrameNumber, int endFrameNumber, const std::string& attributeName, double& value) const
{
if (endFrameNumber<startFrameNumber)
{
std::swap(endFrameNumber, startFrameNumber);
}
double total = 0.0;
double numValidSamples = 0.0;
for(int i = startFrameNumber; i<=endFrameNumber; ++i)
{
double v = 0.0;
if (getAttribute(i,attributeName,v))
{
total += v;
numValidSamples += 1.0;
}
}
if (numValidSamples>0.0)
{
value = total/numValidSamples;
return true;
}
else return false;
}
Stats::AttributeMap& Stats::getAttributeMap(int frameNumber)
{
int index = getIndex(frameNumber);