Hi,

i finally got to cast some rays with my ray-casting application and i found out 
the perforamce is terribly low. i am not sure how fast the intersections should 
be counted, but i am pretty sure that an image 160x120 pixels (which is 19200 
points) should be computed in less than 5.5 seconds ... which is the time i am 
getting when measuring.

i literally copied the part of the osgintersection example that is using the 
intersectorGroup. i am using the intersectionGroup and intersectionVisitor.

Code:
osgUtil::LineSegmentIntersector* intersector = new 
osgUtil::LineSegmentIntersector(osgUtil::LineSegmentIntersector::WINDOW, 
osg::Vec3(x, y, 0), osg::Vec3(x, y, 1));
intersectorGroup->addIntersector(intersector);

this way i add intersectors to the group for each pixel of my window.
this way i try to compute the intersections and measure time
Code:
osgUtil::IntersectionVisitor intersectionVisitor(intersectorGroup.get());
intersectionVisitor.setUseKdTreeWhenAvailable(true);

osg::Timer_t startTick = osg::Timer::instance()->tick();

osg::Camera *cam = _wm->getSceneView()->getCamera();
cam->accept(intersectionVisitor);

osg::Timer_t endTick = osg::Timer::instance()->tick();
std::cout << "Frame in " << osg::Timer::instance()->delta_s(startTick, endTick) 
<< " sec." << std::endl;


the time varies from 4.9 to 6 seconds for 160x120 pixel image, for 320x240 the 
time increases 4 times to roughly 22 seconds ... though i am using a notebook 
it is NOT any 86286 computer :) this way i won't be able to compute full screen 
app window in reasonable time :(

i tried the built-in KdTree support by calling 
Code:
osgDB::Registry::instance()->setBuildKdTreesHint(osgDB::ReaderWriter::Options::BUILD_KDTREES);

as the first command in my main() function.
As i didn't record any changes in the computing time, i even tried running the 
KdTreeBuilder on my loaded model "manually" 
Code:
osg::KdTreeBuilder *kdtb = new osg::KdTreeBuilder;
loadedModel->accept(*kdtb);

still with NO preformance change. And by NO i mean NOthing, i am getting the 
same runing time. i also tried limiting the amount o intersections by setting 
the intersection limit for each intersector calling
Code:
intersector->setIntersectionLimit(osgUtil::Intersector::LIMIT_NEAREST);

in the loop that creates one for every pixel of the window (the first code 
snippet in this post). only the LIMIT_ONE option decreased the computing time 
by roughly 0.3 seconds (which is still unacceptable), but the result i got was 
not accurate.

what am i doing wrong? why are the Kd-Trees not working properly? the 
documentation says the performance should improve from tens to thousands times. 
then why not for me?

Thank you for any tips that may help me.

Andrey

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=44655#44655





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to