Skip to content

Commit

Permalink
Fix jumpy first mouse movement in capture mouse mode
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 13, 2021
1 parent 2b9d772 commit 514edfb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/3d/qgscameracontroller.cpp
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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 ) )
Expand Down
1 change: 1 addition & 0 deletions src/3d/qgscameracontroller.h
Expand Up @@ -235,6 +235,7 @@ class _3D_EXPORT QgsCameraController : public Qt3DCore::QEntity

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

Expand Down

0 comments on commit 514edfb

Please sign in to comment.