diff options
author | Paul Olav Tvete <paul.tvete@qt.io> | 2023-06-06 13:43:34 +0200 |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@qt.io> | 2023-06-12 15:46:07 +0200 |
commit | de9e978532ef5a3c212426f0e46de9059377968d (patch) | |
tree | 69f91e3b6302c197f4ccf13ff94b2c586c357236 /src/gui/math3d | |
parent | 4c18ebbc1c0bddca4b19a585d2d3a5dafdefc4a3 (diff) |
Fix for QQuaternion normalize when length > 1
If the length of the quaternion was slightly larger than 1,
the resulting quaternion would be invalid, causing
getAxisAndAngle() to fail.
Fixes: QTBUG-114313
Pick-to: 6.5 6.6
Change-Id: I8f0616e74590dd6cfee0ce913d214c8e280c4df4
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/gui/math3d')
-rw-r--r-- | src/gui/math3d/qquaternion.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp index 018f6fb731..6998957ca1 100644 --- a/src/gui/math3d/qquaternion.cpp +++ b/src/gui/math3d/qquaternion.cpp @@ -227,8 +227,6 @@ float QQuaternion::lengthSquared() const QQuaternion QQuaternion::normalized() const { const float scale = length(); - if (qFuzzyCompare(scale, 1.0f)) - return *this; if (qFuzzyIsNull(scale)) return QQuaternion(0.0f, 0.0f, 0.0f, 0.0f); return *this / scale; @@ -243,7 +241,7 @@ QQuaternion QQuaternion::normalized() const void QQuaternion::normalize() { const float len = length(); - if (qFuzzyCompare(len, 1.0f) || qFuzzyIsNull(len)) + if (qFuzzyIsNull(len)) return; xp /= len; |