From f931c4996ab15a0e911b9d5247d0edaa3fa426d5 Mon Sep 17 00:00:00 2001 From: Gaoyang Zhang Date: Sun, 2 May 2021 21:36:05 +0800 Subject: [PATCH 1/8] Fix constructor of struct qua to honor macro "GLM_FORCE_QUAT_DATA_WXYZ" Signed-off-by: Gaoyang Zhang --- glm/detail/type_quat.hpp | 2 +- glm/detail/type_quat.inl | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/glm/detail/type_quat.hpp b/glm/detail/type_quat.hpp index daeaa707..0148abe8 100644 --- a/glm/detail/type_quat.hpp +++ b/glm/detail/type_quat.hpp @@ -88,7 +88,7 @@ namespace glm // -- Explicit basic constructors -- GLM_FUNC_DECL GLM_CONSTEXPR qua(T s, vec<3, T, Q> const& v); - GLM_FUNC_DECL GLM_CONSTEXPR qua(T w, T x, T y, T z); + GLM_FUNC_DECL GLM_CONSTEXPR qua(T, T, T, T); // -- Conversion constructors -- diff --git a/glm/detail/type_quat.inl b/glm/detail/type_quat.inl index 1956b7a0..8c0176c0 100644 --- a/glm/detail/type_quat.inl +++ b/glm/detail/type_quat.inl @@ -141,10 +141,11 @@ namespace detail {} template - GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua::qua(T _w, T _x, T _y, T _z) # ifdef GLM_FORCE_QUAT_DATA_WXYZ + GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua::qua(T _w, T _x, T _y, T _z) : w(_w), x(_x), y(_y), z(_z) # else + GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua::qua(T _x, T _y, T _z, T _w) : x(_x), y(_y), z(_z), w(_w) # endif {} From 37842c7400e89962e542804083d407a1b8020e27 Mon Sep 17 00:00:00 2001 From: Gaoyang Zhang Date: Mon, 3 May 2021 00:31:09 +0800 Subject: [PATCH 2/8] Fix construction of identity quaternion Signed-off-by: Gaoyang Zhang --- glm/detail/qualifier.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/glm/detail/qualifier.hpp b/glm/detail/qualifier.hpp index b6c9df0c..60887a0c 100644 --- a/glm/detail/qualifier.hpp +++ b/glm/detail/qualifier.hpp @@ -214,7 +214,11 @@ namespace detail { GLM_FUNC_QUALIFIER GLM_CONSTEXPR static genType identity() { +# ifdef GLM_FORCE_QUAT_DATA_WXYZ return genType(1, 0, 0, 0); +# else + return genType(0, 0, 0, 1); +# endif } }; From e800c41c0a6d79e038829b562cebe03768e4f365 Mon Sep 17 00:00:00 2001 From: Gaoyang Zhang Date: Mon, 3 May 2021 00:32:17 +0800 Subject: [PATCH 3/8] Fix test due to change of default constructor of qua Signed-off-by: Gaoyang Zhang --- test/core/core_cpp_constexpr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/core_cpp_constexpr.cpp b/test/core/core_cpp_constexpr.cpp index 3dc0a92b..37dc7a70 100644 --- a/test/core/core_cpp_constexpr.cpp +++ b/test/core/core_cpp_constexpr.cpp @@ -712,7 +712,7 @@ static int test_quat() { static_assert(glm::quat::length() == 4, "GLM: Failed constexpr"); static_assert(glm::quat(1.0f, glm::vec3(0.0f)).w > 0.0f, "GLM: Failed constexpr"); - static_assert(glm::quat(1.0f, 0.0f, 0.0f, 0.0f).w > 0.0f, "GLM: Failed constexpr"); + static_assert(glm::quat(0.0f, 0.0f, 0.0f, 1.0f).w > 0.0f, "GLM: Failed constexpr"); glm::quat constexpr Q = glm::identity(); static_assert(Q.x - glm::quat(1.0f, glm::vec3(0.0f)).x <= glm::epsilon(), "GLM: Failed constexpr"); From 43b81f49fc1e98cff69a63f67d77d1e02ed7e3cd Mon Sep 17 00:00:00 2001 From: Gaoyang Zhang Date: Thu, 6 May 2021 14:12:16 +0800 Subject: [PATCH 4/8] Revert "Fix test due to change of default constructor of qua" This reverts commit e800c41c0a6d79e038829b562cebe03768e4f365. --- test/core/core_cpp_constexpr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/core_cpp_constexpr.cpp b/test/core/core_cpp_constexpr.cpp index 37dc7a70..3dc0a92b 100644 --- a/test/core/core_cpp_constexpr.cpp +++ b/test/core/core_cpp_constexpr.cpp @@ -712,7 +712,7 @@ static int test_quat() { static_assert(glm::quat::length() == 4, "GLM: Failed constexpr"); static_assert(glm::quat(1.0f, glm::vec3(0.0f)).w > 0.0f, "GLM: Failed constexpr"); - static_assert(glm::quat(0.0f, 0.0f, 0.0f, 1.0f).w > 0.0f, "GLM: Failed constexpr"); + static_assert(glm::quat(1.0f, 0.0f, 0.0f, 0.0f).w > 0.0f, "GLM: Failed constexpr"); glm::quat constexpr Q = glm::identity(); static_assert(Q.x - glm::quat(1.0f, glm::vec3(0.0f)).x <= glm::epsilon(), "GLM: Failed constexpr"); From f6f3596a6b4ed76f77284bc316d7d39ba7b1d857 Mon Sep 17 00:00:00 2001 From: Gaoyang Zhang Date: Thu, 6 May 2021 14:12:22 +0800 Subject: [PATCH 5/8] Revert "Fix construction of identity quaternion" This reverts commit 37842c7400e89962e542804083d407a1b8020e27. --- glm/detail/qualifier.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/glm/detail/qualifier.hpp b/glm/detail/qualifier.hpp index 60887a0c..b6c9df0c 100644 --- a/glm/detail/qualifier.hpp +++ b/glm/detail/qualifier.hpp @@ -214,11 +214,7 @@ namespace detail { GLM_FUNC_QUALIFIER GLM_CONSTEXPR static genType identity() { -# ifdef GLM_FORCE_QUAT_DATA_WXYZ return genType(1, 0, 0, 0); -# else - return genType(0, 0, 0, 1); -# endif } }; From d573bf099aa7b56ed0f3b6fd89419a8f5e9f7098 Mon Sep 17 00:00:00 2001 From: Gaoyang Zhang Date: Thu, 6 May 2021 14:12:23 +0800 Subject: [PATCH 6/8] Revert "Fix constructor of struct qua to honor macro "GLM_FORCE_QUAT_DATA_WXYZ"" This reverts commit f931c4996ab15a0e911b9d5247d0edaa3fa426d5. --- glm/detail/type_quat.hpp | 2 +- glm/detail/type_quat.inl | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/glm/detail/type_quat.hpp b/glm/detail/type_quat.hpp index 0148abe8..daeaa707 100644 --- a/glm/detail/type_quat.hpp +++ b/glm/detail/type_quat.hpp @@ -88,7 +88,7 @@ namespace glm // -- Explicit basic constructors -- GLM_FUNC_DECL GLM_CONSTEXPR qua(T s, vec<3, T, Q> const& v); - GLM_FUNC_DECL GLM_CONSTEXPR qua(T, T, T, T); + GLM_FUNC_DECL GLM_CONSTEXPR qua(T w, T x, T y, T z); // -- Conversion constructors -- diff --git a/glm/detail/type_quat.inl b/glm/detail/type_quat.inl index 8c0176c0..1956b7a0 100644 --- a/glm/detail/type_quat.inl +++ b/glm/detail/type_quat.inl @@ -141,11 +141,10 @@ namespace detail {} template -# ifdef GLM_FORCE_QUAT_DATA_WXYZ 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) # else - GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua::qua(T _x, T _y, T _z, T _w) : x(_x), y(_y), z(_z), w(_w) # endif {} From 59ddeb7d1c5455cedbe29be31a086bb38449a6bb Mon Sep 17 00:00:00 2001 From: Gaoyang Zhang Date: Thu, 6 May 2021 13:58:27 +0800 Subject: [PATCH 7/8] Replace GLM_FORCE_QUAT_DATA_WXYZ with GLM_FORCE_QUAT_DATA_XYZW The default data layout for quat has been changed to w,x,y,z to agree with order of input parameters for quat's constructor. Signed-off-by: Gaoyang Zhang --- glm/detail/type_quat.hpp | 12 +++++----- glm/detail/type_quat.inl | 48 ++++++++++++++++++++-------------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/glm/detail/type_quat.hpp b/glm/detail/type_quat.hpp index daeaa707..3ac014d9 100644 --- a/glm/detail/type_quat.hpp +++ b/glm/detail/type_quat.hpp @@ -42,19 +42,19 @@ namespace glm # if GLM_LANG & GLM_LANG_CXXMS_FLAG union { -# ifdef GLM_FORCE_QUAT_DATA_WXYZ - struct { T w, x, y, z; }; -# else +# ifdef GLM_FORCE_QUAT_DATA_XYZW struct { T x, y, z, w; }; +# else + struct { T w, x, y, z; }; # endif typename detail::storage<4, T, detail::is_aligned::value>::type data; }; # else -# ifdef GLM_FORCE_QUAT_DATA_WXYZ - T w, x, y, z; -# else +# ifdef GLM_FORCE_QUAT_DATA_XYZW T x, y, z, w; +# else + T w, x, y, z; # endif # endif diff --git a/glm/detail/type_quat.inl b/glm/detail/type_quat.inl index 1956b7a0..f5966c9c 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_WXYZ - return (&w)[i]; -# else +# ifdef GLM_FORCE_QUAT_DATA_XYZW return (&x)[i]; +# else + return (&w)[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_WXYZ - return (&w)[i]; -# else +# ifdef GLM_FORCE_QUAT_DATA_XYZW return (&x)[i]; +# else + return (&w)[i]; # endif } @@ -99,10 +99,10 @@ namespace detail template GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua::qua() # if GLM_CONFIG_CTOR_INIT != GLM_CTOR_INIT_DISABLE -# ifdef GLM_FORCE_QUAT_DATA_WXYZ - : w(1), x(0), y(0), z(0) -# else +# ifdef GLM_FORCE_QUAT_DATA_XYZW : x(0), y(0), z(0), w(1) +# else + : w(1), x(0), y(0), z(0) # endif # endif {} @@ -111,10 +111,10 @@ namespace detail # if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE template GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua::qua(qua const& q) -# ifdef GLM_FORCE_QUAT_DATA_WXYZ - : w(q.w), x(q.x), y(q.y), z(q.z) -# else +# ifdef GLM_FORCE_QUAT_DATA_XYZW : x(q.x), y(q.y), z(q.z), w(q.w) +# else + : w(q.w), x(q.x), y(q.y), z(q.z) # 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_WXYZ - : w(q.w), x(q.x), y(q.y), z(q.z) -# else +# ifdef GLM_FORCE_QUAT_DATA_XYZW : x(q.x), y(q.y), z(q.z), w(q.w) +# else + : w(q.w), x(q.x), y(q.y), z(q.z) # endif {} @@ -133,19 +133,19 @@ namespace detail template GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua::qua(T s, vec<3, T, Q> const& v) -# ifdef GLM_FORCE_QUAT_DATA_WXYZ - : w(s), x(v.x), y(v.y), z(v.z) -# else +# ifdef GLM_FORCE_QUAT_DATA_XYZW : x(v.x), y(v.y), z(v.z), w(s) +# else + : w(s), x(v.x), y(v.y), z(v.z) # endif {} template 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) -# else +# ifdef GLM_FORCE_QUAT_DATA_XYZW : x(_x), y(_y), z(_z), w(_w) +# else + : w(_w), x(_x), y(_y), z(_z) # endif {} @@ -154,10 +154,10 @@ namespace detail template template GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua::qua(qua const& q) -# 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 +# 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 + : w(static_cast(q.w)), x(static_cast(q.x)), y(static_cast(q.y)), z(static_cast(q.z)) # endif {} From de7c83f1b6f3f252c13dc32a7e33e0688bcf1498 Mon Sep 17 00:00:00 2001 From: Gaoyang Zhang Date: Thu, 6 May 2021 14:01:41 +0800 Subject: [PATCH 8/8] Update test for GLM_FORCE_QUAT_DATA_XYZW Signed-off-by: Gaoyang Zhang --- test/core/CMakeLists.txt | 2 +- .../core/{core_force_quat_wxyz.cpp => core_force_quat_xyzw.cpp} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename test/core/{core_force_quat_wxyz.cpp => core_force_quat_xyzw.cpp} (78%) diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt index b8dd9683..6cd57b18 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_wxyz) +glmCreateTestGTC(core_force_quat_xyzw) 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_xyzw.cpp similarity index 78% rename from test/core/core_force_quat_wxyz.cpp rename to test/core/core_force_quat_xyzw.cpp index bcb57394..7d5281c2 100644 --- a/test/core/core_force_quat_wxyz.cpp +++ b/test/core/core_force_quat_xyzw.cpp @@ -1,4 +1,4 @@ -#define GLM_FORCE_QUAT_DATA_WXYZ +#define GLM_FORCE_QUAT_DATA_XYZW #define GLM_FORCE_INLINE #include