Skip to content

Commit

Permalink
Partially fix initial jumpy movement after toggling between navigatio…
Browse files Browse the repository at this point in the history
…n modes
  • Loading branch information
nyalldawson committed Jan 16, 2021
1 parent e2c98e1 commit 5450225
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/3d/qgscameracontroller.cpp
Expand Up @@ -68,7 +68,11 @@ QgsCameraController::QgsCameraController( Qt3DCore::QNode *parent )

void QgsCameraController::setCameraNavigationMode( QgsCameraController::NavigationMode navigationMode )
{
if ( navigationMode == mCameraNavigationMode )
return;

mCameraNavigationMode = navigationMode;
mIgnoreNextMouseMove = true;
}

void QgsCameraController::setCameraMovementSpeed( double movementSpeed )
Expand Down Expand Up @@ -348,6 +352,13 @@ void QgsCameraController::onPositionChanged( Qt3DInput::QMouseEvent *mouse )

void QgsCameraController::onPositionChangedTerrainNavigation( Qt3DInput::QMouseEvent *mouse )
{
if ( mIgnoreNextMouseMove )
{
mIgnoreNextMouseMove = false;
mMousePos = QPoint( mouse->x(), mouse->y() );
return;
}

int dx = mouse->x() - mMousePos.x();
int dy = mouse->y() - mMousePos.y();

Expand Down Expand Up @@ -462,10 +473,10 @@ void QgsCameraController::onKeyPressed( Qt3DInput::QKeyEvent *event )
switch ( mCameraNavigationMode )
{
case NavigationMode::WalkNavigation:
mCameraNavigationMode = NavigationMode::TerrainBasedNavigation;
setCameraNavigationMode( NavigationMode::TerrainBasedNavigation );
break;
case NavigationMode::TerrainBasedNavigation:
mCameraNavigationMode = NavigationMode::WalkNavigation;
setCameraNavigationMode( NavigationMode::WalkNavigation );
break;
}
emit navigationModeHotKeyPressed( mCameraNavigationMode );
Expand Down

0 comments on commit 5450225

Please sign in to comment.