Skip to content

Commit

Permalink
Only emit cameraChanged() on frame start
Browse files Browse the repository at this point in the history
Previously the entire camera change was handled on every input event,
which led to slowdown and stutters, since we can get ~1000/s such events
with common mice. We don't care about intermediate camera states and
can only process the last state before rendering.
  • Loading branch information
dvdkon committed Jan 23, 2025
1 parent f33604b commit ff3d870
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/3d/qgscameracontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ void QgsCameraController::zoomCameraAroundPivot( const QVector3D &oldCameraPosit
void QgsCameraController::frameTriggered( float dt )
{
Q_UNUSED( dt )

if ( mCameraChanged )
emit cameraChanged();
}

void QgsCameraController::resetView( float distance )
Expand Down Expand Up @@ -282,7 +285,7 @@ void QgsCameraController::updateCameraFromPose()
if ( mCamera )
mCameraPose.updateCamera( mCamera );

emit cameraChanged();
mCameraChanged = true;
}

void QgsCameraController::moveCameraPositionBy( const QVector3D &posDiff )
Expand Down
3 changes: 3 additions & 0 deletions src/3d/qgscameracontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ class _3D_EXPORT QgsCameraController : public QObject
// 3D world's origin in map coordinates
QgsVector3D mOrigin;

//! Did camera change since last frame? Need to know if we should emit cameraChanged().
bool mCameraChanged = false;

// To test the cameracontroller
friend class TestQgs3DRendering;
friend class TestQgs3DCameraController;
Expand Down

0 comments on commit ff3d870

Please sign in to comment.