Skip to content
Permalink
Browse files

Fix jumpy first mouse movement in capture mouse mode

  • Loading branch information
nyalldawson committed Jan 13, 2021
1 parent 2b9d772 commit 514edfbba547436a3d014d545daac3dee790df2b
Showing with 14 additions and 0 deletions.
  1. +13 −0 src/3d/qgscameracontroller.cpp
  2. +1 −0 src/3d/qgscameracontroller.h
@@ -436,9 +436,15 @@ void QgsCameraController::onKeyPressed( Qt3DInput::QKeyEvent *event )
{
mCaptureFpsMouseMovements = !mCaptureFpsMouseMovements;
if ( mCaptureFpsMouseMovements )
{
mIgnoreNextMouseMove = true;
qApp->setOverrideCursor( QCursor( Qt::BlankCursor ) );
}
else
{
mIgnoreNextMouseMove = false;
qApp->restoreOverrideCursor();
}
return;
}
}
@@ -566,6 +572,13 @@ void QgsCameraController::onPositionChangedFlyNavigation( Qt3DInput::QMouseEvent
if ( !mMousePressed && !mCaptureFpsMouseMovements )
return;

if ( mIgnoreNextMouseMove )
{
mMousePos = QPoint( mouse->x(), mouse->y() );
mIgnoreNextMouseMove = false;
return;
}

double dx = mouse->x() - mMousePos.x();
double dy = mouse->y() - mMousePos.y();
if ( mPressedButton == Qt3DInput::QMouseEvent::LeftButton || mPressedButton == Qt3DInput::QMouseEvent::MiddleButton || ( mCaptureFpsMouseMovements && mPressedButton != Qt3DInput::QMouseEvent::RightButton ) )
@@ -235,6 +235,7 @@ class _3D_EXPORT QgsCameraController : public Qt3DCore::QEntity

QSet< int > mDepressedKeys;
bool mCaptureFpsMouseMovements = false;
bool mIgnoreNextMouseMove = false;
QTimer *mFpsNavTimer = nullptr;
};

0 comments on commit 514edfb

Please sign in to comment.
You can’t perform that action at this time.