Fixed quaternion componant order: w, {x, y, z} #916

This commit is contained in:
Christophe 2019-07-12 19:19:10 +02:00
parent 8c5fde6c8f
commit f5381ef536
5 changed files with 17 additions and 27 deletions

View File

@ -1,15 +1,5 @@
/// @ref gtc_quaternion
/// @file glm/gtc/quaternion.hpp
///
/// @see core (dependence)
/// @see gtc_constants (dependence)
///
/// @defgroup gtc_quaternion GLM_GTC_quaternion
/// @ingroup gtc
///
/// Include <glm/gtc/quaternion.hpp> to use the features of this extension.
///
/// Defines a templated quaternion type and several quaternion operations.
/// @ref core
/// @file glm/detail/type_quat.hpp
#pragma once
@ -25,9 +15,6 @@
namespace glm
{
/// @addtogroup gtc_quaternion
/// @{
template<typename T, qualifier Q>
struct qua
{
@ -55,7 +42,7 @@ namespace glm
# if GLM_LANG & GLM_LANG_CXXMS_FLAG
union
{
struct { T x, y, z, w;};
struct { T w, x, y, z;};
typename detail::storage<4, T, detail::is_aligned<Q>::value>::type data;
};
@ -76,6 +63,7 @@ namespace glm
// -- Component accesses --
typedef length_t length_type;
/// Return the count of components of a quaternion
GLM_FUNC_DECL static GLM_CONSTEXPR length_type length(){return 4;}
@ -183,8 +171,8 @@ namespace glm
template<typename T, qualifier Q>
GLM_FUNC_DECL GLM_CONSTEXPR bool operator!=(qua<T, Q> const& q1, qua<T, Q> const& q2);
/// @}
} //namespace glm
#ifndef GLM_EXTERNAL_TEMPLATE
#include "type_quat.inl"
#endif//GLM_EXTERNAL_TEMPLATE

View File

@ -17,7 +17,7 @@ namespace detail
{
static GLM_FUNC_QUALIFIER T call(qua<T, Q> const& a, qua<T, Q> const& b)
{
vec<4, T, Q> tmp(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w);
vec<4, T, Q> tmp(a.w * b.w, a.x * b.x, a.y * b.y, a.z * b.z);
return (tmp.x + tmp.y) + (tmp.z + tmp.w);
}
};
@ -74,14 +74,14 @@ 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());
return (&x)[i];
return (&w)[i];
}
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());
return (&x)[i];
return (&w)[i];
}
// -- Implicit basic constructors --

View File

@ -84,8 +84,9 @@ namespace glm
// -- Component accesses --
/// Return the count of components of the vector
typedef length_t length_type;
/// Return the count of components of the vector
GLM_FUNC_DECL static GLM_CONSTEXPR length_type length(){return 4;}
GLM_FUNC_DECL GLM_CONSTEXPR T & operator[](length_type i);

View File

@ -450,10 +450,10 @@ namespace detail
LiteralStr, LiteralStr, LiteralStr, LiteralStr));
return detail::format(FormatStr.c_str(),
static_cast<typename cast<T>::value_type>(x[3]),
static_cast<typename cast<T>::value_type>(x[0]),
static_cast<typename cast<T>::value_type>(x[1]),
static_cast<typename cast<T>::value_type>(x[2]));
static_cast<typename cast<T>::value_type>(x[2]),
static_cast<typename cast<T>::value_type>(x[3]));
}
};
@ -470,14 +470,14 @@ namespace detail
LiteralStr, LiteralStr, LiteralStr, LiteralStr));
return detail::format(FormatStr.c_str(),
static_cast<typename cast<T>::value_type>(x.real[3]),
static_cast<typename cast<T>::value_type>(x.real[0]),
static_cast<typename cast<T>::value_type>(x.real[1]),
static_cast<typename cast<T>::value_type>(x.real[2]),
static_cast<typename cast<T>::value_type>(x.dual[3]),
static_cast<typename cast<T>::value_type>(x.real[3]),
static_cast<typename cast<T>::value_type>(x.dual[0]),
static_cast<typename cast<T>::value_type>(x.dual[1]),
static_cast<typename cast<T>::value_type>(x.dual[2]));
static_cast<typename cast<T>::value_type>(x.dual[2]),
static_cast<typename cast<T>::value_type>(x.dual[3]));
}
};

View File

@ -65,6 +65,7 @@ glm::mat4 camera(float Translate, glm::vec2 const& Rotate)
- Fixed .natvis as structs renamed #915
- Fixed ldexp and frexp declaration #895
- Fixed missing const to quaternion conversion operators #890
- Fixed quaternion componant order: w, {x, y, z} #916
### [GLM 0.9.9.5](https://github.com/g-truc/glm/releases/tag/0.9.9.5) - 2019-04-01
#### Fixes: