diff --git a/examples/osgkeyboardmouse/osgkeyboardmouse.cpp b/examples/osgkeyboardmouse/osgkeyboardmouse.cpp index 98970ad74..926b062ed 100644 --- a/examples/osgkeyboardmouse/osgkeyboardmouse.cpp +++ b/examples/osgkeyboardmouse/osgkeyboardmouse.cpp @@ -124,10 +124,14 @@ public: _mx(0.0),_my(0.0), _usePolytopeIntersector(false), _useWindowCoordinates(false), - _precisionHint(osgUtil::Intersector::USE_DOUBLE_CALCULATIONS) {} + _precisionHint(osgUtil::Intersector::USE_DOUBLE_CALCULATIONS), + _dimensionMask(osgUtil::PolytopeIntersector::AllDims) {} ~PickHandler() {} + void setDimensionMask(unsigned int dimensionMask) { _dimensionMask = dimensionMask; } + + bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) { osgViewer::Viewer* viewer = dynamic_cast(&aa); @@ -224,7 +228,9 @@ public: if (_usePolytopeIntersector) { - intersector = new osgUtil::PolytopeIntersector( osgUtil::Intersector::WINDOW, x-dx*0.5, y-dy*0.5, x+dx*0.5, y+dy*0.5); + osg::ref_ptr pi = new osgUtil::PolytopeIntersector( osgUtil::Intersector::WINDOW, x-dx*0.5, y-dy*0.5, x+dx*0.5, y+dy*0.5); + pi->setDimensionMask(_dimensionMask); + intersector = pi.get(); } else { @@ -284,6 +290,7 @@ public: } picker->setPrecisionHint(_precisionHint); + picker->setDimensionMask(_dimensionMask); osgUtil::IntersectionVisitor iv(picker); @@ -405,6 +412,7 @@ protected: bool _usePolytopeIntersector; bool _useWindowCoordinates; osgUtil::Intersector::PrecisionHint _precisionHint; + unsigned int _dimensionMask; }; @@ -451,6 +459,9 @@ int main( int argc, char **argv ) while (arguments.read("--double")) { pickhandler->setPrecisionHint(osgUtil::Intersector::USE_DOUBLE_CALCULATIONS); } while (arguments.read("--float")) { pickhandler->setPrecisionHint(osgUtil::Intersector::USE_FLOAT_CALCULATIONS); } + unsigned int mask = osgUtil::PolytopeIntersector::AllDims; + while (arguments.read("--dim-mask", mask) || arguments.read("--dm", mask)) { pickhandler->setDimensionMask(mask); } + // load model osg::ref_ptr loadedModel = osgDB::readRefNodeFiles(arguments);