Changeset 8547

Show
Ignore:
Timestamp:
07/08/08 19:35:10
Author:
robert
Message:

Added optional control of whether to use KdTrees? for intersections

Files:

Legend:

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

    r7648 r8547  
    4747            _disabledCount(0) {} 
    4848     
     49     
    4950        void setCoordinateFrame(CoordinateFrame cf) { _coordinateFrame = cf; } 
    5051         
    5152        CoordinateFrame getCoordinateFrame() const { return _coordinateFrame; } 
    52      
    53  
     53         
     54         
    5455        virtual Intersector* clone(osgUtil::IntersectionVisitor& iv) = 0; 
    5556         
     
    7374     
    7475        CoordinateFrame _coordinateFrame; 
    75         unsigned int _disabledCount; 
     76        unsigned int    _disabledCount; 
    7677 
    7778}; 
     
    139140        virtual void reset(); 
    140141 
     142 
    141143        /** Set the intersector that will be used to intersect with the scene, and to store any hits that occur.*/ 
    142144        void setIntersector(Intersector* intersector); 
     
    147149        /** Get the const intersector that will be used to intersect with the scene, and to store any hits that occur.*/ 
    148150        const Intersector* getIntersector() const { return _intersectorStack.empty() ? 0 : _intersectorStack.front().get(); } 
     151 
     152 
     153        /** Set whether the intersectors should use KdTrees when they are found on the scene graph.*/ 
     154        void setUseKdTreeWhenAvailable(bool useKdTrees) { _useKdTreesWhenAvailable; } 
     155         
     156        /** Set whether the intersectors should use KdTrees.*/ 
     157        bool getUseKdTreeWhenAvailable() const { return _useKdTreesWhenAvailable; } 
    149158 
    150159 
     
    202211        typedef std::list< osg::ref_ptr<Intersector> > IntersectorStack; 
    203212        IntersectorStack _intersectorStack; 
     213 
     214        bool _useKdTreesWhenAvailable; 
    204215         
    205216        osg::ref_ptr<ReadCallback> _readCallback; 
  • OpenSceneGraph/trunk/src/osgUtil/IntersectionVisitor.cpp

    r8501 r8547  
    156156    setTraversalMode(osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN); 
    157157     
     158    _useKdTreesWhenAvailable = true; 
     159 
    158160    setIntersector(intersector); 
    159161     
  • OpenSceneGraph/trunk/src/osgUtil/LineSegmentIntersector.cpp

    r8546 r8547  
    300300    unsigned int numConventionalHits = 0; 
    301301     
    302     osg::KdTree* kdTree = dynamic_cast<osg::KdTree*>(drawable->getShape()); 
    303302    osg::Vec3d kdTreeHit; 
     303    osg::KdTree* kdTree = iv.getUseKdTreeWhenAvailable() ? dynamic_cast<osg::KdTree*>(drawable->getShape()) : 0; 
    304304    if (kdTree) 
    305305    { 
     
    344344        } 
    345345         
    346         // return; 
    347     } 
    348     else 
    349     { 
    350         // osg::notify(osg::NOTICE)<<"Not KdTree available"<<std::endl; 
     346        return; 
    351347    } 
    352348 
     
    424420    double timeConventional = osg::Timer::instance()->delta_m(after_kdTree, after_conventional); 
    425421 
    426 #if 1 
     422#if 0 
    427423    if (kdTree) 
    428424    {