Aded --dim-mask mask and --dm mask command line option for setting the PolytopeIntersector::setDimensionsMask().

This commit is contained in:
Robert Osfield 2017-05-24 16:01:49 +01:00
parent 47aaca5191
commit 6d46a35900

View File

@ -124,10 +124,14 @@ public:
_mx(0.0),_my(0.0), _mx(0.0),_my(0.0),
_usePolytopeIntersector(false), _usePolytopeIntersector(false),
_useWindowCoordinates(false), _useWindowCoordinates(false),
_precisionHint(osgUtil::Intersector::USE_DOUBLE_CALCULATIONS) {} _precisionHint(osgUtil::Intersector::USE_DOUBLE_CALCULATIONS),
_dimensionMask(osgUtil::PolytopeIntersector::AllDims) {}
~PickHandler() {} ~PickHandler() {}
void setDimensionMask(unsigned int dimensionMask) { _dimensionMask = dimensionMask; }
bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
{ {
osgViewer::Viewer* viewer = dynamic_cast<osgViewer::Viewer*>(&aa); osgViewer::Viewer* viewer = dynamic_cast<osgViewer::Viewer*>(&aa);
@ -224,7 +228,9 @@ public:
if (_usePolytopeIntersector) 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<osgUtil::PolytopeIntersector> 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 else
{ {
@ -284,6 +290,7 @@ public:
} }
picker->setPrecisionHint(_precisionHint); picker->setPrecisionHint(_precisionHint);
picker->setDimensionMask(_dimensionMask);
osgUtil::IntersectionVisitor iv(picker); osgUtil::IntersectionVisitor iv(picker);
@ -405,6 +412,7 @@ protected:
bool _usePolytopeIntersector; bool _usePolytopeIntersector;
bool _useWindowCoordinates; bool _useWindowCoordinates;
osgUtil::Intersector::PrecisionHint _precisionHint; 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("--double")) { pickhandler->setPrecisionHint(osgUtil::Intersector::USE_DOUBLE_CALCULATIONS); }
while (arguments.read("--float")) { pickhandler->setPrecisionHint(osgUtil::Intersector::USE_FLOAT_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 // load model
osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments); osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments);