Skip to content

Commit

Permalink
[3d] Allow Shift+up/down/left/right keys to rotate/tilt camera
Browse files Browse the repository at this point in the history
Just like user can drag map with mouse or move it with up/down/left/right keys,
for consistency with Shift+drag we have now also support for arrow keys.
  • Loading branch information
wonder-sk committed Dec 30, 2017
1 parent 63c1925 commit 9f3b3e5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/3d/qgscameracontroller.cpp
Expand Up @@ -240,7 +240,7 @@ void QgsCameraController::frameTriggered( float dt )
float tx = mTxAxis->value() * dt * mCameraData.dist * 1.5;
float ty = -mTyAxis->value() * dt * mCameraData.dist * 1.5;

if ( tx || ty )
if ( !mShiftAction->isActive() && ( tx || ty ) )
{
// moving with keyboard - take into account yaw of camera
float t = sqrt( tx * tx + ty * ty );
Expand All @@ -253,9 +253,16 @@ void QgsCameraController::frameTriggered( float dt )

if ( ( mLeftMouseButtonAction->isActive() && mShiftAction->isActive() ) || mMiddleMouseButtonAction->isActive() )
{
// rotate/tilt using mouse
mCameraData.pitch += dy;
mCameraData.yaw -= dx / 2;
}
else if ( mShiftAction->isActive() && ( mTxAxis->value() || mTyAxis->value() ) )
{
// rotate/tilt using keyboard
mCameraData.pitch -= mTyAxis->value(); // down key = moving camera toward terrain
mCameraData.yaw -= mTxAxis->value(); // right key = moving camera clockwise
}
else if ( mLeftMouseButtonAction->isActive() && !mShiftAction->isActive() )
{
// translation works as if one grabbed a point on the plane and dragged it
Expand Down

0 comments on commit 9f3b3e5

Please sign in to comment.