Skip to content

Commit

Permalink
Fix for QQuaternion normalize when length > 1
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Andy Nichols <[email protected]>
  • Loading branch information
paulolav committed Jun 12, 2023
1 parent 4c18ebb commit de9e978
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/gui/math3d/qquaternion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit de9e978

Please sign in to comment.