diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-04-24 10:24:44 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-05-04 13:49:27 +0000 |
commit | ec73b5d4b83df954ea68076c51e8ab6a85477a0d (patch) | |
tree | b6adc3e754a3ee8f70700c2afc8db6bcc53b273c /src/gui/math3d | |
parent | cecd52b89ae6c58476c39079830908d22f52ef2d (diff) |
QQuaternion: prepare isNull(), isIdentity() for constexpr'ification
...by dropping the use of qIsNull(), which, in Qt 4, distinguished
between -0.0f and +0.0f.
But mathematically, whether x, y, z are ±0 doesn't change the fact
that the result is the identity element (x, y, z should contain the
identity element for addition and w the one for multiplication), or
the null element (additive identity).
So using qIsNull() was wrong even in Qt 4. In Qt 5, qIsNull() returns
true for both ±0, so we can just as well compare to 0.0f instead,
which allows to mark these functions constexpr (qIsNull() can't be).
Do so.
Change-Id: I78b1fa7890036dd3cb4de7f90b75d439f9835e73
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Diffstat (limited to 'src/gui/math3d')
-rw-r--r-- | src/gui/math3d/qquaternion.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h index 52c717072d..6bed397893 100644 --- a/src/gui/math3d/qquaternion.h +++ b/src/gui/math3d/qquaternion.h @@ -161,12 +161,12 @@ inline QQuaternion::QQuaternion(float aScalar, float xpos, float ypos, float zpo inline bool QQuaternion::isNull() const { - return qIsNull(xp) && qIsNull(yp) && qIsNull(zp) && qIsNull(wp); + return xp == 0.0f && yp == 0.0f && zp == 0.0f && wp == 0.0f; } inline bool QQuaternion::isIdentity() const { - return qIsNull(xp) && qIsNull(yp) && qIsNull(zp) && wp == 1.0f; + return xp == 0.0f && yp == 0.0f && zp == 0.0f && wp == 1.0f; } inline float QQuaternion::x() const { return xp; } |