FGManipulator::FGManipulator() :
idleHandler(0), drawHandler(0), windowResizeHandler(0), keyHandler(0),
mouseClickHandler(0), mouseMotionHandler(0), currentModifiers(0),
- osgModifiers(0), resizable(true)
+ osgModifiers(0), resizable(true), mouseWarped(false)
{
using namespace osgGA;
(*idleHandler)();
if (drawHandler)
(*drawHandler)();
+ mouseWarped = false;
return true;
case osgGA::GUIEventAdapter::KEYDOWN:
case osgGA::GUIEventAdapter::KEYUP:
}
case osgGA::GUIEventAdapter::MOVE:
case osgGA::GUIEventAdapter::DRAG:
+ // If we warped the mouse, then disregard all pointer motion
+ // events for this frame. We really want to flush the event
+ // queue of mouse events, but don't have the ability to do
+ // that with osgViewer.
+ if (mouseWarped)
+ return true;
eventToViewport(ea, us, x, y);
if (mouseMotionHandler)
(*mouseMotionHandler)(x, y);
{
return currentModifiers;
}
+
+ void setMouseWarped()
+ {
+ mouseWarped = true;
+ }
+
void setPosition(const osg::Vec3d position) { this->position = position; }
void setAttitude(const osg::Quat attitude) { this->attitude = attitude; }
osg::Quat attitude;
void handleKey(const osgGA::GUIEventAdapter& ea, int& key, int& modifiers);
bool resizable;
+ bool mouseWarped;
};
#endif
void fgWarpMouse(int x, int y)
{
+ globals->get_renderer()->getManipulator()->setMouseWarped();
// Hack, currently the pointer is just recentered. So, we know the
// relative coordinates ...
if (!mainCamera.valid()) {
float ysize = (float)mainCamera->getGraphicsContext()->getTraits()->height;
viewer->requestWarpPointer(2.0f * (float)x / xsize - 1.0f,
1.0f - 2.0f * (float)y / ysize);
-
}
// Noop