Skip to content

Commit

Permalink
Remember camera movement speed changes triggered through fps nav mode
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 14, 2021
1 parent c75fa66 commit d6d1958
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/3d/qgscameracontroller.cpp
Expand Up @@ -73,7 +73,11 @@ void QgsCameraController::setCameraNavigationMode( QgsCameraController::Navigati

void QgsCameraController::setCameraMovementSpeed( double movementSpeed )
{
if ( movementSpeed == mCameraMovementSpeed )
return;

mCameraMovementSpeed = movementSpeed;
emit cameraMovementSpeedChanged( mCameraMovementSpeed );
}

void QgsCameraController::setVerticalAxisInversion( QgsCameraController::VerticalAxisInversion inversion )
Expand Down Expand Up @@ -413,7 +417,7 @@ void QgsCameraController::onWheel( Qt3DInput::QWheelEvent *wheel )
case QgsCameraController::WalkNavigation:
{
float scaling = ( ( wheel->modifiers() & Qt::ControlModifier ) ? 0.1f : 1.0f ) / 1000.f;
mCameraMovementSpeed += mCameraMovementSpeed * scaling * wheel->angleDelta().y();
setCameraMovementSpeed( mCameraMovementSpeed + mCameraMovementSpeed * scaling * wheel->angleDelta().y() );
break;
}

Expand Down
5 changes: 5 additions & 0 deletions src/3d/qgscameracontroller.h
Expand Up @@ -218,6 +218,11 @@ class _3D_EXPORT QgsCameraController : public Qt3DCore::QEntity
//! Emitted when the navigation mode is changed using the hotkey ctrl + ~
void navigationModeHotKeyPressed( QgsCameraController::NavigationMode mode );

/**
* Emitted whenever the camera movement speed is changed by the controller.
*/
void cameraMovementSpeedChanged( double speed );

/**
* Emitted when the mouse cursor position should be moved to the specified \a point
* on the map viewport.
Expand Down
1 change: 1 addition & 0 deletions src/app/3d/qgs3dmapcanvas.cpp
Expand Up @@ -118,6 +118,7 @@ void Qgs3DMapCanvas::setMap( Qgs3DMapSettings *map )
{
QCursor::setPos( mapToGlobal( point ) );
} );
connect( cameraController(), &QgsCameraController::cameraMovementSpeedChanged, mMap, &Qgs3DMapSettings::setCameraMovementSpeed );

emit mapSettingsChanged();
}
Expand Down

0 comments on commit d6d1958

Please sign in to comment.