From Aurelien Albert, "I made a modification in the Dragger class :
You can now set a "intersection mask" and it will be used when looking for intersections. So you can now easily "hide" some objects from manipulators."
This commit is contained in:
@@ -262,6 +262,13 @@ class OSGMANIPULATOR_EXPORT Dragger : public osg::MatrixTransform
|
||||
void setDraggerActive(bool active) { _draggerActive = active; }
|
||||
bool getDraggerActive() const { return _draggerActive; }
|
||||
|
||||
/**
|
||||
* Set/Get the traversal mask used by this dragger when looking for intersections during event handling.
|
||||
* This is usefull to "hide" some geometry during event handling.
|
||||
*/
|
||||
virtual void setIntersectionMask(osg::Node::NodeMask intersectionMask) { _intersectionMask = intersectionMask; }
|
||||
osg::Node::NodeMask getIntersectionMask() const { return _intersectionMask; }
|
||||
|
||||
protected:
|
||||
|
||||
Dragger();
|
||||
@@ -285,6 +292,7 @@ class OSGMANIPULATOR_EXPORT Dragger : public osg::MatrixTransform
|
||||
osg::ref_ptr<DraggerCallback> _selfUpdater;
|
||||
Constraints _constraints;
|
||||
DraggerCallbacks _draggerCallbacks;
|
||||
osg::Node::NodeMask _intersectionMask;
|
||||
|
||||
};
|
||||
|
||||
@@ -317,6 +325,8 @@ class OSGMANIPULATOR_EXPORT CompositeDragger : public Dragger
|
||||
bool containsDragger(const Dragger* dragger) const;
|
||||
DraggerList::iterator findDragger(const Dragger* dragger);
|
||||
|
||||
virtual void setIntersectionMask(osg::Node::NodeMask intersectionMask);
|
||||
|
||||
protected:
|
||||
|
||||
CompositeDragger() {}
|
||||
|
||||
@@ -129,7 +129,8 @@ Dragger::Dragger() :
|
||||
_activationModKeyMask(0),
|
||||
_activationKeyEvent(0),
|
||||
_activationPermittedByModKeyMask(false),
|
||||
_activationPermittedByKeyEvent(false)
|
||||
_activationPermittedByKeyEvent(false),
|
||||
_intersectionMask(0xffffffff)
|
||||
{
|
||||
_parentDragger = this;
|
||||
getOrCreateStateSet()->setDataVariance(osg::Object::DYNAMIC);
|
||||
@@ -145,7 +146,8 @@ Dragger::Dragger(const Dragger& rhs, const osg::CopyOp& copyop):
|
||||
_activationModKeyMask(rhs._activationModKeyMask),
|
||||
_activationKeyEvent(rhs._activationKeyEvent),
|
||||
_activationPermittedByModKeyMask(false),
|
||||
_activationPermittedByKeyEvent(false)
|
||||
_activationPermittedByKeyEvent(false),
|
||||
_intersectionMask(0xffffffff)
|
||||
{
|
||||
OSG_NOTICE<<"CompositeDragger::CompositeDragger(const CompositeDragger& rhs, const osg::CopyOp& copyop) not Implemented yet."<<std::endl;
|
||||
}
|
||||
@@ -307,7 +309,7 @@ bool Dragger::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter&
|
||||
|
||||
_pointer.reset();
|
||||
|
||||
if (view->computeIntersections(ea.getX(),ea.getY(),intersections))
|
||||
if (view->computeIntersections(ea.getX(),ea.getY(),intersections, _intersectionMask))
|
||||
{
|
||||
for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr = intersections.begin();
|
||||
hitr != intersections.end();
|
||||
@@ -481,6 +483,15 @@ void CompositeDragger::setParentDragger(Dragger* dragger)
|
||||
Dragger::setParentDragger(dragger);
|
||||
}
|
||||
|
||||
void CompositeDragger::setIntersectionMask(osg::Node::NodeMask intersectionMask)
|
||||
{
|
||||
Dragger::setIntersectionMask(intersectionMask);
|
||||
for (DraggerList::iterator itr = _draggerList.begin(); itr != _draggerList.end(); ++itr)
|
||||
{
|
||||
(*itr)->setIntersectionMask(intersectionMask);
|
||||
}
|
||||
}
|
||||
|
||||
class ForceCullCallback : public osg::Drawable::CullCallback
|
||||
{
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user