diff --git a/doc/glm.docx b/doc/glm.docx index 8db44eac..7665f6ea 100644 Binary files a/doc/glm.docx and b/doc/glm.docx differ diff --git a/glm/detail/_vectorize.hpp b/glm/detail/_vectorize.hpp index 840e3530..7982e4eb 100644 --- a/glm/detail/_vectorize.hpp +++ b/glm/detail/_vectorize.hpp @@ -33,6 +33,89 @@ #include "type_vec3.hpp" #include "type_vec4.hpp" +namespace glm{ +namespace detail +{ + template class vecType> + struct functor1{}; + + template + struct functor1 + { + GLM_FUNC_QUALIFIER static tvec1 call(T (*Func) (T x), tvec1 const & v) + { + return tvec1(Func(v.x)); + } + }; + + template + struct functor1 + { + GLM_FUNC_QUALIFIER static tvec2 call(T (*Func) (T x), tvec2 const & v) + { + return tvec2(Func(v.x), Func(v.y)); + } + }; + + template + struct functor1 + { + GLM_FUNC_QUALIFIER static tvec3 call(T (*Func) (T x), tvec3 const & v) + { + return tvec3(Func(v.x), Func(v.y), Func(v.z)); + } + }; + + template + struct functor1 + { + GLM_FUNC_QUALIFIER static tvec4 call(T (*Func) (T x), tvec4 const & v) + { + return tvec4(Func(v.x), Func(v.y), Func(v.z), Func(v.w)); + } + }; + + template class vecType> + struct functor2{}; + + template + struct functor2 + { + GLM_FUNC_QUALIFIER static tvec1 call(T (*Func) (T x, T y), tvec1 const & a, tvec1 const & b) + { + return tvec1(Func(a.x, b.x)); + } + }; + + template + struct functor2 + { + GLM_FUNC_QUALIFIER static tvec2 call(T (*Func) (T x, T y), tvec2 const & a, tvec2 const & b) + { + return tvec2(Func(a.x, b.x), Func(a.y, b.y)); + } + }; + + template + struct functor2 + { + GLM_FUNC_QUALIFIER static tvec3 call(T (*Func) (T x, T y), tvec3 const & a, tvec3 const & b) + { + return tvec3(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z)); + } + }; + + template + struct functor2 + { + GLM_FUNC_QUALIFIER static tvec4 call(T (*Func) (T x, T y), tvec4 const & a, tvec4 const & b) + { + return tvec4(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z), Func(a.w, b.w)); + } + }; +}//namespace detail +}//namespace glm + #define VECTORIZE1_VEC(func) \ template \ GLM_FUNC_QUALIFIER tvec1 func( \ diff --git a/glm/detail/func_common.hpp b/glm/detail/func_common.hpp index 879465d9..58a4d8ae 100644 --- a/glm/detail/func_common.hpp +++ b/glm/detail/func_common.hpp @@ -52,7 +52,7 @@ namespace glm /// @see GLSL abs man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template - GLM_FUNC_DECL genType abs(genType const & x); + GLM_FUNC_DECL genType abs(genType x); /// Returns 1.0 if x > 0, 0.0 if x == 0, or -1.0 if x < 0. /// @@ -61,7 +61,7 @@ namespace glm /// @see GLSL sign man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template - GLM_FUNC_DECL genType sign(genType const & x); + GLM_FUNC_DECL genType sign(genType x); /// Returns a value equal to the nearest integer that is less then or equal to x. /// @@ -70,7 +70,7 @@ namespace glm /// @see GLSL floor man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template - GLM_FUNC_DECL genType floor(genType const & x); + GLM_FUNC_DECL genType floor(genType x); /// Returns a value equal to the nearest integer to x /// whose absolute value is not larger than the absolute value of x. @@ -80,7 +80,7 @@ namespace glm /// @see GLSL trunc man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template - GLM_FUNC_DECL genType trunc(genType const & x); + GLM_FUNC_DECL genType trunc(genType x); /// Returns a value equal to the nearest integer to x. /// The fraction 0.5 will round in a direction chosen by the @@ -93,7 +93,7 @@ namespace glm /// @see GLSL round man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template - GLM_FUNC_DECL genType round(genType const & x); + GLM_FUNC_DECL genType round(genType x); /// Returns a value equal to the nearest integer to x. /// A fractional part of 0.5 will round toward the nearest even @@ -105,7 +105,7 @@ namespace glm /// @see GLSL 4.20.8 specification, section 8.3 Common Functions /// @see New round to even technique template - GLM_FUNC_DECL genType roundEven(genType const & x); + GLM_FUNC_DECL genType roundEven(genType x); /// Returns a value equal to the nearest integer /// that is greater than or equal to x. @@ -115,7 +115,7 @@ namespace glm /// @see GLSL ceil man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template - GLM_FUNC_DECL genType ceil(genType const & x); + GLM_FUNC_DECL genType ceil(genType x); /// Return x - floor(x). /// @@ -124,7 +124,7 @@ namespace glm /// @see GLSL fract man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template - GLM_FUNC_DECL genType fract(genType const & x); + GLM_FUNC_DECL genType fract(genType x); /// Modulus. Returns x - y * floor(x / y) /// for each component in x using the floating point value y. @@ -134,9 +134,7 @@ namespace glm /// @see GLSL mod man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template - GLM_FUNC_DECL genType mod( - genType const & x, - genType const & y); + GLM_FUNC_DECL genType mod(genType x, genType y); /// Modulus. Returns x - y * floor(x / y) /// for each component in x using the floating point value y. @@ -146,9 +144,7 @@ namespace glm /// @see GLSL mod man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template - GLM_FUNC_DECL genType mod( - genType const & x, - typename genType::value_type const & y); + GLM_FUNC_DECL genType mod(genType const & x, typename genType::value_type const & y); /// Returns the fractional part of x and sets i to the integer /// part (as a whole number floating point value). Both the @@ -160,9 +156,7 @@ namespace glm /// @see GLSL modf man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template - GLM_FUNC_DECL genType modf( - genType const & x, - genType & i); + GLM_FUNC_DECL genType modf(genType const & x, genType & i); /// Returns y if y < x; otherwise, it returns x. /// @@ -171,14 +165,10 @@ namespace glm /// @see GLSL min man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template - GLM_FUNC_DECL genType min( - genType const & x, - genType const & y); + GLM_FUNC_DECL genType min(genType x, genType y); template - GLM_FUNC_DECL genType min( - genType const & x, - typename genType::value_type const & y); + GLM_FUNC_DECL genType min(genType const & x, typename genType::value_type const & y); /// Returns y if x < y; otherwise, it returns x. /// @@ -187,14 +177,10 @@ namespace glm /// @see GLSL max man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template - GLM_FUNC_DECL genType max( - genType const & x, - genType const & y); + GLM_FUNC_DECL genType max(genType x, genType y); template - GLM_FUNC_DECL genType max( - genType const & x, - typename genType::value_type const & y); + GLM_FUNC_DECL genType max(genType const & x, typename genType::value_type const & y); /// Returns min(max(x, minVal), maxVal) for each component in x /// using the floating-point values minVal and maxVal. @@ -204,16 +190,10 @@ namespace glm /// @see GLSL clamp man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template - GLM_FUNC_DECL genType clamp( - genType const & x, - genType const & minVal, - genType const & maxVal); + GLM_FUNC_DECL genType clamp(genType const & x, genType const & minVal, genType const & maxVal); template - GLM_FUNC_DECL genType clamp( - genType const & x, - typename genType::value_type const & minVal, - typename genType::value_type const & maxVal); + GLM_FUNC_DECL genType clamp(genType const & x, typename genType::value_type const & minVal, typename genType::value_type const & maxVal); /// If genTypeU is a floating scalar or vector: /// Returns x * (1.0 - a) + y * a, i.e., the linear blend of @@ -258,40 +238,27 @@ namespace glm /// glm::vec4 u = glm::mix(g, h, r); // Interpolations can be perform per component with a vector for the last parameter. /// @endcode template class vecType> - GLM_FUNC_DECL vecType mix( - vecType const & x, - vecType const & y, - vecType const & a); + GLM_FUNC_DECL vecType mix(vecType const & x, vecType const & y, vecType const & a); template class vecType> - GLM_FUNC_DECL vecType mix( - vecType const & x, - vecType const & y, - U const & a); + GLM_FUNC_DECL vecType mix(vecType const & x, vecType const & y, U const & a); template - GLM_FUNC_DECL genTypeT mix( - genTypeT const & x, - genTypeT const & y, - genTypeU const & a); + GLM_FUNC_DECL genTypeT mix(genTypeT const & x, genTypeT const & y, genTypeU const & a); /// Returns 0.0 if x < edge, otherwise it returns 1.0 for each component of a genType. /// /// @see GLSL step man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template - GLM_FUNC_DECL genType step( - genType const & edge, - genType const & x); + GLM_FUNC_DECL genType step(genType const & edge, genType const & x); /// Returns 0.0 if x < edge, otherwise it returns 1.0. /// /// @see GLSL step man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template