Adding constexpr qualifier for dot product

master
RohacekD ago%!(EXTRA string=5 years)
parent 596577f200
commit 6ce6cd9e26
  1. 12
      glm/detail/func_geometric.inl
  2. 2
      glm/geometric.hpp

@ -28,7 +28,7 @@ namespace detail
template<typename T, qualifier Q, bool Aligned> template<typename T, qualifier Q, bool Aligned>
struct compute_dot<vec<1, T, Q>, T, Aligned> struct compute_dot<vec<1, T, Q>, T, Aligned>
{ {
GLM_FUNC_QUALIFIER static T call(vec<1, T, Q> const& a, vec<1, T, Q> const& b) GLM_FUNC_QUALIFIER GLM_CONSTEXPR static T call(vec<1, T, Q> const& a, vec<1, T, Q> const& b)
{ {
return a.x * b.x; return a.x * b.x;
} }
@ -37,7 +37,7 @@ namespace detail
template<typename T, qualifier Q, bool Aligned> template<typename T, qualifier Q, bool Aligned>
struct compute_dot<vec<2, T, Q>, T, Aligned> struct compute_dot<vec<2, T, Q>, T, Aligned>
{ {
GLM_FUNC_QUALIFIER static T call(vec<2, T, Q> const& a, vec<2, T, Q> const& b) GLM_FUNC_QUALIFIER GLM_CONSTEXPR static T call(vec<2, T, Q> const& a, vec<2, T, Q> const& b)
{ {
vec<2, T, Q> tmp(a * b); vec<2, T, Q> tmp(a * b);
return tmp.x + tmp.y; return tmp.x + tmp.y;
@ -47,7 +47,7 @@ namespace detail
template<typename T, qualifier Q, bool Aligned> template<typename T, qualifier Q, bool Aligned>
struct compute_dot<vec<3, T, Q>, T, Aligned> struct compute_dot<vec<3, T, Q>, T, Aligned>
{ {
GLM_FUNC_QUALIFIER static T call(vec<3, T, Q> const& a, vec<3, T, Q> const& b) GLM_FUNC_QUALIFIER GLM_CONSTEXPR static T call(vec<3, T, Q> const& a, vec<3, T, Q> const& b)
{ {
vec<3, T, Q> tmp(a * b); vec<3, T, Q> tmp(a * b);
return tmp.x + tmp.y + tmp.z; return tmp.x + tmp.y + tmp.z;
@ -57,7 +57,7 @@ namespace detail
template<typename T, qualifier Q, bool Aligned> template<typename T, qualifier Q, bool Aligned>
struct compute_dot<vec<4, T, Q>, T, Aligned> struct compute_dot<vec<4, T, Q>, T, Aligned>
{ {
GLM_FUNC_QUALIFIER static T call(vec<4, T, Q> const& a, vec<4, T, Q> const& b) GLM_FUNC_QUALIFIER GLM_CONSTEXPR static T call(vec<4, T, Q> const& a, vec<4, T, Q> const& b)
{ {
vec<4, T, Q> tmp(a * b); vec<4, T, Q> tmp(a * b);
return (tmp.x + tmp.y) + (tmp.z + tmp.w); return (tmp.x + tmp.y) + (tmp.z + tmp.w);
@ -157,14 +157,14 @@ namespace detail
// dot // dot
template<typename T> template<typename T>
GLM_FUNC_QUALIFIER T dot(T x, T y) GLM_FUNC_QUALIFIER GLM_CONSTEXPR T dot(T x, T 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 x * y; return x * y;
} }
template<length_t L, typename T, qualifier Q> template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER T dot(vec<L, T, Q> const& x, vec<L, T, Q> const& y) GLM_FUNC_QUALIFIER GLM_CONSTEXPR T dot(vec<L, T, Q> const& x, vec<L, 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<vec<L, T, Q>, T, detail::is_aligned<Q>::value>::call(x, y); return detail::compute_dot<vec<L, T, Q>, T, detail::is_aligned<Q>::value>::call(x, y);

@ -47,7 +47,7 @@ namespace glm
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/dot.xml">GLSL dot man page</a> /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/dot.xml">GLSL dot man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a> /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
template<length_t L, typename T, qualifier Q> template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL T dot(vec<L, T, Q> const& x, vec<L, T, Q> const& y); GLM_FUNC_DECL GLM_CONSTEXPR T dot(vec<L, T, Q> const& x, vec<L, T, Q> const& y);
/// Returns the cross product of x and y. /// Returns the cross product of x and y.
/// ///

Loading…
Cancel
Save