diff --git a/include/osgUtil/IntersectionVisitor b/include/osgUtil/IntersectionVisitor index b79d9f82b..f567a021a 100644 --- a/include/osgUtil/IntersectionVisitor +++ b/include/osgUtil/IntersectionVisitor @@ -155,6 +155,9 @@ class OSGUTIL_EXPORT IntersectionVisitor : public osg::NodeVisitor /** Set whether the intersectors should use KdTrees.*/ bool getUseKdTreeWhenAvailable() const { return _useKdTreesWhenAvailable; } + + void setDoDummyTraversal(bool dummy) { _dummyTraversal = dummy; } + bool getDoDummyTraversal() const { return _dummyTraversal; } /** Set the read callback.*/ @@ -212,6 +215,7 @@ class OSGUTIL_EXPORT IntersectionVisitor : public osg::NodeVisitor IntersectorStack _intersectorStack; bool _useKdTreesWhenAvailable; + bool _dummyTraversal; osg::ref_ptr _readCallback; diff --git a/src/osgUtil/IntersectionVisitor.cpp b/src/osgUtil/IntersectionVisitor.cpp index 010ddef8e..f592e2e43 100644 --- a/src/osgUtil/IntersectionVisitor.cpp +++ b/src/osgUtil/IntersectionVisitor.cpp @@ -156,6 +156,7 @@ IntersectionVisitor::IntersectionVisitor(Intersector* intersector, ReadCallback* setTraversalMode(osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN); _useKdTreesWhenAvailable = true; + _dummyTraversal = false; setIntersector(intersector); diff --git a/src/osgUtil/LineSegmentIntersector.cpp b/src/osgUtil/LineSegmentIntersector.cpp index 2caeb0a5f..770de9c18 100644 --- a/src/osgUtil/LineSegmentIntersector.cpp +++ b/src/osgUtil/LineSegmentIntersector.cpp @@ -285,6 +285,8 @@ void LineSegmentIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Dr osg::Vec3d s(_start), e(_end); if ( !intersectAndClip( s, e, drawable->getBound() ) ) return; + if (iv.getDoDummyTraversal()) return; + double epsilon = 1e-8; if ((s-e).length()tick(); - unsigned int numKdTreeHits = 0; - unsigned int numConventionalHits = 0; - - osg::Vec3d kdTreeHit; osg::KdTree* kdTree = iv.getUseKdTreeWhenAvailable() ? dynamic_cast(drawable->getShape()) : 0; if (kdTree) { @@ -328,7 +325,6 @@ void LineSegmentIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Dr hit.primitiveIndex = lsi.primitiveIndex; hit.localIntersectionPoint = _start*(1.0-remap_ratio) + _end*remap_ratio; - kdTreeHit = hit.localIntersectionPoint; // osg::notify(osg::NOTICE)<<"KdTree: ratio="<tick(); - osg::TriangleFunctor ti; ti.set(s,e); drawable->accept(ti); - osg::Vec3d conventionalHit; if (ti._hit) { osg::Geometry* geometry = drawable->asGeometry(); @@ -378,7 +370,6 @@ void LineSegmentIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Dr hit.primitiveIndex = triHit._index; hit.localIntersectionPoint = _start*(1.0-remap_ratio) + _end*remap_ratio; - conventionalHit = hit.localIntersectionPoint; // osg::notify(osg::NOTICE)<<"Conventional: ratio="<tick(); - - double timeKdTree = osg::Timer::instance()->delta_m(before_kdTree, after_kdTree); - double timeConventional = osg::Timer::instance()->delta_m(after_kdTree, after_conventional); - -#if 0 - if (kdTree) - { - osg::notify(osg::NOTICE)<<"KdTree ("<