From b486701da44c51b4f15073f55481766e0cce72e4 Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 21 Dec 2023 19:20:21 +0100 Subject: [PATCH] quaternion: Revert #1069 --- glm/detail/type_quat.hpp | 10 ++-- glm/detail/type_quat.inl | 51 +++++++++---------- test/core/CMakeLists.txt | 2 +- ...quat_xyzw.cpp => core_force_quat_wxyz.cpp} | 2 +- 4 files changed, 32 insertions(+), 33 deletions(-) rename test/core/{core_force_quat_xyzw.cpp => core_force_quat_wxyz.cpp} (78%) diff --git a/glm/detail/type_quat.hpp b/glm/detail/type_quat.hpp index d3726743..58261811 100644 --- a/glm/detail/type_quat.hpp +++ b/glm/detail/type_quat.hpp @@ -42,17 +42,17 @@ namespace glm # if GLM_LANG & GLM_LANG_CXXMS_FLAG union { -# ifdef GLM_FORCE_QUAT_DATA_XYZW - struct { T x, y, z, w; }; -# else +# ifdef GLM_FORCE_QUAT_DATA_WXYZ struct { T w, x, y, z; }; +# else + struct { T x, y, z, w; }; # endif typename detail::storage<4, T, detail::is_aligned::value>::type data; }; # else -# ifdef GLM_FORCE_QUAT_DATA_XYZW - T x, y, z, w; +# ifdef GLM_FORCE_QUAT_DATA_WXYZ + T w, x, y, z; # else T w, x, y, z; # endif diff --git a/glm/detail/type_quat.inl b/glm/detail/type_quat.inl index ed297368..f3f47c06 100644 --- a/glm/detail/type_quat.inl +++ b/glm/detail/type_quat.inl @@ -75,10 +75,10 @@ namespace detail GLM_FUNC_QUALIFIER GLM_CONSTEXPR T & qua::operator[](typename qua::length_type i) { assert(i >= 0 && i < this->length()); -# ifdef GLM_FORCE_QUAT_DATA_XYZW - return (&x)[i]; -# else +# ifdef GLM_FORCE_QUAT_DATA_WXYZ return (&w)[i]; +# else + return (&x)[i]; # endif } @@ -86,10 +86,10 @@ namespace detail GLM_FUNC_QUALIFIER GLM_CONSTEXPR T const& qua::operator[](typename qua::length_type i) const { assert(i >= 0 && i < this->length()); -# ifdef GLM_FORCE_QUAT_DATA_XYZW - return (&x)[i]; -# else +# ifdef GLM_FORCE_QUAT_DATA_WXYZ return (&w)[i]; +# else + return (&x)[i]; # endif } @@ -99,10 +99,10 @@ namespace detail template GLM_DEFAULTED_DEFAULT_CTOR_QUALIFIER GLM_CONSTEXPR qua::qua() # if GLM_CONFIG_CTOR_INIT != GLM_CTOR_INIT_DISABLE -# ifdef GLM_FORCE_QUAT_DATA_XYZW - : x(0), y(0), z(0), w(1) -# else +# 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 {} @@ -111,10 +111,10 @@ namespace detail # if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE template GLM_DEFAULTED_FUNC_QUALIFIER GLM_CONSTEXPR qua::qua(qua const& q) -# ifdef GLM_FORCE_QUAT_DATA_XYZW - : x(q.x), y(q.y), z(q.z), w(q.w) -# else +# 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 @@ -122,10 +122,10 @@ namespace detail template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua::qua(qua const& q) -# ifdef GLM_FORCE_QUAT_DATA_XYZW - : x(q.x), y(q.y), z(q.z), w(q.w) -# else +# 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 {} @@ -133,21 +133,20 @@ namespace detail template GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua::qua(T s, vec<3, T, Q> const& v) -# ifdef GLM_FORCE_QUAT_DATA_XYZW - : x(v.x), y(v.y), z(v.z), w(s) -# else +# 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 -# ifdef GLM_FORCE_QUAT_DATA_XYZW - GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua::qua(T _x, T _y, T _z, T _w) - : x(_x), y(_y), z(_z), w(_w) -# else GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua::qua(T _w, T _x, T _y, T _z) +# ifdef GLM_FORCE_QUAT_DATA_WXYZ : w(_w), x(_x), y(_y), z(_z) -# endif +# else + : x(_x), y(_y), z(_z), w(_w) +# endif {} template @@ -164,10 +163,10 @@ namespace detail template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua::qua(qua const& q) -# ifdef GLM_FORCE_QUAT_DATA_XYZW - : x(static_cast(q.x)), y(static_cast(q.y)), z(static_cast(q.z)), w(static_cast(q.w)) -# else +# 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 {} diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt index 6cd57b18..b8dd9683 100644 --- a/test/core/CMakeLists.txt +++ b/test/core/CMakeLists.txt @@ -13,7 +13,7 @@ glmCreateTestGTC(core_force_platform_unknown) glmCreateTestGTC(core_force_pure) glmCreateTestGTC(core_force_unrestricted_gentype) glmCreateTestGTC(core_force_xyzw_only) -glmCreateTestGTC(core_force_quat_xyzw) +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_xyzw.cpp b/test/core/core_force_quat_wxyz.cpp similarity index 78% rename from test/core/core_force_quat_xyzw.cpp rename to test/core/core_force_quat_wxyz.cpp index 7d5281c2..bcb57394 100644 --- a/test/core/core_force_quat_xyzw.cpp +++ b/test/core/core_force_quat_wxyz.cpp @@ -1,4 +1,4 @@ -#define GLM_FORCE_QUAT_DATA_XYZW +#define GLM_FORCE_QUAT_DATA_WXYZ #define GLM_FORCE_INLINE #include