From 85e491b30c09c833aa1afb618a4f945740a2e0fe Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sun, 5 Jan 2020 20:41:51 +0100 Subject: [PATCH] Tentative fix of GLM_FORCE_QUAT_DATA_WXYZ on Clang with tests --- glm/detail/type_quat.inl | 39 +++++++++++++++++++++++------- test/core/CMakeLists.txt | 1 + test/core/core_force_quat_wxyz.cpp | 13 ++++++++++ 3 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 test/core/core_force_quat_wxyz.cpp diff --git a/glm/detail/type_quat.inl b/glm/detail/type_quat.inl index c1824e0c..692f434d 100644 --- a/glm/detail/type_quat.inl +++ b/glm/detail/type_quat.inl @@ -90,32 +90,52 @@ namespace detail template GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua::qua() # if GLM_CONFIG_CTOR_INIT != GLM_CTOR_INIT_DISABLE - : x(0), y(0), z(0), w(1) +# ifdef GLM_FORCE_QUAT_DATA_WXYZ + : w(1), x(0), y(0), z(0) +# else + : x(0), y(0), z(0), w(1) +# endif # endif {} template GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua::qua(qua const& q) - : x(q.x), y(q.y), z(q.z), w(q.w) +# ifdef GLM_FORCE_QUAT_DATA_WXYZ + : w(q.w), x(q.x), y(q.y), z(q.z) +# else + : x(q.x), y(q.y), z(q.z), w(q.w) +# endif {} # endif template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua::qua(qua const& q) - : x(q.x), y(q.y), z(q.z), w(q.w) +# ifdef GLM_FORCE_QUAT_DATA_WXYZ + : w(q.w), x(q.x), y(q.y), z(q.z) +# else + : x(q.x), y(q.y), z(q.z), w(q.w) +# endif {} // -- Explicit basic constructors -- template GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua::qua(T s, vec<3, T, Q> const& v) - : x(v.x), y(v.y), z(v.z), w(s) +# ifdef GLM_FORCE_QUAT_DATA_WXYZ + : w(s), x(v.x), y(v.y), z(v.z) +# else + : x(v.x), y(v.y), z(v.z), w(s) +# endif {} template GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua::qua(T _w, T _x, T _y, T _z) - : x(_x), y(_y), z(_z), w(_w) +# ifdef GLM_FORCE_QUAT_DATA_WXYZ + : y(_y), z(_z), w(_w), x(_x) +# else + : x(_x), y(_y), z(_z), w(_w) +# endif {} // -- Conversion constructors -- @@ -123,10 +143,11 @@ namespace detail template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua::qua(qua const& q) - : x(static_cast(q.x)) - , y(static_cast(q.y)) - , z(static_cast(q.z)) - , w(static_cast(q.w)) +# ifdef GLM_FORCE_QUAT_DATA_WXYZ + : w(static_cast(q.w)), x(static_cast(q.x)), y(static_cast(q.y)), z(static_cast(q.z)) +# else + : x(static_cast(q.x)), y(static_cast(q.y)), z(static_cast(q.z)), w(static_cast(q.w)) +# endif {} //template diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt index a1f1d0ff..935792b9 100644 --- a/test/core/CMakeLists.txt +++ b/test/core/CMakeLists.txt @@ -7,6 +7,7 @@ glmCreateTestGTC(core_force_inline) glmCreateTestGTC(core_force_pure) glmCreateTestGTC(core_force_unrestricted_gentype) glmCreateTestGTC(core_force_xyzw_only) +glmCreateTestGTC(core_force_quat_wxyz) glmCreateTestGTC(core_type_aligned) glmCreateTestGTC(core_type_cast) glmCreateTestGTC(core_type_ctor) diff --git a/test/core/core_force_quat_wxyz.cpp b/test/core/core_force_quat_wxyz.cpp new file mode 100644 index 00000000..bcb57394 --- /dev/null +++ b/test/core/core_force_quat_wxyz.cpp @@ -0,0 +1,13 @@ +#define GLM_FORCE_QUAT_DATA_WXYZ +#define GLM_FORCE_INLINE + +#include +#include + +int main() +{ + int Error = 0; + + return Error; +} +