From e979f76156b129ca967578adbcbcdae807d58eef Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 31 Jul 2014 18:29:31 +0000 Subject: [PATCH] Added NodeVisitor::INTERSECTION_VISITOR VisitorType git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14395 16af8721-9629-0410-8352-f15c8da7e697 --- include/osg/NodeVisitor | 3 ++- src/osgUI/Widget.cpp | 8 +++++++- src/osgUtil/CullVisitor.cpp | 2 +- src/osgUtil/IntersectVisitor.cpp | 3 ++- src/osgUtil/IntersectionVisitor.cpp | 6 ++---- src/osgUtil/UpdateVisitor.cpp | 3 ++- src/osgWrappers/serializers/osg/NodeVisitor.cpp | 1 + 7 files changed, 17 insertions(+), 9 deletions(-) diff --git a/include/osg/NodeVisitor b/include/osg/NodeVisitor index 1b8c94d8b..373ff4c1e 100644 --- a/include/osg/NodeVisitor +++ b/include/osg/NodeVisitor @@ -82,7 +82,8 @@ class OSG_EXPORT NodeVisitor : public virtual Object UPDATE_VISITOR, EVENT_VISITOR, COLLECT_OCCLUDER_VISITOR, - CULL_VISITOR + CULL_VISITOR, + INTERSECTION_VISITOR }; NodeVisitor(TraversalMode tm=TRAVERSE_NONE); diff --git a/src/osgUI/Widget.cpp b/src/osgUI/Widget.cpp index 9f38bf457..69af9f1df 100644 --- a/src/osgUI/Widget.cpp +++ b/src/osgUI/Widget.cpp @@ -114,8 +114,13 @@ void Widget::updateFocus(osg::NodeVisitor& nv) if (checkWithinWidget) { +#if 0 osgUtil::LineSegmentIntersector::Intersections intersections; bool withinWidget = aa->computeIntersections(*ea, nv.getNodePath(), intersections); +#else + Intersections intersections; + bool withinWidget = computeIntersections( ev, ea, intersections); +#endif _hasEventFocus = withinWidget; } @@ -227,7 +232,8 @@ void Widget::traverseImplementation(osg::NodeVisitor& nv) osg::Group::traverse(nv); } } - else if (_visible || (nv.getVisitorType()!=osg::NodeVisitor::UPDATE_VISITOR && nv.getVisitorType()!=osg::NodeVisitor::CULL_VISITOR)) + else if (_visible || + (nv.getVisitorType()!=osg::NodeVisitor::UPDATE_VISITOR && nv.getVisitorType()!=osg::NodeVisitor::CULL_VISITOR && nv.getVisitorType()!=osg::NodeVisitor::INTERSECTION_VISITOR) ) { GraphicsSubgraphMap::iterator itr = _graphicsSubgraphMap.begin(); while(itr!= _graphicsSubgraphMap.end() && itr->first<=0) diff --git a/src/osgUtil/CullVisitor.cpp b/src/osgUtil/CullVisitor.cpp index 2f3783901..7f36b575f 100644 --- a/src/osgUtil/CullVisitor.cpp +++ b/src/osgUtil/CullVisitor.cpp @@ -45,7 +45,7 @@ inline int EQUAL_F(float a, float b) CullVisitor::CullVisitor(): - NodeVisitor(CULL_VISITOR,TRAVERSE_ACTIVE_CHILDREN), + osg::NodeVisitor(CULL_VISITOR,TRAVERSE_ACTIVE_CHILDREN), _currentStateGraph(NULL), _currentRenderBin(NULL), _traversalNumber(0), diff --git a/src/osgUtil/IntersectVisitor.cpp b/src/osgUtil/IntersectVisitor.cpp index c653cdf3b..41140d51e 100644 --- a/src/osgUtil/IntersectVisitor.cpp +++ b/src/osgUtil/IntersectVisitor.cpp @@ -179,7 +179,8 @@ void IntersectVisitor::IntersectState::addLineSegment(osg::LineSegment* seg) } -IntersectVisitor::IntersectVisitor() +IntersectVisitor::IntersectVisitor(): + osg::NodeVisitor(osg::NodeVisitor::INTERSECTION_VISITOR, osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN) { // override the default node visitor mode. diff --git a/src/osgUtil/IntersectionVisitor.cpp b/src/osgUtil/IntersectionVisitor.cpp index 9a1608976..8ca1898c5 100644 --- a/src/osgUtil/IntersectionVisitor.cpp +++ b/src/osgUtil/IntersectionVisitor.cpp @@ -151,11 +151,9 @@ bool IntersectorGroup::containsIntersections() // IntersectionVisitor // -IntersectionVisitor::IntersectionVisitor(Intersector* intersector, ReadCallback* readCallback) +IntersectionVisitor::IntersectionVisitor(Intersector* intersector, ReadCallback* readCallback): + osg::NodeVisitor(osg::NodeVisitor::INTERSECTION_VISITOR, osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN) { - // override the default node visitor mode. - setTraversalMode(osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN); - _useKdTreesWhenAvailable = true; _dummyTraversal = false; diff --git a/src/osgUtil/UpdateVisitor.cpp b/src/osgUtil/UpdateVisitor.cpp index 718777f5a..f056920c2 100644 --- a/src/osgUtil/UpdateVisitor.cpp +++ b/src/osgUtil/UpdateVisitor.cpp @@ -15,7 +15,8 @@ using namespace osg; using namespace osgUtil; -UpdateVisitor::UpdateVisitor():NodeVisitor(UPDATE_VISITOR,TRAVERSE_ALL_CHILDREN) +UpdateVisitor::UpdateVisitor(): + osg::NodeVisitor(osg::NodeVisitor::UPDATE_VISITOR, osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) { } diff --git a/src/osgWrappers/serializers/osg/NodeVisitor.cpp b/src/osgWrappers/serializers/osg/NodeVisitor.cpp index 5f1dea24c..c7b968506 100644 --- a/src/osgWrappers/serializers/osg/NodeVisitor.cpp +++ b/src/osgWrappers/serializers/osg/NodeVisitor.cpp @@ -24,6 +24,7 @@ REGISTER_OBJECT_WRAPPER( NodeVistor, ADD_ENUM_VALUE( EVENT_VISITOR ); ADD_ENUM_VALUE( COLLECT_OCCLUDER_VISITOR ); ADD_ENUM_VALUE( CULL_VISITOR ); + ADD_ENUM_VALUE( INTERSECTION_VISITOR ); END_ENUM_SERIALIZER(); ADD_UINT_SERIALIZER(TraversalMask, 0xffffffff);