Skip to content

Commit

Permalink
qgscamerapose: Fix pitch max value to avoid rotation computation error
Browse files Browse the repository at this point in the history
This is a similar fix to b173af9
which fixed the pitch min value.

With a mPitchAngle > 179.8, QQuaternion::fromEulerAngles(
mPitchAngle, mHeadingAngle, 0 ) will return bad rotation angles.

This is fixed is Qt6, but it has not been backported to Qt5.
See: https://bugreports.qt.io/browse/QTBUG-72103
  • Loading branch information
ptitjano authored and nyalldawson committed Jul 7, 2022
1 parent 75f11c8 commit 5d47cbe
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/3d/qgscamerapose.cpp
Expand Up @@ -61,9 +61,10 @@ void QgsCameraPose::setPitchAngle( float pitch )
{
// prevent going over the head
// prevent bug in QgsCameraPose::updateCamera when updating camera rotation.
// With a mPitchAngle < 0.2, QQuaternion::fromEulerAngles( mPitchAngle, mHeadingAngle, 0 ) will return bad rotation angle.
// With a mPitchAngle < 0.2 or > 179.8, QQuaternion::fromEulerAngles( mPitchAngle, mHeadingAngle, 0 )
// will return bad rotation angle.
// See https://bugreports.qt.io/browse/QTBUG-72103
mPitchAngle = std::clamp( pitch, 0.2f, 180.0f );
mPitchAngle = std::clamp( pitch, 0.2f, 179.8f );
}

void QgsCameraPose::updateCamera( Qt3DRender::QCamera *camera )
Expand Down

0 comments on commit 5d47cbe

Please sign in to comment.