From ec73b5d4b83df954ea68076c51e8ab6a85477a0d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 24 Apr 2015 10:24:44 +0200 Subject: QQuaternion: prepare isNull(), isIdentity() for constexpr'ification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ...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 --- src/gui/math3d/qquaternion.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gui/math3d/qquaternion.h') 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; } -- cgit v1.2.3