diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2013-11-15 13:47:24 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-20 11:22:08 +0100 |
commit | cd91d8ad0281c984a01b8091696a6fdfdfa69514 (patch) | |
tree | 690e2be9ab5e2a9ec8a5a6b005c9ab745ca16c2f /src/gui/math3d/qvector4d.h | |
parent | ac6b9be9b3d207aef6241c59edc7375f6fadabeb (diff) |
Convert more QVector*D member functions to constexpr
constexpr requires inline functions. We convert more member functions
to inline functions while retaining a version of those functions
inside QtGui. This prevents any BC breakage.
Change-Id: I325b78da6b41611bda3994869f474c700b6fb306
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/gui/math3d/qvector4d.h')
-rw-r--r-- | src/gui/math3d/qvector4d.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/gui/math3d/qvector4d.h b/src/gui/math3d/qvector4d.h index 5e21d0853d..1256f384a0 100644 --- a/src/gui/math3d/qvector4d.h +++ b/src/gui/math3d/qvector4d.h @@ -86,7 +86,12 @@ public: float operator[](int i) const; float length() const; +#ifdef QT_BUILD_GUI_LIB float lengthSquared() const; +#else + Q_DECL_CONSTEXPR inline float lengthSquared() const + { return xp * xp + yp * yp + zp * zp + wp * wp; } +#endif QVector4D normalized() const; void normalize(); @@ -97,7 +102,12 @@ public: QVector4D &operator*=(const QVector4D &vector); QVector4D &operator/=(float divisor); +#ifdef QT_BUILD_GUI_LIB static float dotProduct(const QVector4D& v1, const QVector4D& v2); +#else + static float dotProduct(const QVector4D& v1, const QVector4D& v2) + { return v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp + v1.wp * v2.wp; } +#endif Q_DECL_CONSTEXPR friend inline bool operator==(const QVector4D &v1, const QVector4D &v2); Q_DECL_CONSTEXPR friend inline bool operator!=(const QVector4D &v1, const QVector4D &v2); |