]> git.mxchange.org Git - flightgear.git/commitdiff
osgviewer mouse warp fixes
authortimoore <timoore>
Sun, 19 Aug 2007 05:29:00 +0000 (05:29 +0000)
committertimoore <timoore>
Sun, 19 Aug 2007 05:29:00 +0000 (05:29 +0000)
After a mouse warp drop all pointer motion events for the entire frame.

Author: Melchior FRANZ

src/Main/FGManipulator.cxx
src/Main/FGManipulator.hxx
src/Main/fg_os_osgviewer.cxx

index 8bffc930a6418b64bff2d5d1e217ac6e659f3066..416ecf529a1991e27fbc90ed8fe8642a38ed186b 100644 (file)
@@ -13,7 +13,7 @@
 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;
     
@@ -132,6 +132,7 @@ bool FGManipulator::handle(const osgGA::GUIEventAdapter& ea,
            (*idleHandler)();
        if (drawHandler)
            (*drawHandler)();
+       mouseWarped = false;
        return true;
     case osgGA::GUIEventAdapter::KEYDOWN:
     case osgGA::GUIEventAdapter::KEYUP:
@@ -167,6 +168,12 @@ bool FGManipulator::handle(const osgGA::GUIEventAdapter& ea,
     }
     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);
index 78fb8720200f84d756c8555f313f7cd458b2e3ff..5412ce6f36c88aea1465d9fe7396a85e49c6ebea 100644 (file)
@@ -103,6 +103,12 @@ public:
        {
            return currentModifiers;
        }
+
+    void setMouseWarped()
+       {
+           mouseWarped = true;
+       }
+
     void setPosition(const osg::Vec3d position) { this->position = position; }
     void setAttitude(const osg::Quat attitude) { this->attitude = attitude; }
 
@@ -130,5 +136,6 @@ protected:
     osg::Quat attitude;
     void handleKey(const osgGA::GUIEventAdapter& ea, int& key, int& modifiers);
     bool resizable;
+    bool mouseWarped;
 };
 #endif
index 25a23643d6496301428ed46a1bafad87be38190b..afd55c976f04ccf3fd988c44b512a43eb57dbbd5 100644 (file)
@@ -250,6 +250,7 @@ int fgGetKeyModifiers()
 
 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()) {
@@ -260,7 +261,6 @@ void fgWarpMouse(int x, int y)
     float ysize = (float)mainCamera->getGraphicsContext()->getTraits()->height;
     viewer->requestWarpPointer(2.0f * (float)x / xsize - 1.0f,
                                1.0f - 2.0f * (float)y / ysize);
-    
 }
 
 // Noop