From 8c9609b331b0740c0978e3a4bea34ec96ba138bb Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 20 Mar 2002 11:22:06 +0000 Subject: [PATCH] Added the fallback of intersecting with the a drawables bounding box, if the drawable isn't a GeoSet and hence supported by the IntersectVisitor's GeoSet primitive intersections code. --- src/osgUtil/IntersectVisitor.cpp | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/osgUtil/IntersectVisitor.cpp b/src/osgUtil/IntersectVisitor.cpp index e37ef013b..44b50792c 100644 --- a/src/osgUtil/IntersectVisitor.cpp +++ b/src/osgUtil/IntersectVisitor.cpp @@ -478,6 +478,40 @@ void IntersectVisitor::apply(Geode& geode) { osg::GeoSet* gset = dynamic_cast(geode.getDrawable(i)); if (gset) intersect(*gset); + else + { + IntersectState* cis = _intersectStateStack.back().get(); + + // simply default to intersecting with bounding box. + for(IntersectState::LineSegmentList::iterator sitr=cis->_segList.begin(); + sitr!=cis->_segList.end(); + ++sitr) + { + if (sitr->second->intersect(geode.getDrawable(i)->getBound())) + { + Hit hit; + hit._nodePath = _nodePath; + hit._matrix = cis->_matrix; + hit._inverse = cis->_inverse; + hit._geoset = NULL; + if (_nodePath.empty()) hit._geode = NULL; + else hit._geode = dynamic_cast(_nodePath.back()); + + hit._ratio = 0.0f; + hit._primitiveIndex = -1; + hit._originalLineSegment = sitr->first; + hit._localLineSegment = sitr->second; + + hit._intersectPoint = geode.getDrawable(i)->getBound().center(); + + hit._intersectNormal.set(0.0,0.0,1.0); + + _segHitList[sitr->first.get()].push_back(hit); + std::sort(_segHitList[sitr->first.get()].begin(),_segHitList[sitr->first.get()].end()); + + } + } + } } leaveNode();