Adding constexpr for dot, cross and inverse quaternion functions

This commit is contained in:
RohacekD 2020-12-08 01:27:49 +01:00 committed by Dominik Roháček
parent a73987d863
commit 7eef79c9c7
4 changed files with 6 additions and 6 deletions

View File

@ -103,7 +103,7 @@ namespace glm
/// @tparam T A floating-point scalar type /// @tparam T A floating-point scalar type
/// @tparam Q A value from qualifier enum /// @tparam Q A value from qualifier enum
template<typename T, qualifier Q> template<typename T, qualifier Q>
GLM_FUNC_DECL qua<T, Q> inverse(qua<T, Q> const& q); GLM_FUNC_DECL GLM_CONSTEXPR qua<T, Q> inverse(qua<T, Q> const& q);
/// Returns true if x holds a NaN (not a number) /// Returns true if x holds a NaN (not a number)
/// representation in the underlying implementation's set of /// representation in the underlying implementation's set of

View File

@ -116,7 +116,7 @@ namespace glm
} }
template<typename T, qualifier Q> template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER qua<T, Q> inverse(qua<T, Q> const& q) GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua<T, Q> inverse(qua<T, Q> const& q)
{ {
return conjugate(q) / dot(q, q); return conjugate(q) / dot(q, q);
} }

View File

@ -53,7 +53,7 @@ namespace glm
/// ///
/// @see ext_quaternion_geometric /// @see ext_quaternion_geometric
template<typename T, qualifier Q> template<typename T, qualifier Q>
GLM_FUNC_DECL T dot(qua<T, Q> const& x, qua<T, Q> const& y); GLM_FUNC_DECL GLM_CONSTEXPR T dot(qua<T, Q> const& x, qua<T, Q> const& y);
/// Compute a cross product. /// Compute a cross product.
/// ///
@ -62,7 +62,7 @@ namespace glm
/// ///
/// @see ext_quaternion_geometric /// @see ext_quaternion_geometric
template<typename T, qualifier Q> template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER qua<T, Q> cross(qua<T, Q> const& q1, qua<T, Q> const& q2); GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua<T, Q> cross(qua<T, Q> const& q1, qua<T, Q> const& q2);
/// @} /// @}
} //namespace glm } //namespace glm

View File

@ -1,7 +1,7 @@
namespace glm namespace glm
{ {
template<typename T, qualifier Q> template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER T dot(qua<T, Q> const& x, qua<T, Q> const& y) GLM_FUNC_QUALIFIER GLM_CONSTEXPR T dot(qua<T, Q> const& x, qua<T, Q> const& y)
{ {
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'dot' accepts only floating-point inputs"); GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'dot' accepts only floating-point inputs");
return detail::compute_dot<qua<T, Q>, T, detail::is_aligned<Q>::value>::call(x, y); return detail::compute_dot<qua<T, Q>, T, detail::is_aligned<Q>::value>::call(x, y);
@ -24,7 +24,7 @@ namespace glm
} }
template<typename T, qualifier Q> template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER qua<T, Q> cross(qua<T, Q> const& q1, qua<T, Q> const& q2) GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua<T, Q> cross(qua<T, Q> const& q1, qua<T, Q> const& q2)
{ {
return qua<T, Q>( return qua<T, Q>(
q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z, q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z,