From bf08a0e234746f1a67d99f8a1cc55e6bad466e20 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Mon, 20 Oct 2014 02:03:48 +0200 Subject: [PATCH] Replace function instanciations with macros by templates --- glm/detail/func_common.inl | 2 +- glm/detail/func_exponential.hpp | 27 ++-- glm/detail/func_exponential.inl | 109 +++++---------- glm/detail/func_geometric.hpp | 32 ++--- glm/detail/func_geometric.inl | 196 ++++----------------------- glm/detail/func_trigonometric.hpp | 61 ++++----- glm/detail/func_trigonometric.inl | 199 +++++++++++----------------- test/core/core_func_exponential.cpp | 3 +- 8 files changed, 196 insertions(+), 433 deletions(-) diff --git a/glm/detail/func_common.inl b/glm/detail/func_common.inl index 554424a6..74117ff3 100644 --- a/glm/detail/func_common.inl +++ b/glm/detail/func_common.inl @@ -211,7 +211,7 @@ namespace detail template class vecType> GLM_FUNC_QUALIFIER vecType round(vecType const & x) { - return detail::functor1::call(::std::round, x); + return detail::functor1::call(round, x); } /* diff --git a/glm/detail/func_exponential.hpp b/glm/detail/func_exponential.hpp index 1e1f4418..2adcb8ec 100644 --- a/glm/detail/func_exponential.hpp +++ b/glm/detail/func_exponential.hpp @@ -54,8 +54,8 @@ namespace glm /// /// @see GLSL pow man page /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions - template - GLM_FUNC_DECL genType pow(genType const & base, genType const & exponent); + template class vecType> + GLM_FUNC_DECL vecType pow(vecType const & base, vecType const & exponent); /// Returns the natural exponentiation of x, i.e., e^x. /// @@ -64,8 +64,8 @@ namespace glm /// /// @see GLSL exp man page /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions - template - GLM_FUNC_DECL genType exp(genType const & x); + template class vecType> + GLM_FUNC_DECL vecType exp(vecType const & v); /// Returns the natural logarithm of x, i.e., /// returns the value y which satisfies the equation x = e^y. @@ -76,8 +76,8 @@ namespace glm /// /// @see GLSL log man page /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions - template - GLM_FUNC_DECL genType log(genType const & x); + template class vecType> + GLM_FUNC_DECL vecType log(vecType const & v); /// Returns 2 raised to the x power. /// @@ -86,8 +86,8 @@ namespace glm /// /// @see GLSL exp2 man page /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions - template - GLM_FUNC_DECL genType exp2(genType const & x); + template class vecType> + GLM_FUNC_DECL vecType exp2(vecType const & v); /// Returns the base 2 log of x, i.e., returns the value y, /// which satisfies the equation x = 2 ^ y. @@ -97,8 +97,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 x); + template class vecType> + GLM_FUNC_DECL vecType log2(vecType const & v); /// Returns the positive square root of x. /// @@ -109,9 +109,8 @@ namespace glm /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions //template //GLM_FUNC_DECL genType sqrt(genType const & x); - template class vecType> - GLM_FUNC_DECL vecType sqrt(vecType const & x); + GLM_FUNC_DECL vecType sqrt(vecType const & v); /// Returns the reciprocal of the positive square root of x. /// @@ -120,8 +119,8 @@ namespace glm /// /// @see GLSL inversesqrt man page /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions - template - GLM_FUNC_DECL genType inversesqrt(genType const & x); + template class vecType> + GLM_FUNC_DECL vecType inversesqrt(vecType const & v); /// @} }//namespace glm diff --git a/glm/detail/func_exponential.inl b/glm/detail/func_exponential.inl index a1d656f9..146ef5c9 100644 --- a/glm/detail/func_exponential.inl +++ b/glm/detail/func_exponential.inl @@ -36,19 +36,15 @@ namespace glm{ namespace detail { template - struct compute_log2 - { - template - T operator() (T const & Value) const; - }; + struct compute_log2{}; template <> struct compute_log2 { template - GLM_FUNC_QUALIFIER T operator() (T const & Value) const + GLM_FUNC_QUALIFIER T operator() (T Value) const { -# if(GLM_LANG & GLM_LANG_CXX11_FLAG) +# if GLM_LANG & GLM_LANG_CXX11_FLAG return std::log2(Value); # else return std::log(Value) * static_cast(1.4426950408889634073599246810019); @@ -84,28 +80,42 @@ namespace detail // pow using std::pow; - VECTORIZE_VEC_VEC(pow) + template class vecType> + GLM_FUNC_QUALIFIER vecType pow(vecType const & base, vecType const & exponent) + { + return detail::functor2::call(::std::pow, base, exponent); + } // exp using std::exp; - VECTORIZE_VEC(exp) + template class vecType> + GLM_FUNC_QUALIFIER vecType exp(vecType const & x) + { + return detail::functor1::call(::std::exp, x); + } // log using std::log; - VECTORIZE_VEC(log) + template class vecType> + GLM_FUNC_QUALIFIER vecType log(vecType const & x) + { + return detail::functor1::call(::std::log, x); + } //exp2, ln2 = 0.69314718055994530941723212145818f template - GLM_FUNC_QUALIFIER genType exp2(genType const & x) + GLM_FUNC_QUALIFIER genType exp2(genType x) { - GLM_STATIC_ASSERT( - std::numeric_limits::is_iec559, - "'exp2' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'exp2' only accept floating-point inputs"); return std::exp(static_cast(0.69314718055994530941723212145818) * x); } - VECTORIZE_VEC(exp2) + template class vecType> + GLM_FUNC_QUALIFIER vecType exp2(vecType const & x) + { + return detail::functor1::call(exp2, x); + } // log2, ln2 = 0.69314718055994530941723212145818f template @@ -118,79 +128,32 @@ namespace detail return detail::compute_log2::is_iec559>()(x); } - VECTORIZE_VEC(log2) - - namespace detail + template class vecType> + GLM_FUNC_QUALIFIER vecType log2(vecType const & x) { - template