From de9e978532ef5a3c212426f0e46de9059377968d Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 6 Jun 2023 13:43:34 +0200 Subject: 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 Reviewed-by: Andy Nichols --- src/gui/math3d/qquaternion.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/gui/math3d') 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; -- cgit v1.2.3