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
This commit is contained in:
Robert Osfield 2015-05-25 12:39:18 +00:00
parent d5b615a4e1
commit 95a507299b
2 changed files with 39 additions and 25 deletions

View File

@ -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<osg::Camera*> 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<osg::Camera*>(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);
}

View File

@ -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<osg::Camera*> 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<osg::Camera*>(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,7 +986,18 @@ 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 = "<<eventState->getXmin()<<" Ymin="<<eventState->getYmin()<<" xMax="<<eventState->getXmax()<<" Ymax="<<eventState->getYmax()<<std::endl;