From 6ce6cd9e26a57a05c14f02dcf9b6639953bd85d6 Mon Sep 17 00:00:00 2001 From: RohacekD Date: Mon, 16 Nov 2020 20:04:06 +0100 Subject: [PATCH 1/2] Adding constexpr qualifier for dot product --- glm/detail/func_geometric.inl | 12 ++++++------ glm/geometric.hpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/glm/detail/func_geometric.inl b/glm/detail/func_geometric.inl index 9cde28fe..020f39c4 100644 --- a/glm/detail/func_geometric.inl +++ b/glm/detail/func_geometric.inl @@ -28,7 +28,7 @@ namespace detail template struct compute_dot, 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; } @@ -37,7 +37,7 @@ namespace detail template struct compute_dot, 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); return tmp.x + tmp.y; @@ -47,7 +47,7 @@ namespace detail template struct compute_dot, 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); return tmp.x + tmp.y + tmp.z; @@ -57,7 +57,7 @@ namespace detail template struct compute_dot, 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); return (tmp.x + tmp.y) + (tmp.z + tmp.w); @@ -157,14 +157,14 @@ namespace detail // dot template - 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::is_iec559, "'dot' accepts only floating-point inputs"); return x * y; } template - GLM_FUNC_QUALIFIER T dot(vec const& x, vec const& y) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR T dot(vec const& x, vec const& y) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'dot' accepts only floating-point inputs"); return detail::compute_dot, T, detail::is_aligned::value>::call(x, y); diff --git a/glm/geometric.hpp b/glm/geometric.hpp index c068a3cb..4753bbcd 100644 --- a/glm/geometric.hpp +++ b/glm/geometric.hpp @@ -47,7 +47,7 @@ namespace glm /// @see GLSL dot man page /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions template - GLM_FUNC_DECL T dot(vec const& x, vec const& y); + GLM_FUNC_DECL GLM_CONSTEXPR T dot(vec const& x, vec const& y); /// Returns the cross product of x and y. /// From ae6fa0872f442460378a1e6994c3aee7a098f1dd Mon Sep 17 00:00:00 2001 From: RohacekD Date: Tue, 17 Nov 2020 16:58:12 +0100 Subject: [PATCH 2/2] Adding constexpr qualifier for cross product --- glm/detail/func_geometric.inl | 4 ++-- glm/geometric.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/glm/detail/func_geometric.inl b/glm/detail/func_geometric.inl index 020f39c4..404c9905 100644 --- a/glm/detail/func_geometric.inl +++ b/glm/detail/func_geometric.inl @@ -67,7 +67,7 @@ namespace detail template struct compute_cross { - GLM_FUNC_QUALIFIER static vec<3, T, Q> call(vec<3, T, Q> const& x, vec<3, T, Q> const& y) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec<3, T, Q> call(vec<3, T, Q> const& x, vec<3, T, Q> const& y) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'cross' accepts only floating-point inputs"); @@ -172,7 +172,7 @@ namespace detail // cross template - GLM_FUNC_QUALIFIER vec<3, T, Q> cross(vec<3, T, Q> const& x, vec<3, T, Q> const& y) + GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q> cross(vec<3, T, Q> const& x, vec<3, T, Q> const& y) { return detail::compute_cross::value>::call(x, y); } diff --git a/glm/geometric.hpp b/glm/geometric.hpp index 4753bbcd..b704f253 100644 --- a/glm/geometric.hpp +++ b/glm/geometric.hpp @@ -56,7 +56,7 @@ namespace glm /// @see GLSL cross man page /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions template - GLM_FUNC_DECL vec<3, T, Q> cross(vec<3, T, Q> const& x, vec<3, T, Q> const& y); + GLM_FUNC_DECL GLM_CONSTEXPR vec<3, T, Q> cross(vec<3, T, Q> const& x, vec<3, T, Q> const& y); /// Returns a vector in the same direction as x but with length of 1. /// According to issue 10 GLSL 1.10 specification, if length(x) == 0 then result is undefined and generate an error.