Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quaternion: Revert #1069 #1183

Merged
merged 2 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions glm/detail/type_quat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ 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<Q>::value>::type data;
};
# else
# ifdef GLM_FORCE_QUAT_DATA_XYZW
T x, y, z, w;
# else
# ifdef GLM_FORCE_QUAT_DATA_WXYZ
T w, x, y, z;
# else
T x, y, z, w;
# endif
# endif

Expand Down
51 changes: 25 additions & 26 deletions glm/detail/type_quat.inl
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,21 @@ namespace detail
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T & qua<T, Q>::operator[](typename qua<T, Q>::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
}

template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T const& qua<T, Q>::operator[](typename qua<T, Q>::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
}

Expand All @@ -99,10 +99,10 @@ namespace detail
template<typename T, qualifier Q>
GLM_DEFAULTED_DEFAULT_CTOR_QUALIFIER GLM_CONSTEXPR qua<T, Q>::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
{}
Expand All @@ -111,43 +111,42 @@ namespace detail
# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE
template<typename T, qualifier Q>
GLM_DEFAULTED_FUNC_QUALIFIER GLM_CONSTEXPR qua<T, Q>::qua(qua<T, Q> 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

template<typename T, qualifier Q>
template<qualifier P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua<T, Q>::qua(qua<T, P> 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
{}

// -- Explicit basic constructors --

template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua<T, Q>::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 <typename T, qualifier Q>
# ifdef GLM_FORCE_QUAT_DATA_XYZW
GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua<T, Q>::qua(T _x, T _y, T _z, T _w)
: x(_x), y(_y), z(_z), w(_w)
# else
GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua<T, Q>::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 <typename T, qualifier Q>
Expand All @@ -164,10 +163,10 @@ namespace detail
template<typename T, qualifier Q>
template<typename U, qualifier P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua<T, Q>::qua(qua<U, P> const& q)
# ifdef GLM_FORCE_QUAT_DATA_XYZW
: x(static_cast<T>(q.x)), y(static_cast<T>(q.y)), z(static_cast<T>(q.z)), w(static_cast<T>(q.w))
# else
# ifdef GLM_FORCE_QUAT_DATA_WXYZ
: w(static_cast<T>(q.w)), x(static_cast<T>(q.x)), y(static_cast<T>(q.y)), z(static_cast<T>(q.z))
# else
: x(static_cast<T>(q.x)), y(static_cast<T>(q.y)), z(static_cast<T>(q.z)), w(static_cast<T>(q.w))
# endif
{}

Expand Down
2 changes: 1 addition & 1 deletion test/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define GLM_FORCE_QUAT_DATA_XYZW
#define GLM_FORCE_QUAT_DATA_WXYZ
#define GLM_FORCE_INLINE

#include <glm/glm.hpp>
Expand Down