Templatize unary conversions from glm types to quat and dualquat

This commit is contained in:
Jesse Talavera-Greenberg 2016-03-06 19:43:43 -05:00
parent 7ed3456ca3
commit b60047fa16
4 changed files with 23 additions and 10 deletions

View File

@ -147,9 +147,14 @@ namespace glm
GLM_FUNC_DECL tquat(tvec3<T, P> const & u, tvec3<T, P> const & v); GLM_FUNC_DECL tquat(tvec3<T, P> const & u, tvec3<T, P> const & v);
/// Build a quaternion from euler angles (pitch, yaw, roll), in radians. /// Build a quaternion from euler angles (pitch, yaw, roll), in radians.
GLM_FUNC_DECL GLM_EXPLICIT tquat(tvec3<T, P> const & eulerAngles); template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tquat(tmat3x3<T, P> const & m); GLM_FUNC_DECL GLM_EXPLICIT tquat(tvec3<U, Q> const & eulerAngles);
GLM_FUNC_DECL GLM_EXPLICIT tquat(tmat4x4<T, P> const & m);
template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tquat(tmat3x3<U, Q> const & m);
template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tquat(tmat4x4<U, Q> const & m);
// -- Unary arithmetic operators -- // -- Unary arithmetic operators --

View File

@ -240,7 +240,8 @@ namespace detail
} }
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tvec3<T, P> const & eulerAngle) template <typename U, precision Q>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tvec3<U, Q> const & eulerAngle)
{ {
tvec3<T, P> c = glm::cos(eulerAngle * T(0.5)); tvec3<T, P> c = glm::cos(eulerAngle * T(0.5));
tvec3<T, P> s = glm::sin(eulerAngle * T(0.5)); tvec3<T, P> s = glm::sin(eulerAngle * T(0.5));
@ -252,13 +253,15 @@ namespace detail
} }
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tmat3x3<T, P> const & m) template <typename U, precision Q>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tmat3x3<U, Q> const & m)
{ {
*this = quat_cast(m); *this = quat_cast(m);
} }
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tmat4x4<T, P> const & m) template <typename U, precision Q>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat(tmat4x4<U, Q> const & m)
{ {
*this = quat_cast(m); *this = quat_cast(m);
} }

View File

@ -112,8 +112,11 @@ namespace glm
template <typename U, precision Q> template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tdualquat(tdualquat<U, Q> const & q); GLM_FUNC_DECL GLM_EXPLICIT tdualquat(tdualquat<U, Q> const & q);
GLM_FUNC_DECL GLM_EXPLICIT tdualquat(tmat2x4<T, P> const & holder_mat); template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tdualquat(tmat3x4<T, P> const & aug_mat); GLM_FUNC_DECL GLM_EXPLICIT tdualquat(tmat2x4<U, Q> const & holder_mat);
template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tdualquat(tmat3x4<U, Q> const & aug_mat);
// -- Unary arithmetic operators -- // -- Unary arithmetic operators --

View File

@ -141,13 +141,15 @@ namespace glm
{} {}
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tdualquat<T, P>::tdualquat(tmat2x4<T, P> const & m) template <typename U, precision Q>
GLM_FUNC_QUALIFIER tdualquat<T, P>::tdualquat(tmat2x4<U, Q> const & m)
{ {
*this = dualquat_cast(m); *this = dualquat_cast(m);
} }
template <typename T, precision P> template <typename T, precision P>
GLM_FUNC_QUALIFIER tdualquat<T, P>::tdualquat(tmat3x4<T, P> const & m) template <typename U, precision Q>
GLM_FUNC_QUALIFIER tdualquat<T, P>::tdualquat(tmat3x4<U, Q> const & m)
{ {
*this = dualquat_cast(m); *this = dualquat_cast(m);
} }