From c7698c133456d59f90f893a13334568d621ebfca Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 23 Dec 2011 17:21:59 +0000 Subject: [PATCH] From Aurelien Albert, "I made a modification in the Dragger class : You can now set a "intersection mask" and it will be used when looking for intersections. So you can now easily "hide" some objects from manipulators." --- include/osgManipulator/Dragger | 10 ++++++++++ src/osgManipulator/Dragger.cpp | 17 ++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/include/osgManipulator/Dragger b/include/osgManipulator/Dragger index 7edb3cf84..b28f44c4a 100644 --- a/include/osgManipulator/Dragger +++ b/include/osgManipulator/Dragger @@ -262,6 +262,13 @@ class OSGMANIPULATOR_EXPORT Dragger : public osg::MatrixTransform void setDraggerActive(bool active) { _draggerActive = active; } bool getDraggerActive() const { return _draggerActive; } + /** + * Set/Get the traversal mask used by this dragger when looking for intersections during event handling. + * This is usefull to "hide" some geometry during event handling. + */ + virtual void setIntersectionMask(osg::Node::NodeMask intersectionMask) { _intersectionMask = intersectionMask; } + osg::Node::NodeMask getIntersectionMask() const { return _intersectionMask; } + protected: Dragger(); @@ -285,6 +292,7 @@ class OSGMANIPULATOR_EXPORT Dragger : public osg::MatrixTransform osg::ref_ptr _selfUpdater; Constraints _constraints; DraggerCallbacks _draggerCallbacks; + osg::Node::NodeMask _intersectionMask; }; @@ -317,6 +325,8 @@ class OSGMANIPULATOR_EXPORT CompositeDragger : public Dragger bool containsDragger(const Dragger* dragger) const; DraggerList::iterator findDragger(const Dragger* dragger); + virtual void setIntersectionMask(osg::Node::NodeMask intersectionMask); + protected: CompositeDragger() {} diff --git a/src/osgManipulator/Dragger.cpp b/src/osgManipulator/Dragger.cpp index 5b8d684f7..f69335ba4 100644 --- a/src/osgManipulator/Dragger.cpp +++ b/src/osgManipulator/Dragger.cpp @@ -129,7 +129,8 @@ Dragger::Dragger() : _activationModKeyMask(0), _activationKeyEvent(0), _activationPermittedByModKeyMask(false), - _activationPermittedByKeyEvent(false) + _activationPermittedByKeyEvent(false), + _intersectionMask(0xffffffff) { _parentDragger = this; getOrCreateStateSet()->setDataVariance(osg::Object::DYNAMIC); @@ -145,7 +146,8 @@ Dragger::Dragger(const Dragger& rhs, const osg::CopyOp& copyop): _activationModKeyMask(rhs._activationModKeyMask), _activationKeyEvent(rhs._activationKeyEvent), _activationPermittedByModKeyMask(false), - _activationPermittedByKeyEvent(false) + _activationPermittedByKeyEvent(false), + _intersectionMask(0xffffffff) { OSG_NOTICE<<"CompositeDragger::CompositeDragger(const CompositeDragger& rhs, const osg::CopyOp& copyop) not Implemented yet."<computeIntersections(ea.getX(),ea.getY(),intersections)) + if (view->computeIntersections(ea.getX(),ea.getY(),intersections, _intersectionMask)) { for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr = intersections.begin(); hitr != intersections.end(); @@ -481,6 +483,15 @@ void CompositeDragger::setParentDragger(Dragger* dragger) Dragger::setParentDragger(dragger); } +void CompositeDragger::setIntersectionMask(osg::Node::NodeMask intersectionMask) +{ + Dragger::setIntersectionMask(intersectionMask); + for (DraggerList::iterator itr = _draggerList.begin(); itr != _draggerList.end(); ++itr) + { + (*itr)->setIntersectionMask(intersectionMask); + } +} + class ForceCullCallback : public osg::Drawable::CullCallback { public: