From 95a507299b18de91091b509b80a2669d9adc892f Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 25 May 2015 12:39:18 +0000 Subject: [PATCH] Changed the EventQueue::frame() event generation to use the generatePointerData/reprojectPointerData() methods in the same way that other events are handled. git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14869 16af8721-9629-0410-8352-f15c8da7e697 --- src/osgViewer/CompositeViewer.cpp | 31 +++++++++++++++++------------ src/osgViewer/Viewer.cpp | 33 ++++++++++++++++++++----------- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/src/osgViewer/CompositeViewer.cpp b/src/osgViewer/CompositeViewer.cpp index 7e5679c53..1ffed241c 100644 --- a/src/osgViewer/CompositeViewer.cpp +++ b/src/osgViewer/CompositeViewer.cpp @@ -853,6 +853,8 @@ void CompositeViewer::generatePointerData(osgGA::GUIEventAdapter& event) event.addPointerData(new osgGA::PointerData(gw, x, 0, gw->getTraits()->width, y, 0, gw->getTraits()->height)); + event.setMouseYOrientationAndUpdateCoords(osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS); + typedef std::vector CameraVector; CameraVector activeCameras; @@ -911,6 +913,8 @@ void CompositeViewer::reprojectPointerData(osgGA::GUIEventAdapter& source_event, dest_event.addPointerData(new osgGA::PointerData(gw, x, 0, gw->getTraits()->width, y, 0, gw->getTraits()->height)); + dest_event.setMouseYOrientationAndUpdateCoords(osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS); + osg::Camera* camera = (source_event.getNumPointerData()>=2) ? dynamic_cast(source_event.getPointerData(1)->object.get()) : 0; osg::Viewport* viewport = camera ? camera->getViewport() : 0; @@ -1015,17 +1019,6 @@ void CompositeViewer::eventTraversal() reprojectPointerData(*_previousEvent, *event); } -#if 0 - // assign topmost PointeData settings as the events X,Y and InputRange - osgGA::PointerData* pd = event->getPointerData(event->getNumPointerData()-1); - event->setX(pd->x); - event->setY(pd->y); - event->setInputRange(pd->xMin, pd->yMin, pd->xMax, pd->yMax); - event->setMouseYOrientation(osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS); -#else - event->setMouseYOrientationAndUpdateCoords(osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS); -#endif - _previousEvent = event; break; @@ -1117,8 +1110,20 @@ void CompositeViewer::eventTraversal() es->getEventQueue()->takeEvents(viewEventsMap[view], cutOffTime); } - // generate frame event - view->getEventQueue()->frame( getFrameStamp()->getReferenceTime() ); + // create a frame event for the new frame. + { + osgGA::GUIEventAdapter* event = view->getEventQueue()->frame( getFrameStamp()->getReferenceTime() ); + + if (!_previousEvent || _previousEvent->getNumPointerData()<2) + { + generatePointerData(*event); + } + else + { + reprojectPointerData(*_previousEvent, *event); + } + } + view->getEventQueue()->takeEvents(viewEventsMap[view], cutOffTime); } diff --git a/src/osgViewer/Viewer.cpp b/src/osgViewer/Viewer.cpp index df6c0ec3b..ec3e840ce 100644 --- a/src/osgViewer/Viewer.cpp +++ b/src/osgViewer/Viewer.cpp @@ -786,6 +786,8 @@ void Viewer::generatePointerData(osgGA::GUIEventAdapter& event) event.addPointerData(new osgGA::PointerData(gw, x, 0, gw->getTraits()->width, y, 0, gw->getTraits()->height)); + event.setMouseYOrientationAndUpdateCoords(osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS); + typedef std::vector CameraVector; CameraVector activeCameras; @@ -843,6 +845,8 @@ void Viewer::reprojectPointerData(osgGA::GUIEventAdapter& source_event, osgGA::G dest_event.addPointerData(new osgGA::PointerData(gw, x, 0, gw->getTraits()->width, y, 0, gw->getTraits()->height)); + dest_event.setMouseYOrientationAndUpdateCoords(osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS); + osg::Camera* camera = (source_event.getNumPointerData()>=2) ? dynamic_cast(source_event.getPointerData(1)->object.get()) : 0; osg::Viewport* viewport = camera ? camera->getViewport() : 0; @@ -858,6 +862,10 @@ void Viewer::reprojectPointerData(osgGA::GUIEventAdapter& source_event, osgGA::G } } +void generateOrReprojectPointerData(osgGA::GUIEventAdapter& source_event, osgGA::GUIEventAdapter& dest_event) +{ +} + void Viewer::eventTraversal() { if (_done) return; @@ -936,16 +944,6 @@ void Viewer::eventTraversal() reprojectPointerData(*eventState, *event); } -#if 0 - // assign topmost PointeData settings as the events X,Y and InputRange - osgGA::PointerData* pd = event->getPointerData(event->getNumPointerData()-1); - event->setX(pd->x); - event->setY(pd->y); - event->setInputRange(pd->xMin, pd->yMin, pd->xMax, pd->yMax); - event->setMouseYOrientation(osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS); -#else - event->setMouseYOrientationAndUpdateCoords(osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS); -#endif eventState->copyPointerDataFrom(*event); @@ -988,8 +986,19 @@ void Viewer::eventTraversal() } // create a frame event for the new frame. - _eventQueue->frame( getFrameStamp()->getReferenceTime() ); - + { + osgGA::GUIEventAdapter* event = _eventQueue->frame( getFrameStamp()->getReferenceTime() ); + + if (!eventState || eventState->getNumPointerData()<2) + { + generatePointerData(*event); + } + else + { + reprojectPointerData(*eventState, *event); + } + } + // OSG_NOTICE<<"mouseEventState Xmin = "<getXmin()<<" Ymin="<getYmin()<<" xMax="<getXmax()<<" Ymax="<getYmax()<takeEvents(events, cutOffTime);