From 7ce6df407822319338a4067ee1adfc65eadf11f3 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sat, 8 Feb 2014 20:21:24 +0100 Subject: [PATCH] Fixed sqrt ambiguity --- glm/detail/func_exponential.hpp | 11 ++++-- glm/detail/func_exponential.inl | 68 +++++++++++++++++++++++++++------ 2 files changed, 63 insertions(+), 16 deletions(-) diff --git a/glm/detail/func_exponential.hpp b/glm/detail/func_exponential.hpp index 5f016161..93820870 100644 --- a/glm/detail/func_exponential.hpp +++ b/glm/detail/func_exponential.hpp @@ -98,8 +98,8 @@ namespace glm /// /// @see GLSL log2 man page /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions - template - GLM_FUNC_DECL genType log2(genType const & x); + template + GLM_FUNC_DECL genType log2(genType x); /// Returns the positive square root of x. /// @@ -108,9 +108,12 @@ namespace glm /// /// @see GLSL sqrt man page /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions - template - GLM_FUNC_DECL genType sqrt(genType const & x); + //template + //GLM_FUNC_DECL genType sqrt(genType const & x); + template class vecType> + GLM_FUNC_DECL vecType sqrt(vecType const & x); + /// Returns the reciprocal of the positive square root of x. /// /// @param x inversesqrt function is defined for input values of x defined in the range [0, inf+) in the limit of the type precision. diff --git a/glm/detail/func_exponential.inl b/glm/detail/func_exponential.inl index 805ce163..20fa45c9 100644 --- a/glm/detail/func_exponential.inl +++ b/glm/detail/func_exponential.inl @@ -158,21 +158,65 @@ namespace detail VECTORIZE_VEC(log2) - // sqrt - template - GLM_FUNC_QUALIFIER genType sqrt - ( - genType const & x - ) + namespace detail { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'sqrt' only accept floating-point inputs"); - - assert(x >= genType(0)); - - return std::sqrt(x); + template