本文整理汇总了C++中osgviewer::Viewer::eventTraversal方法的典型用法代码示例。如果您正苦于以下问题:C++ Viewer::eventTraversal方法的具体用法?C++ Viewer::eventTraversal怎么用?C++ Viewer::eventTraversal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osgviewer::Viewer
的用法示例。
在下文中一共展示了Viewer::eventTraversal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
int Metrics::run(osgViewer::Viewer& viewer)
{
if (Metrics::enabled())
{
if (!viewer.isRealized())
{
viewer.realize();
}
// If Metrics are enabled, enable stats on the Viewer so that it we can report them for the Metrics
if (Metrics::enabled())
{
osgViewer::ViewerBase::Scenes scenes;
viewer.getScenes(scenes);
for (osgViewer::ViewerBase::Scenes::iterator itr = scenes.begin();
itr != scenes.end();
++itr)
{
osgViewer::Scene* scene = *itr;
osgDB::DatabasePager* dp = scene->getDatabasePager();
if (dp && dp->isRunning())
{
dp->resetStats();
}
}
viewer.getViewerStats()->collectStats("frame_rate", true);
viewer.getViewerStats()->collectStats("event", true);
viewer.getViewerStats()->collectStats("update", true);
viewer.getCamera()->getStats()->collectStats("rendering", true);
viewer.getCamera()->getStats()->collectStats("gpu", true);
}
// Report memory and fps every 10 frames.
unsigned int reportEvery = 10;
while (!viewer.done())
{
{
METRIC_SCOPED_EX("frame", 1, "number", toString<int>(viewer.getFrameStamp()->getFrameNumber()).c_str());
{
METRIC_SCOPED("advance");
viewer.advance();
}
{
METRIC_SCOPED("event");
viewer.eventTraversal();
}
{
METRIC_SCOPED("update");
viewer.updateTraversal();
}
{
METRIC_SCOPED("render");
viewer.renderingTraversals();
}
}
// Report memory and fps periodically. periodically.
if (viewer.getFrameStamp()->getFrameNumber() % reportEvery == 0)
{
// Only report the metrics if they are enabled to avoid computing the memory.
if (Metrics::enabled())
{
Metrics::counter("Memory::WorkingSet", "WorkingSet", Memory::getProcessPhysicalUsage() / 1048576);
Metrics::counter("Memory::PrivateBytes", "PrivateBytes", Memory::getProcessPrivateUsage() / 1048576);
Metrics::counter("Memory::PeakPrivateBytes", "PeakPrivateBytes", Memory::getProcessPeakPrivateUsage() / 1048576);
}
}
double eventTime = 0.0;
if (viewer.getViewerStats()->getAttribute(viewer.getViewerStats()->getLatestFrameNumber(), "Event traversal time taken", eventTime))
{
Metrics::counter("Viewer::Event", "Event", eventTime * 1000.0);
}
double updateTime = 0.0;
if (viewer.getViewerStats()->getAttribute(viewer.getViewerStats()->getLatestFrameNumber(), "Update traversal time taken", updateTime))
{
Metrics::counter("Viewer::Update", "Update", updateTime * 1000.0);
}
double cullTime = 0.0;
if (viewer.getCamera()->getStats()->getAttribute(viewer.getCamera()->getStats()->getLatestFrameNumber(), "Cull traversal time taken", cullTime))
{
Metrics::counter("Viewer::Cull", "Cull", cullTime * 1000.0);
}
double drawTime = 0.0;
if (viewer.getCamera()->getStats()->getAttribute(viewer.getCamera()->getStats()->getLatestFrameNumber(), "Draw traversal time taken", drawTime))
{
Metrics::counter("Viewer::Draw", "Draw", drawTime * 1000.0);
}
double gpuTime = 0.0;
//.........这里部分代码省略.........