Changeset 8552
- Timestamp:
- 07/09/08 21:40:10
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
OpenSceneGraph/trunk/include/osgUtil/IntersectionVisitor
r8548 r8552 156 156 /** Set whether the intersectors should use KdTrees.*/ 157 157 bool getUseKdTreeWhenAvailable() const { return _useKdTreesWhenAvailable; } 158 159 void setDoDummyTraversal(bool dummy) { _dummyTraversal = dummy; } 160 bool getDoDummyTraversal() const { return _dummyTraversal; } 158 161 159 162 … … 213 216 214 217 bool _useKdTreesWhenAvailable; 218 bool _dummyTraversal; 215 219 216 220 osg::ref_ptr<ReadCallback> _readCallback; OpenSceneGraph/trunk/src/osgUtil/IntersectionVisitor.cpp
r8547 r8552 157 157 158 158 _useKdTreesWhenAvailable = true; 159 _dummyTraversal = false; 159 160 160 161 setIntersector(intersector); OpenSceneGraph/trunk/src/osgUtil/LineSegmentIntersector.cpp
r8547 r8552 286 286 if ( !intersectAndClip( s, e, drawable->getBound() ) ) return; 287 287 288 if (iv.getDoDummyTraversal()) return; 289 288 290 double epsilon = 1e-8; 289 291 if ((s-e).length()<epsilon) … … 296 298 } 297 299 298 osg::Timer_t before_kdTree = osg::Timer::instance()->tick();299 unsigned int numKdTreeHits = 0;300 unsigned int numConventionalHits = 0;301 302 osg::Vec3d kdTreeHit;303 300 osg::KdTree* kdTree = iv.getUseKdTreeWhenAvailable() ? dynamic_cast<osg::KdTree*>(drawable->getShape()) : 0; 304 301 if (kdTree) … … 329 326 330 327 hit.localIntersectionPoint = _start*(1.0-remap_ratio) + _end*remap_ratio; 331 kdTreeHit = hit.localIntersectionPoint;332 328 333 329 // osg::notify(osg::NOTICE)<<"KdTree: ratio="<<hit.ratio<<" ("<<hit.localIntersectionPoint<<")"<<std::endl; … … 338 334 hit.ratioList.swap(lsi.ratioList); 339 335 340 ++numKdTreeHits;341 336 insertIntersection(hit); 342 337 … … 346 341 return; 347 342 } 348 349 osg::Timer_t after_kdTree = osg::Timer::instance()->tick();350 343 351 344 osg::TriangleFunctor<LineSegmentIntersectorUtils::TriangleIntersector> ti; … … 353 346 drawable->accept(ti); 354 347 355 osg::Vec3d conventionalHit;356 348 if (ti._hit) 357 349 { … … 379 371 380 372 hit.localIntersectionPoint = _start*(1.0-remap_ratio) + _end*remap_ratio; 381 conventionalHit = hit.localIntersectionPoint;382 373 383 374 // osg::notify(osg::NOTICE)<<"Conventional: ratio="<<hit.ratio<<" ("<<hit.localIntersectionPoint<<")"<<std::endl; … … 410 401 411 402 insertIntersection(hit); 412 ++numConventionalHits; 413 414 } 415 } 416 417 osg::Timer_t after_conventional = osg::Timer::instance()->tick(); 418 419 double timeKdTree = osg::Timer::instance()->delta_m(before_kdTree, after_kdTree); 420 double timeConventional = osg::Timer::instance()->delta_m(after_kdTree, after_conventional); 421 422 #if 0 423 if (kdTree) 424 { 425 osg::notify(osg::NOTICE)<<"KdTree ("<<kdTreeHit<<") intersections = "<<numKdTreeHits<< " time = "<<timeKdTree<<std::endl; 426 osg::notify(osg::NOTICE)<<"Conventional ("<<conventionalHit<<") intersections = "<<numConventionalHits<< " time = "<<timeConventional<<std::endl; 427 osg::notify(osg::NOTICE)<<"Ratio = "<<timeConventional/timeKdTree<<std::endl; 428 osg::notify(osg::NOTICE)<<std::endl; 429 } 430 #endif 403 404 } 405 } 431 406 } 432 407
