From 907a51b198ddb788cb7e76e65b44e41eec091453 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 7 Oct 2008 14:01:14 +0000 Subject: [PATCH] Replaced usage of depreacted IntersectVisitor with IntersectionVisitor --- examples/osgforest/osgforest.cpp | 23 ++++++++++--------- examples/osgoccluder/osgoccluder.cpp | 2 -- .../osgparticleeffects/osgparticleeffects.cpp | 19 +++++---------- .../osgshaderterrain/osgshaderterrain.cpp | 1 - .../osgspheresegment/osgspheresegment.cpp | 19 +++++---------- 5 files changed, 24 insertions(+), 40 deletions(-) diff --git a/examples/osgforest/osgforest.cpp b/examples/osgforest/osgforest.cpp index 093e5904b..67f1f6b21 100644 --- a/examples/osgforest/osgforest.cpp +++ b/examples/osgforest/osgforest.cpp @@ -36,7 +36,8 @@ #include #include -#include +#include +#include #include #include @@ -508,22 +509,22 @@ void ForestTechniqueManager::createTreeList(osg::Node* terrain,const osg::Vec3& if (terrain) { - osgUtil::IntersectVisitor iv; - osg::ref_ptr segDown = new osg::LineSegment; + osg::ref_ptr 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(); } } } diff --git a/examples/osgoccluder/osgoccluder.cpp b/examples/osgoccluder/osgoccluder.cpp index 7b8b8a9af..6c1c89af9 100644 --- a/examples/osgoccluder/osgoccluder.cpp +++ b/examples/osgoccluder/osgoccluder.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include @@ -35,7 +34,6 @@ #include #include -#include #include #include diff --git a/examples/osgparticleeffects/osgparticleeffects.cpp b/examples/osgparticleeffects/osgparticleeffects.cpp index 000b59a54..f53353d68 100644 --- a/examples/osgparticleeffects/osgparticleeffects.cpp +++ b/examples/osgparticleeffects/osgparticleeffects.cpp @@ -28,7 +28,6 @@ #include #include -#include #include @@ -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 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 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); diff --git a/examples/osgshaderterrain/osgshaderterrain.cpp b/examples/osgshaderterrain/osgshaderterrain.cpp index 302e99e3e..aab69f4ad 100644 --- a/examples/osgshaderterrain/osgshaderterrain.cpp +++ b/examples/osgshaderterrain/osgshaderterrain.cpp @@ -39,7 +39,6 @@ #include #include -#include #include #include diff --git a/examples/osgspheresegment/osgspheresegment.cpp b/examples/osgspheresegment/osgspheresegment.cpp index 052cc0d68..2960b17ac 100644 --- a/examples/osgspheresegment/osgspheresegment.cpp +++ b/examples/osgspheresegment/osgspheresegment.cpp @@ -27,7 +27,6 @@ #include #include -#include #include @@ -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 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 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);