Skip to content

Commit

Permalink
[3d] Make right and middle mouse drag while in fly mode behavior
Browse files Browse the repository at this point in the history
consistent with other parts of qgis

Now
- right click+drag = camera dolly, to match the same behavior
as when in terrain navigation mode
- middle click+drag = pan camera left/right/up/down, which matches
the middle click+drag behavior for 2d maps
  • Loading branch information
nyalldawson committed Jan 17, 2021
1 parent 47c1072 commit 4317c4c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/3d/qgscameracontroller.cpp
Expand Up @@ -676,18 +676,20 @@ void QgsCameraController::onPositionChangedFlyNavigation( Qt3DInput::QMouseEvent
return;
}

if ( hasRightButton )
if ( hasMiddleButton )
{
// middle button drag = pan camera in place (strafe)
QVector3D cameraUp = mCamera->upVector().normalized();
QVector3D cameraFront = ( QVector3D( mCameraPose.centerPoint().x(), mCameraPose.centerPoint().y(), mCameraPose.centerPoint().z() ) - mCamera->position() ).normalized();
QVector3D cameraLeft = QVector3D::crossProduct( cameraUp, cameraFront );
QVector3D cameraPosDiff = -dx * cameraLeft - dy * cameraUp;
moveCameraPositionBy( mCameraMovementSpeed * cameraPosDiff / 10.0 );
}
else if ( hasMiddleButton )
else if ( hasRightButton )
{
// right button drag = camera dolly
QVector3D cameraFront = ( QVector3D( mCameraPose.centerPoint().x(), mCameraPose.centerPoint().y(), mCameraPose.centerPoint().z() ) - mCamera->position() ).normalized();
QVector3D cameraPosDiff = -dy * cameraFront;
QVector3D cameraPosDiff = dy * cameraFront;
moveCameraPositionBy( mCameraMovementSpeed * cameraPosDiff / 5.0 );
}
else
Expand Down

0 comments on commit 4317c4c

Please sign in to comment.