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_common.inl b/glm/detail/func_common.inl index 65304a45..a788eb4c 100644 --- a/glm/detail/func_common.inl +++ b/glm/detail/func_common.inl @@ -70,6 +70,8 @@ namespace detail { GLM_FUNC_QUALIFIER static vecType call(vecType const & x, vecType const & y, vecType const & a) { + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'mix' only accept floating-point inputs for the interpolator a"); + return vecType(vecType(x) + a * vecType(y - x)); } }; @@ -91,6 +93,8 @@ namespace detail { GLM_FUNC_QUALIFIER static vecType call(vecType const & x, vecType const & y, U const & a) { + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'mix' only accept floating-point inputs for the interpolator a"); + return vecType(vecType(x) + a * vecType(y - x)); } }; @@ -109,6 +113,8 @@ namespace detail { GLM_FUNC_QUALIFIER static T call(T const & x, T const & y, U const & a) { + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'mix' only accept floating-point inputs for the interpolator a"); + return static_cast(static_cast(x) + a * static_cast(y - x)); } }; 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 a1403202..08f3ba4c 100644 --- a/glm/detail/func_exponential.inl +++ b/glm/detail/func_exponential.inl @@ -31,8 +31,52 @@ #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