Skip to content
Permalink
Browse files

Wheel scroll changes movement speed

  • Loading branch information
nyalldawson committed Jan 13, 2021
1 parent ea5b4cb commit 3d9afb5dd7580069f4b975f8fff3397ec7a63251
Showing with 14 additions and 5 deletions.
  1. +14 −5 src/3d/qgscameracontroller.cpp
@@ -26,6 +26,7 @@
#include <Qt3DRender/QPickEvent>
#include <Qt3DInput>

#include "qgslogger.h"

QgsCameraController::QgsCameraController( Qt3DCore::QNode *parent )
: Qt3DCore::QEntity( parent )
@@ -393,11 +394,19 @@ void QgsCameraController::zoom( float factor )

void QgsCameraController::onWheel( Qt3DInput::QWheelEvent *wheel )
{
float scaling = ( ( wheel->modifiers() & Qt::ControlModifier ) ? 0.1f : 1.0f ) / 1000.f;
float dist = mCameraPose.distanceFromCenterPoint();
dist -= dist * scaling * wheel->angleDelta().y();
mCameraPose.setDistanceFromCenterPoint( dist );
updateCameraFromPose();
if ( mCameraNavigationMode == QgsCameraController::FlyNavigation )
{
float scaling = ( ( wheel->modifiers() & Qt::ControlModifier ) ? 0.1f : 1.0f ) / 1000.f;
mCameraMovementSpeed += mCameraMovementSpeed * scaling * wheel->angleDelta().y();
}
else
{
float scaling = ( ( wheel->modifiers() & Qt::ControlModifier ) ? 0.1f : 1.0f ) / 1000.f;
float dist = mCameraPose.distanceFromCenterPoint();
dist -= dist * scaling * wheel->angleDelta().y();
mCameraPose.setDistanceFromCenterPoint( dist );
updateCameraFromPose();
}
}

void QgsCameraController::onMousePressed( Qt3DInput::QMouseEvent *mouse )

0 comments on commit 3d9afb5

Please sign in to comment.
You can’t perform that action at this time.