Added optional TraversalMask paramter to computeIntersections() methods.

This commit is contained in:
Robert Osfield 2003-12-04 09:43:34 +00:00
parent db66abd6d6
commit f9fcffd9cd
2 changed files with 18 additions and 11 deletions

View File

@ -115,16 +115,16 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction
bool computeNearFarPoints(float x,float y,unsigned int cameraNum,osg::Vec3& near, osg::Vec3& far); bool computeNearFarPoints(float x,float y,unsigned int cameraNum,osg::Vec3& near, osg::Vec3& far);
/** compute, from normalized mouse coords, for all Cameras, intersections with the specified subgraph.*/ /** compute, from normalized mouse coords, for all Cameras, intersections with the specified subgraph.*/
bool computeIntersections(float x,float y,unsigned int cameraNum,osg::Node *node,osgUtil::IntersectVisitor::HitList& hits); bool computeIntersections(float x,float y,unsigned int cameraNum,osg::Node *node,osgUtil::IntersectVisitor::HitList& hits,osg::Node::NodeMask traversalMask = 0xffffffff);
/** compute, from normalized mouse coords, for sepecified Camera, intersections with the scene.*/ /** compute, from normalized mouse coords, for sepecified Camera, intersections with the scene.*/
bool computeIntersections(float x,float y,unsigned int cameraNum,osgUtil::IntersectVisitor::HitList& hits); bool computeIntersections(float x,float y,unsigned int cameraNum,osgUtil::IntersectVisitor::HitList& hits,osg::Node::NodeMask traversalMask = 0xffffffff);
/** compute, from normalized mouse coords, for all Cameras, intersections with specified subgraph.*/ /** compute, from normalized mouse coords, for all Cameras, intersections with specified subgraph.*/
bool computeIntersections(float x,float y,osg::Node *node,osgUtil::IntersectVisitor::HitList& hits); bool computeIntersections(float x,float y,osg::Node *node,osgUtil::IntersectVisitor::HitList& hits,osg::Node::NodeMask traversalMask = 0xffffffff);
/** compute, from normalized mouse coords, for all Cameras, intersections with the scene.*/ /** compute, from normalized mouse coords, for all Cameras, intersections with the scene.*/
bool computeIntersections(float x,float y,osgUtil::IntersectVisitor::HitList& hits); bool computeIntersections(float x,float y,osgUtil::IntersectVisitor::HitList& hits,osg::Node::NodeMask traversalMask = 0xffffffff);
void setKeyboardMouse(Producer::KeyboardMouse* kbm); void setKeyboardMouse(Producer::KeyboardMouse* kbm);
Producer::KeyboardMouse* getKeyboardMouse() { return _kbm.get(); } Producer::KeyboardMouse* getKeyboardMouse() { return _kbm.get(); }

View File

@ -62,6 +62,12 @@ public:
} }
~PickVisitor() {} ~PickVisitor() {}
void setTraversalMask(osg::Node::NodeMask traversalMask)
{
NodeVisitor::setTraversalMask(traversalMask);
_piv.setTraversalMask(traversalMask);
}
// Aug 2003 added to pass the nodemaskOverride to the PickIntersectVisitor // Aug 2003 added to pass the nodemaskOverride to the PickIntersectVisitor
// may be used make the visitor override the nodemask to visit invisible actions // may be used make the visitor override the nodemask to visit invisible actions
inline void setNodeMaskOverride(osg::Node::NodeMask mask) { inline void setNodeMaskOverride(osg::Node::NodeMask mask) {
@ -588,7 +594,7 @@ bool Viewer::computeNearFarPoints(float x,float y,unsigned int cameraNum,osg::Ve
} }
bool Viewer::computeIntersections(float x,float y,unsigned int cameraNum,osg::Node *node,osgUtil::IntersectVisitor::HitList& hits) bool Viewer::computeIntersections(float x,float y,unsigned int cameraNum,osg::Node *node,osgUtil::IntersectVisitor::HitList& hits,osg::Node::NodeMask traversalMask)
{ {
float pixel_x,pixel_y; float pixel_x,pixel_y;
if (computePixelCoords(x,y,cameraNum,pixel_x,pixel_y)) if (computePixelCoords(x,y,cameraNum,pixel_x,pixel_y))
@ -621,6 +627,7 @@ bool Viewer::computeIntersections(float x,float y,unsigned int cameraNum,osg::No
} }
PickVisitor iv; PickVisitor iv;
iv.setTraversalMask(traversalMask);
osgUtil::IntersectVisitor::HitList localHits; osgUtil::IntersectVisitor::HitList localHits;
localHits = iv.getHits(node, vum, rx,ry); localHits = iv.getHits(node, vum, rx,ry);
@ -634,26 +641,26 @@ bool Viewer::computeIntersections(float x,float y,unsigned int cameraNum,osg::No
return false; return false;
} }
bool Viewer::computeIntersections(float x,float y,unsigned int cameraNum,osgUtil::IntersectVisitor::HitList& hits) bool Viewer::computeIntersections(float x,float y,unsigned int cameraNum,osgUtil::IntersectVisitor::HitList& hits,osg::Node::NodeMask traversalMask)
{ {
return computeIntersections(x,y,cameraNum,getSceneData(),hits); return computeIntersections(x,y,cameraNum,getSceneData(),hits,traversalMask);
} }
bool Viewer::computeIntersections(float x,float y,osg::Node *node,osgUtil::IntersectVisitor::HitList& hits) bool Viewer::computeIntersections(float x,float y,osg::Node *node,osgUtil::IntersectVisitor::HitList& hits,osg::Node::NodeMask traversalMask)
{ {
bool hitFound = false; bool hitFound = false;
osgUtil::IntersectVisitor::HitList hlist; osgUtil::IntersectVisitor::HitList hlist;
for(unsigned int i=0;i<getNumberOfCameras();++i) for(unsigned int i=0;i<getNumberOfCameras();++i)
{ {
if (computeIntersections(x,y,i,node,hits)) hitFound = true; if (computeIntersections(x,y,i,node,hits,traversalMask)) hitFound = true;
} }
return hitFound; return hitFound;
} }
bool Viewer::computeIntersections(float x,float y,osgUtil::IntersectVisitor::HitList& hits) bool Viewer::computeIntersections(float x,float y,osgUtil::IntersectVisitor::HitList& hits,osg::Node::NodeMask traversalMask)
{ {
return computeIntersections(x,y,getSceneData(),hits); return computeIntersections(x,y,getSceneData(),hits,traversalMask);
} }
void Viewer::selectCameraManipulator(unsigned int no) void Viewer::selectCameraManipulator(unsigned int no)