diff --git a/include/osgGA/MatrixManipulator b/include/osgGA/MatrixManipulator index 81ff9ee51..cf182811a 100644 --- a/include/osgGA/MatrixManipulator +++ b/include/osgGA/MatrixManipulator @@ -100,6 +100,12 @@ public: /** Get the FusionDistanceValue. Used by SceneView for setting up setereo convergence.*/ virtual float getFusionDistanceValue() const { return 1.0f; } + /** Set the mask to use when set up intersection traversal such as used in manipulators that follow terrain or have collision detection. + * The intersection traversal mask is useful for controlling what parts of the scene graph should be used for intersection purposes.*/ + void setIntersectTraversalMask(unsigned int mask) { _intersectTraversalMask = mask; } + + /** Get the mask to use when set up intersection traversal such as used in manipulators that follow terrain or have collision detection.*/ + unsigned int getIntersectTraversalMask() const { return _intersectTraversalMask; } /** Attach a node to the manipulator, automatically detaching any previously attached node. @@ -185,6 +191,8 @@ protected: double _minimumDistance; + unsigned int _intersectTraversalMask; + bool _autoComputeHomePosition; osg::Vec3d _homeEye; @@ -192,6 +200,7 @@ protected: osg::Vec3d _homeUp; osg::ref_ptr _coordinateFrameCallback; + }; } diff --git a/src/osgGA/DriveManipulator.cpp b/src/osgGA/DriveManipulator.cpp index 2b81b30a3..f3450fcf7 100644 --- a/src/osgGA/DriveManipulator.cpp +++ b/src/osgGA/DriveManipulator.cpp @@ -105,6 +105,7 @@ void DriveManipulator::computeHomePosition() // check to see if any obstruction in front. osgUtil::IntersectVisitor iv; + iv.setTraversalMask(_intersectTraversalMask); bool positionSet = false; @@ -223,6 +224,7 @@ void DriveManipulator::init(const GUIEventAdapter& ea,GUIActionAdapter& us) // check to see if any obstruction in front. osgUtil::IntersectVisitor iv; + iv.setTraversalMask(_intersectTraversalMask); bool positionSet = false; @@ -574,6 +576,8 @@ bool DriveManipulator::calcMovement() // check to see if any obstruction in front. osgUtil::IntersectVisitor iv; + iv.setTraversalMask(_intersectTraversalMask); + osg::ref_ptr segForward = new osg::LineSegment; segForward->set(_eye,_eye+lv*(signedBuffer+distanceToMove)); iv.addLineSegment(segForward.get()); diff --git a/src/osgGA/MatrixManipulator.cpp b/src/osgGA/MatrixManipulator.cpp index 2c226cc85..90416db5a 100644 --- a/src/osgGA/MatrixManipulator.cpp +++ b/src/osgGA/MatrixManipulator.cpp @@ -9,6 +9,8 @@ MatrixManipulator::MatrixManipulator() { _minimumDistance = 0.001; + _intersectTraversalMask = 0xffffffff; + _autoComputeHomePosition = true; _homeEye.set(0.0,-1.0,0.0); diff --git a/src/osgGA/TerrainManipulator.cpp b/src/osgGA/TerrainManipulator.cpp index b5c92176b..b99e2a27b 100644 --- a/src/osgGA/TerrainManipulator.cpp +++ b/src/osgGA/TerrainManipulator.cpp @@ -214,6 +214,7 @@ void TerrainManipulator::setByMatrix(const osg::Matrixd& matrix) // need to reintersect with the terrain osgUtil::IntersectVisitor iv; + iv.setTraversalMask(_intersectTraversalMask); const osg::BoundingSphere& bs = _node->getBound(); float distance = (eye-bs.center()).length() + _node->getBound().radius(); @@ -327,6 +328,7 @@ void TerrainManipulator::computePosition(const osg::Vec3d& eye,const osg::Vec3d& { // compute the itersection with the scene. osgUtil::IntersectVisitor iv; + iv.setTraversalMask(_intersectTraversalMask); osg::ref_ptr segLookVector = new osg::LineSegment; segLookVector->set(eye,endPoint ); @@ -475,6 +477,7 @@ bool TerrainManipulator::calcMovement() // need to reintersect with the terrain osgUtil::IntersectVisitor iv; + iv.setTraversalMask(_intersectTraversalMask); double distance = _node->getBound().radius()*0.1f; osg::Vec3d start_segment = _center + getUpVector(coordinateFrame) * distance; diff --git a/src/osgGA/TrackballManipulator.cpp b/src/osgGA/TrackballManipulator.cpp index 5c94ccf5c..c1e03b96f 100644 --- a/src/osgGA/TrackballManipulator.cpp +++ b/src/osgGA/TrackballManipulator.cpp @@ -46,7 +46,7 @@ osg::Node* TrackballManipulator::getNode() } -void TrackballManipulator::home(double currentTime) +void TrackballManipulator::home(double /*currentTime*/) { if (getAutoComputeHomePosition()) computeHomePosition(); computePosition(_homeEye, _homeCenter, _homeUp); diff --git a/src/osgGA/UFOManipulator.cpp b/src/osgGA/UFOManipulator.cpp index 996ceb287..e40a1fc1b 100644 --- a/src/osgGA/UFOManipulator.cpp +++ b/src/osgGA/UFOManipulator.cpp @@ -100,6 +100,8 @@ void UFOManipulator::computeHomePosition() * from a line segment extending from above to below the database at its * horizontal center, that intersects the database closest to zero. */ osgUtil::IntersectVisitor iv; + iv.setTraversalMask(_intersectTraversalMask); + osg::ref_ptr seg = new osg::LineSegment; osg::Vec3 A = bs.center() + (osg::Vec3(0,0,1)*(bs.radius()*2)); osg::Vec3 B = bs.center() + (osg::Vec3(0,0,-1)*(bs.radius()*2)); @@ -475,6 +477,7 @@ void UFOManipulator::_adjustPosition() return; osgUtil::IntersectVisitor iv; + iv.setTraversalMask(_intersectTraversalMask); // Forward line segment at 3 times our intersect distance osg::ref_ptr segForward = new osg::LineSegment;