Show
Ignore:
Timestamp:
10/07/08 16:01:14 (6 years ago)
Author:
robert
Message:

Replaced usage of depreacted IntersectVisitor? with IntersectionVisitor?

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgspheresegment/osgspheresegment.cpp

    r7648 r8998  
    2828 
    2929#include <osgUtil/SmoothingVisitor> 
    30 #include <osgUtil/IntersectVisitor> 
    3130 
    3231#include <osgDB/ReadFile> 
     
    318317osg::Vec3 computeTerrainIntersection(osg::Node* subgraph,float x,float y) 
    319318{ 
    320     osgUtil::IntersectVisitor iv; 
    321     osg::ref_ptr<osg::LineSegment> segDown = new osg::LineSegment; 
    322  
    323319    const osg::BoundingSphere& bs = subgraph->getBound(); 
    324320    float zMax = bs.center().z()+bs.radius(); 
    325321    float zMin = bs.center().z()-bs.radius(); 
    326322     
    327     segDown->set(osg::Vec3(x,y,zMin),osg::Vec3(x,y,zMax)); 
    328     iv.addLineSegment(segDown.get()); 
     323    osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector =  
     324        new osgUtil::LineSegmentIntersector(osg::Vec3(x,y,zMin),osg::Vec3(x,y,zMax)); 
     325 
     326    osgUtil::IntersectionVisitor iv(intersector.get()); 
    329327 
    330328    subgraph->accept(iv); 
    331329 
    332     if (iv.hits()) 
    333     { 
    334         osgUtil::IntersectVisitor::HitList& hitList = iv.getHitList(segDown.get()); 
    335         if (!hitList.empty()) 
    336         { 
    337             osg::Vec3 ip = hitList.front().getWorldIntersectPoint(); 
    338             return  ip; 
    339         } 
     330    if (intersector->containsIntersections()) 
     331    { 
     332        return intersector->getFirstIntersection().getWorldIntersectPoint(); 
    340333    } 
    341334