From b5c57c3d68eeea77d6efb7146e2d57afe1ecfe43 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 29 Oct 2010 15:18:34 +0000 Subject: [PATCH] From Mikhail Izmestev, "I have discovered problem with draggers from osgManipulator in HUD. This problem caused because osgManipulator::Dragger uses matrices of top camera instead last absolute Camera in NodePath. I attached modified osgManipulator/Dragger.cpp file, where added code for finding last absolute camera. With this changes draggers works in HUD. Example for demonstrate this problem you can find in osg-users list [1]. Mikhail. [1] http://thread.gmane.org/gmane.comp.graphics.openscenegraph.user/62636 " --- src/osgManipulator/Dragger.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/osgManipulator/Dragger.cpp b/src/osgManipulator/Dragger.cpp index 5234d6e40..a5b8d49ec 100644 --- a/src/osgManipulator/Dragger.cpp +++ b/src/osgManipulator/Dragger.cpp @@ -309,9 +309,6 @@ bool Dragger::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& if (view->computeIntersections(ea.getX(),ea.getY(),intersections)) { - _pointer.setCamera(view->getCamera()); - _pointer.setMousePosition(ea.getX(), ea.getY()); - for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr = intersections.begin(); hitr != intersections.end(); ++hitr) @@ -327,6 +324,24 @@ bool Dragger::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& { if (dragger==this) { + osg::Camera *rootCamera = view->getCamera(); + osg::NodePath nodePath = _pointer._hitList.front().first; + osg::NodePath::reverse_iterator ritr; + for(ritr = nodePath.rbegin(); + ritr != nodePath.rend(); + ++ritr) + { + osg::Camera* camera = dynamic_cast(*ritr); + if (camera && (camera->getReferenceFrame()!=osg::Transform::RELATIVE_RF || camera->getParents().empty())) + { + rootCamera = camera; + break; + } + } + + _pointer.setCamera(rootCamera); + _pointer.setMousePosition(ea.getX(), ea.getY()); + dragger->handle(_pointer, ea, aa); dragger->setDraggerActive(true); handled = true; @@ -341,7 +356,7 @@ bool Dragger::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& if (_draggerActive) { _pointer._hitIter = _pointer._hitList.begin(); - _pointer.setCamera(view->getCamera()); +// _pointer.setCamera(view->getCamera()); _pointer.setMousePosition(ea.getX(), ea.getY()); handle(_pointer, ea, aa);