Replaced usage of depreacted IntersectVisitor with IntersectionVisitor

This commit is contained in:
Robert Osfield 2008-10-07 14:01:14 +00:00
parent ed2bbbf23b
commit 907a51b198
5 changed files with 24 additions and 40 deletions

View File

@ -36,7 +36,8 @@
#include <osgDB/ReadFile>
#include <osgDB/FileUtils>
#include <osgUtil/IntersectVisitor>
#include <osgUtil/LineSegmentIntersector>
#include <osgUtil/IntersectionVisitor>
#include <osgUtil/SmoothingVisitor>
#include <osgText/Text>
@ -508,22 +509,22 @@ void ForestTechniqueManager::createTreeList(osg::Node* terrain,const osg::Vec3&
if (terrain)
{
osgUtil::IntersectVisitor iv;
osg::ref_ptr<osg::LineSegment> segDown = new osg::LineSegment;
osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector =
new osgUtil::LineSegmentIntersector(tree->_position,tree->_position+osg::Vec3(0.0f,0.0f,size.z()));
segDown->set(tree->_position,tree->_position+osg::Vec3(0.0f,0.0f,size.z()));
iv.addLineSegment(segDown.get());
osgUtil::IntersectionVisitor iv(intersector.get());
terrain->accept(iv);
if (iv.hits())
if (intersector->containsIntersections())
{
osgUtil::IntersectVisitor::HitList& hitList = iv.getHitList(segDown.get());
if (!hitList.empty())
osgUtil::LineSegmentIntersector::Intersections& intersections = intersector->getIntersections();
for(osgUtil::LineSegmentIntersector::Intersections::iterator itr = intersections.begin();
itr != intersections.end();
++itr)
{
osg::Vec3 ip = hitList.front().getWorldIntersectPoint();
osg::Vec3 np = hitList.front().getWorldIntersectNormal();
tree->_position = ip;
const osgUtil::LineSegmentIntersector::Intersection& intersection = *itr;
tree->_position = intersection.getWorldIntersectPoint();
}
}
}

View File

@ -23,7 +23,6 @@
#include <osg/Geode>
#include <osg/Group>
#include <osg/Notify>
#include <osg/LineSegment>
#include <osg/io_utils>
#include <osgDB/Registry>
@ -35,7 +34,6 @@
#include <osgGA/DriveManipulator>
#include <osgUtil/Optimizer>
#include <osgUtil/IntersectVisitor>
#include <osg/OccluderNode>
#include <osg/Geometry>

View File

@ -28,7 +28,6 @@
#include <osg/io_utils>
#include <osgUtil/Optimizer>
#include <osgUtil/IntersectVisitor>
#include <osgDB/ReadFile>
@ -133,26 +132,20 @@ osg::Node* createMovingModel(const osg::Vec3& center, float radius)
osg::Vec3 computeTerrainIntersection(osg::Node* subgraph,float x,float y)
{
osgUtil::IntersectVisitor iv;
osg::ref_ptr<osg::LineSegment> segDown = new osg::LineSegment;
const osg::BoundingSphere& bs = subgraph->getBound();
float zMax = bs.center().z()+bs.radius();
float zMin = bs.center().z()-bs.radius();
segDown->set(osg::Vec3(x,y,zMin),osg::Vec3(x,y,zMax));
iv.addLineSegment(segDown.get());
osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector =
new osgUtil::LineSegmentIntersector(osg::Vec3(x,y,zMin),osg::Vec3(x,y,zMax));
osgUtil::IntersectionVisitor iv(intersector.get());
subgraph->accept(iv);
if (iv.hits())
if (intersector->containsIntersections())
{
osgUtil::IntersectVisitor::HitList& hitList = iv.getHitList(segDown.get());
if (!hitList.empty())
{
osg::Vec3 ip = hitList.front().getWorldIntersectPoint();
return ip;
}
return intersector->getFirstIntersection().getWorldIntersectPoint();
}
return osg::Vec3(x,y,0.0f);

View File

@ -39,7 +39,6 @@
#include <osgDB/ReadFile>
#include <osgDB/FileUtils>
#include <osgUtil/IntersectVisitor>
#include <osgUtil/SmoothingVisitor>
#include <osgText/Text>

View File

@ -27,7 +27,6 @@
#include <osg/Geometry>
#include <osgUtil/SmoothingVisitor>
#include <osgUtil/IntersectVisitor>
#include <osgDB/ReadFile>
@ -317,26 +316,20 @@ osg::Group* createOverlay(const osg::Vec3& center, float radius)
osg::Vec3 computeTerrainIntersection(osg::Node* subgraph,float x,float y)
{
osgUtil::IntersectVisitor iv;
osg::ref_ptr<osg::LineSegment> segDown = new osg::LineSegment;
const osg::BoundingSphere& bs = subgraph->getBound();
float zMax = bs.center().z()+bs.radius();
float zMin = bs.center().z()-bs.radius();
segDown->set(osg::Vec3(x,y,zMin),osg::Vec3(x,y,zMax));
iv.addLineSegment(segDown.get());
osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector =
new osgUtil::LineSegmentIntersector(osg::Vec3(x,y,zMin),osg::Vec3(x,y,zMax));
osgUtil::IntersectionVisitor iv(intersector.get());
subgraph->accept(iv);
if (iv.hits())
if (intersector->containsIntersections())
{
osgUtil::IntersectVisitor::HitList& hitList = iv.getHitList(segDown.get());
if (!hitList.empty())
{
osg::Vec3 ip = hitList.front().getWorldIntersectPoint();
return ip;
}
return intersector->getFirstIntersection().getWorldIntersectPoint();
}
return osg::Vec3(x,y,0.0f);