From b77301350b31a0590aaf78ee8d4f0f53be0f60a1 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 19 Apr 2017 10:20:01 +0100 Subject: [PATCH] Added --kdtree command line option and associated invocation of KdTreeBuilder to enable benchmarking. Added timing stats code. --- .../osgkeyboardmouse/osgkeyboardmouse.cpp | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/examples/osgkeyboardmouse/osgkeyboardmouse.cpp b/examples/osgkeyboardmouse/osgkeyboardmouse.cpp index 39d2cee30..57d53b39a 100644 --- a/examples/osgkeyboardmouse/osgkeyboardmouse.cpp +++ b/examples/osgkeyboardmouse/osgkeyboardmouse.cpp @@ -20,6 +20,7 @@ // example that provides the user with control over view position with basic picking. #include +#include #include #include @@ -205,6 +206,7 @@ public: osg::Node* node = 0; osg::Group* parent = 0; + if (_usePolytopeIntersector) { osgUtil::PolytopeIntersector* picker; @@ -229,8 +231,12 @@ public: } osgUtil::IntersectionVisitor iv(picker); + osg::ElapsedTime elapsedTime; + viewer->getCamera()->accept(iv); + OSG_NOTICE<<"PoltyopeIntersector traversal took "<containsIntersections()) { osgUtil::PolytopeIntersector::Intersection intersection = picker->getFirstIntersection(); @@ -269,8 +275,12 @@ public: } osgUtil::IntersectionVisitor iv(picker); + osg::ElapsedTime elapsedTime; + viewer->getCamera()->accept(iv); + OSG_NOTICE<<"LineSegmentIntersector traversal took "<containsIntersections()) { osgUtil::LineSegmentIntersector::Intersection intersection = picker->getFirstIntersection(); @@ -338,10 +348,14 @@ protected: int main( int argc, char **argv ) { - osg::ref_ptr loadedModel; + osg::ArgumentParser arguments(&argc, argv); - // load the scene. - if (argc>1) loadedModel = osgDB::readRefNodeFile(argv[1]); + bool useKdTree = false; + while (arguments.read("--kdtree")) { useKdTree = true; } + + + // load model + osg::ref_ptr loadedModel = osgDB::readRefNodeFiles(arguments); // if not loaded assume no arguments passed in, try use default mode instead. if (!loadedModel) loadedModel = osgDB::readRefNodeFile("dumptruck.osgt"); @@ -352,6 +366,14 @@ int main( int argc, char **argv ) return 1; } + if (useKdTree) + { + OSG_NOTICE<<"Buildering KdTrees"< builder = new osg::KdTreeBuilder; + loadedModel->accept(*builder); + } + + // create the window to draw to. osg::ref_ptr traits = new osg::GraphicsContext::Traits; traits->x = 200;