From a310855d2352f3f8147fb7eb183b7e5d2b1c7eb1 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sat, 8 Feb 2014 13:34:40 +0100 Subject: [PATCH] Fixed undefined reference to fastInverseSqrt (#161) --- glm/detail/_vectorize.hpp | 24 ++++++++ glm/detail/func_exponential.inl | 97 ++++++++++++++----------------- glm/gtx/fast_square_root.hpp | 17 ++++-- glm/gtx/fast_square_root.inl | 11 +++- readme.txt | 1 + test/gtx/gtx_fast_square_root.cpp | 20 ++++++- 6 files changed, 109 insertions(+), 61 deletions(-) diff --git a/glm/detail/_vectorize.hpp b/glm/detail/_vectorize.hpp index 17ef1128..b653fa9f 100644 --- a/glm/detail/_vectorize.hpp +++ b/glm/detail/_vectorize.hpp @@ -29,10 +29,20 @@ #ifndef GLM_CORE_DETAIL_INCLUDED #define GLM_CORE_DETAIL_INCLUDED +#include "type_vec1.hpp" #include "type_vec2.hpp" #include "type_vec3.hpp" #include "type_vec4.hpp" +#define VECTORIZE1_VEC(func) \ + template \ + GLM_FUNC_QUALIFIER detail::tvec1 func( \ + detail::tvec1 const & v) \ + { \ + return detail::tvec1( \ + func(v.x)); \ + } + #define VECTORIZE2_VEC(func) \ template \ GLM_FUNC_QUALIFIER detail::tvec2 func( \ @@ -67,10 +77,23 @@ } #define VECTORIZE_VEC(func) \ + VECTORIZE1_VEC(func) \ VECTORIZE2_VEC(func) \ VECTORIZE3_VEC(func) \ VECTORIZE4_VEC(func) +#define VECTORIZE1_VEC_SCA(func) \ + template \ + GLM_FUNC_QUALIFIER detail::tvec1 func \ + ( \ + detail::tvec1 const & x, \ + T const & y \ + ) \ + { \ + return detail::tvec1( \ + func(x.x, y)); \ + } + #define VECTORIZE2_VEC_SCA(func) \ template \ GLM_FUNC_QUALIFIER detail::tvec2 func \ @@ -114,6 +137,7 @@ } #define VECTORIZE_VEC_SCA(func) \ + VECTORIZE1_VEC_SCA(func) \ VECTORIZE2_VEC_SCA(func) \ VECTORIZE3_VEC_SCA(func) \ VECTORIZE4_VEC_SCA(func) diff --git a/glm/detail/func_exponential.inl b/glm/detail/func_exponential.inl index a1403202..c4dbd681 100644 --- a/glm/detail/func_exponential.inl +++ b/glm/detail/func_exponential.inl @@ -31,8 +31,51 @@ #include #include -namespace glm +namespace glm{ +namespace detail { + template + struct compute_log2 + { + template + T operator() (T const & Value) const; + }; + + template <> + struct compute_log2 + { + template + T operator() (T const & Value) const + { + return static_cast(::std::log(Value)) * static_cast(1.4426950408889634073599246810019); + } + }; + + template