Added MatrixManipulator::s/getIntersectTraversalMask(uint) to allow control

of which subgraphs should be used in intersection calculations.  Updated
Terrain,Drive and UFO manipulator to use this new flag.
This commit is contained in:
Robert Osfield 2005-03-22 21:06:06 +00:00
parent 0b2ac40fe8
commit 476a83bb9c
6 changed files with 22 additions and 1 deletions

View File

@ -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> _coordinateFrameCallback;
};
}

View File

@ -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<osg::LineSegment> segForward = new osg::LineSegment;
segForward->set(_eye,_eye+lv*(signedBuffer+distanceToMove));
iv.addLineSegment(segForward.get());

View File

@ -9,6 +9,8 @@ MatrixManipulator::MatrixManipulator()
{
_minimumDistance = 0.001;
_intersectTraversalMask = 0xffffffff;
_autoComputeHomePosition = true;
_homeEye.set(0.0,-1.0,0.0);

View File

@ -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<osg::LineSegment> 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;

View File

@ -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);

View File

@ -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<osg::LineSegment> 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<osg::LineSegment> segForward = new osg::LineSegment;