From 61a81d8e06011e84961463607161a4168d1ecc39 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 11 Jul 2008 16:51:11 +0000 Subject: [PATCH] Updated KdTree code to refect new cleaned up API --- src/osgUtil/LineSegmentIntersector.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/osgUtil/LineSegmentIntersector.cpp b/src/osgUtil/LineSegmentIntersector.cpp index 770de9c18..fba241f5f 100644 --- a/src/osgUtil/LineSegmentIntersector.cpp +++ b/src/osgUtil/LineSegmentIntersector.cpp @@ -301,6 +301,7 @@ void LineSegmentIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Dr if (kdTree) { osg::KdTree::LineSegmentIntersections intersections; + intersections.reserve(4); if (kdTree->intersect(s,e,intersections)) { // osg::notify(osg::NOTICE)<<"Got KdTree intersections"<(*itr); + osg::KdTree::LineSegmentIntersection& lsi = *(itr); // get ratio in s,e range double ratio = lsi.ratio; @@ -330,11 +331,27 @@ void LineSegmentIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Dr hit.localIntersectionNormal = lsi.intersectionNormal; - hit.indexList.swap(lsi.indexList); - hit.ratioList.swap(lsi.ratioList); + hit.indexList.reserve(3); + hit.ratioList.reserve(3); + if (lsi.r0!=0.0f) + { + hit.indexList.push_back(lsi.p0); + hit.ratioList.push_back(lsi.r0); + } + + if (lsi.r1!=0.0f) + { + hit.indexList.push_back(lsi.p1); + hit.ratioList.push_back(lsi.r1); + } + + if (lsi.r2!=0.0f) + { + hit.indexList.push_back(lsi.p2); + hit.ratioList.push_back(lsi.r2); + } insertIntersection(hit); - } }