From 03fc0c3662c4e580fdcf418a021f1f3342042032 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 15 May 2014 16:30:17 +0000 Subject: [PATCH] Added support for intesecting Drawable that are attached directly to the scene graph without an osg::Geode --- include/osgUtil/IntersectVisitor | 1 + include/osgUtil/IntersectionVisitor | 1 + src/osgUtil/IntersectVisitor.cpp | 7 ++++++- src/osgUtil/IntersectionVisitor.cpp | 5 +++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/osgUtil/IntersectVisitor b/include/osgUtil/IntersectVisitor index 98197ebdf..63851d627 100644 --- a/include/osgUtil/IntersectVisitor +++ b/include/osgUtil/IntersectVisitor @@ -141,6 +141,7 @@ class OSGUTIL_EXPORT IntersectVisitor : public osg::NodeVisitor virtual float getDistanceToEyePoint(const osg::Vec3& pos, bool withLODScale) const; virtual void apply(osg::Node&); + virtual void apply(osg::Drawable&); virtual void apply(osg::Geode& node); virtual void apply(osg::Billboard& node); diff --git a/include/osgUtil/IntersectionVisitor b/include/osgUtil/IntersectionVisitor index 13878888d..17db66553 100644 --- a/include/osgUtil/IntersectionVisitor +++ b/include/osgUtil/IntersectionVisitor @@ -258,6 +258,7 @@ class OSGUTIL_EXPORT IntersectionVisitor : public osg::NodeVisitor public: virtual void apply(osg::Node& node); + virtual void apply(osg::Drawable& drawable); virtual void apply(osg::Geode& geode); virtual void apply(osg::Billboard& geode); virtual void apply(osg::Group& group); diff --git a/src/osgUtil/IntersectVisitor.cpp b/src/osgUtil/IntersectVisitor.cpp index ef4d87696..c653cdf3b 100644 --- a/src/osgUtil/IntersectVisitor.cpp +++ b/src/osgUtil/IntersectVisitor.cpp @@ -399,7 +399,6 @@ void IntersectVisitor::apply(Node& node) leaveNode(); } - struct TriangleHit { TriangleHit(unsigned int index, const osg::Vec3& normal, float r1, const osg::Vec3* v1, float r2, const osg::Vec3* v2, float r3, const osg::Vec3* v3): @@ -661,6 +660,12 @@ bool IntersectVisitor::intersect(Drawable& drawable) } + +void IntersectVisitor::apply(Drawable& drawable) +{ + intersect(drawable); +} + void IntersectVisitor::apply(Geode& geode) { if (!enterNode(geode)) return; diff --git a/src/osgUtil/IntersectionVisitor.cpp b/src/osgUtil/IntersectionVisitor.cpp index c0b61d0b0..9a1608976 100644 --- a/src/osgUtil/IntersectionVisitor.cpp +++ b/src/osgUtil/IntersectionVisitor.cpp @@ -223,6 +223,11 @@ void IntersectionVisitor::apply(osg::Group& group) leave(); } +void IntersectionVisitor::apply(osg::Drawable& drawable) +{ + intersect( &drawable ); +} + void IntersectionVisitor::apply(osg::Geode& geode) { // OSG_NOTICE<<"apply(Geode&)"<