Changeset 8552

Show
Ignore:
Timestamp:
07/09/08 21:40:10
Author:
robert
Message:

Introduced code for doing dummy test traversals - used for benchmarking KdTree? code.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • OpenSceneGraph/trunk/include/osgUtil/IntersectionVisitor

    r8548 r8552  
    156156        /** Set whether the intersectors should use KdTrees.*/ 
    157157        bool getUseKdTreeWhenAvailable() const { return _useKdTreesWhenAvailable; } 
     158         
     159        void setDoDummyTraversal(bool dummy) { _dummyTraversal = dummy; } 
     160        bool getDoDummyTraversal() const { return _dummyTraversal; } 
    158161 
    159162 
     
    213216 
    214217        bool _useKdTreesWhenAvailable; 
     218        bool _dummyTraversal; 
    215219         
    216220        osg::ref_ptr<ReadCallback> _readCallback; 
  • OpenSceneGraph/trunk/src/osgUtil/IntersectionVisitor.cpp

    r8547 r8552  
    157157     
    158158    _useKdTreesWhenAvailable = true; 
     159    _dummyTraversal = false; 
    159160 
    160161    setIntersector(intersector); 
  • OpenSceneGraph/trunk/src/osgUtil/LineSegmentIntersector.cpp

    r8547 r8552  
    286286    if ( !intersectAndClip( s, e, drawable->getBound() ) ) return; 
    287287 
     288    if (iv.getDoDummyTraversal()) return; 
     289 
    288290    double epsilon = 1e-8; 
    289291    if ((s-e).length()<epsilon) 
     
    296298    } 
    297299     
    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; 
    303300    osg::KdTree* kdTree = iv.getUseKdTreeWhenAvailable() ? dynamic_cast<osg::KdTree*>(drawable->getShape()) : 0; 
    304301    if (kdTree) 
     
    329326 
    330327                hit.localIntersectionPoint = _start*(1.0-remap_ratio) + _end*remap_ratio; 
    331                 kdTreeHit = hit.localIntersectionPoint; 
    332328                 
    333329                // osg::notify(osg::NOTICE)<<"KdTree: ratio="<<hit.ratio<<" ("<<hit.localIntersectionPoint<<")"<<std::endl; 
     
    338334                hit.ratioList.swap(lsi.ratioList); 
    339335 
    340                 ++numKdTreeHits; 
    341336                insertIntersection(hit); 
    342337 
     
    346341        return; 
    347342    } 
    348  
    349     osg::Timer_t after_kdTree = osg::Timer::instance()->tick(); 
    350343 
    351344    osg::TriangleFunctor<LineSegmentIntersectorUtils::TriangleIntersector> ti; 
     
    353346    drawable->accept(ti); 
    354347 
    355     osg::Vec3d conventionalHit; 
    356348    if (ti._hit) 
    357349    { 
     
    379371 
    380372            hit.localIntersectionPoint = _start*(1.0-remap_ratio) + _end*remap_ratio; 
    381             conventionalHit = hit.localIntersectionPoint; 
    382373 
    383374            // osg::notify(osg::NOTICE)<<"Conventional: ratio="<<hit.ratio<<" ("<<hit.localIntersectionPoint<<")"<<std::endl; 
     
    410401             
    411402            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    } 
    431406} 
    432407