From e09dfb93f1d6c9a4bba2d80bef0163cfb76684d5 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 21 Apr 2017 11:07:17 +0100 Subject: [PATCH] Added group intersection test that covers the window with 10000 tests, activated by pressing 'a'. I have added this to provide a reproducable intersection test for benchmarking. --- .../osgkeyboardmouse/osgkeyboardmouse.cpp | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/examples/osgkeyboardmouse/osgkeyboardmouse.cpp b/examples/osgkeyboardmouse/osgkeyboardmouse.cpp index 57d53b39a..ae3824c67 100644 --- a/examples/osgkeyboardmouse/osgkeyboardmouse.cpp +++ b/examples/osgkeyboardmouse/osgkeyboardmouse.cpp @@ -165,6 +165,10 @@ public: osg::notify(osg::NOTICE)<<"Using projection coordiates for picking"< intersectors = new osgUtil::IntersectorGroup; + + osg::Viewport* viewport = viewer->getCamera()->getViewport(); + unsigned int numX = 100; + unsigned int numY = 100; + double dx = viewport->width()/double(numX-1); + double dy = viewport->width()/double(numX-1); + + + double y = viewport->x(); + for(unsigned int r=0; rx(); + for(unsigned int c=0; cgetIntersectors().push_back( new osgUtil::PolytopeIntersector( osgUtil::Intersector::WINDOW, x-dx*0.5, y-dy*0.5, x+dx*0.5, y+dy*0.5 ) ); + } + else + { + intersectors->getIntersectors().push_back( new osgUtil::LineSegmentIntersector( osgUtil::Intersector::WINDOW, x, y ) ); + } + + x += dx; + } + y += dy; + } + + + osgUtil::IntersectionVisitor iv(intersectors.get()); + + osg::ElapsedTime elapsedTime; + viewer->getCamera()->accept(iv); + + OSG_NOTICE<<"Intersection traversal took "<getIntersectors().size()<<" intersectors"<getSceneData();