diff --git a/glm/core/_swizzle.hpp b/glm/core/_swizzle.hpp index 61be1d6b..a46299b5 100644 --- a/glm/core/_swizzle.hpp +++ b/glm/core/_swizzle.hpp @@ -53,60 +53,60 @@ namespace glm namespace glm{ namespace detail { - // Internal class for implementing swizzle operators - template - struct _swizzle_base0 - { - typedef T value_type; + // Internal class for implementing swizzle operators + template + struct _swizzle_base0 + { + typedef T value_type; - protected: - value_type& elem (size_t i) { return (reinterpret_cast(_buffer))[i]; } - const value_type& elem (size_t i) const { return (reinterpret_cast(_buffer))[i]; } + protected: + value_type& elem (size_t i) { return (reinterpret_cast(_buffer))[i]; } + const value_type& elem (size_t i) const { return (reinterpret_cast(_buffer))[i]; } - // Use an opaque buffer to *ensure* the compiler doesn't call a constructor. - // The size 1 buffer is assumed to aligned to the actual members so that the - // elem() - char _buffer[1]; - }; + // Use an opaque buffer to *ensure* the compiler doesn't call a constructor. + // The size 1 buffer is assumed to aligned to the actual members so that the + // elem() + char _buffer[1]; + }; - template - struct _swizzle_base1 : public _swizzle_base0 - { - }; + template + struct _swizzle_base1 : public _swizzle_base0 + { + }; - template - struct _swizzle_base1 : public _swizzle_base0 - { - V operator ()() const { return V(this->elem(E0), this->elem(E1)); } - }; + template + struct _swizzle_base1 : public _swizzle_base0 + { + V operator ()() const { return V(this->elem(E0), this->elem(E1)); } + }; - template - struct _swizzle_base1 : public _swizzle_base0 - { - V operator ()() const { return V(this->elem(E0), this->elem(E1), this->elem(E2)); } - }; + template + struct _swizzle_base1 : public _swizzle_base0 + { + V operator ()() const { return V(this->elem(E0), this->elem(E1), this->elem(E2)); } + }; - template - struct _swizzle_base1 : public _swizzle_base0 - { - V operator ()() const { return V(this->elem(E0), this->elem(E1), this->elem(E2), this->elem(E3)); } - }; + template + struct _swizzle_base1 : public _swizzle_base0 + { + V operator ()() const { return V(this->elem(E0), this->elem(E1), this->elem(E2), this->elem(E3)); } + }; - // Internal class for implementing swizzle operators - /* - Template parameters: + // Internal class for implementing swizzle operators + /* + Template parameters: - ValueType = type of scalar values (e.g. float, double) - VecType = class the swizzle is applies to (e.g. tvec3) - N = number of components in the vector (e.g. 3) - E0...3 = what index the n-th element of this swizzle refers to in the unswizzled vec + ValueType = type of scalar values (e.g. float, double) + VecType = class the swizzle is applies to (e.g. tvec3) + N = number of components in the vector (e.g. 3) + E0...3 = what index the n-th element of this swizzle refers to in the unswizzled vec - DUPLICATE_ELEMENTS = 1 if there is a repeated element, 0 otherwise (used to specialize swizzles - containing duplicate elements so that they cannot be used as r-values). - */ - template - struct _swizzle_base2 : public _swizzle_base1 - { + DUPLICATE_ELEMENTS = 1 if there is a repeated element, 0 otherwise (used to specialize swizzles + containing duplicate elements so that they cannot be used as r-values). + */ + template + struct _swizzle_base2 : public _swizzle_base1 + { typedef VecType vec_type; typedef ValueType value_type; @@ -181,7 +181,7 @@ namespace detail for (int i = 0; i < N; ++i) op( (*this)[i], t[i] ); } - }; + }; // Specialization for swizzles containing duplicate elements. These cannot be modified. template @@ -322,33 +322,32 @@ namespace glm { _GLM_SWIZZLE_SCALAR_BINARY_OPERATOR_IMPLEMENTATION(-) _GLM_SWIZZLE_SCALAR_BINARY_OPERATOR_IMPLEMENTATION(*) - _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(+) _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(-) _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(*) _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(/) } - // - // Swizzles are distinct types from the unswizzled type. The below macros will - // provide template specializations for the swizzle types for the given functions - // so that the compiler does not have any ambiguity to choosing how to handle - // the function. - // - // The alternative is to use the operator()() when calling the function in order - // to explicitly convert the swizzled type to the unswizzled type. - // + // + // Swizzles are distinct types from the unswizzled type. The below macros will + // provide template specializations for the swizzle types for the given functions + // so that the compiler does not have any ambiguity to choosing how to handle + // the function. + // + // The alternative is to use the operator()() when calling the function in order + // to explicitly convert the swizzled type to the unswizzled type. + // - //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, abs); - //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, acos); - //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, acosh); - //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, all); - //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, any); - - //_GLM_SWIZZLE_FUNCTION_2_ARGS(value_type, dot); - //_GLM_SWIZZLE_FUNCTION_2_ARGS(vec_type, cross); - //_GLM_SWIZZLE_FUNCTION_2_ARGS(vec_type, step); - //_GLM_SWIZZLE_FUNCTION_2_ARGS_SCALAR(vec_type, mix); + //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, abs); + //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, acos); + //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, acosh); + //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, all); + //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, any); + + //_GLM_SWIZZLE_FUNCTION_2_ARGS(value_type, dot); + //_GLM_SWIZZLE_FUNCTION_2_ARGS(vec_type, cross); + //_GLM_SWIZZLE_FUNCTION_2_ARGS(vec_type, step); + //_GLM_SWIZZLE_FUNCTION_2_ARGS_SCALAR(vec_type, mix); } #define _GLM_SWIZZLE2_2_MEMBERS(T,P,E0,E1) \ diff --git a/glm/core/_vectorize.hpp b/glm/core/_vectorize.hpp index e69d8091..7e14cc17 100644 --- a/glm/core/_vectorize.hpp +++ b/glm/core/_vectorize.hpp @@ -27,37 +27,37 @@ /////////////////////////////////////////////////////////////////////////////////// #define VECTORIZE2_VEC(func) \ - template \ - GLM_FUNC_QUALIFIER detail::tvec2 func( \ + template \ + GLM_FUNC_QUALIFIER detail::tvec2 func( \ detail::tvec2 const & v) \ - { \ - return detail::tvec2( \ - func(v.x), \ - func(v.y)); \ - } + { \ + return detail::tvec2( \ + func(v.x), \ + func(v.y)); \ + } #define VECTORIZE3_VEC(func) \ - template \ - GLM_FUNC_QUALIFIER detail::tvec3 func( \ + template \ + GLM_FUNC_QUALIFIER detail::tvec3 func( \ detail::tvec3 const & v) \ - { \ - return detail::tvec3( \ - func(v.x), \ - func(v.y), \ - func(v.z)); \ - } + { \ + return detail::tvec3( \ + func(v.x), \ + func(v.y), \ + func(v.z)); \ + } #define VECTORIZE4_VEC(func) \ - template \ - GLM_FUNC_QUALIFIER detail::tvec4 func( \ + template \ + GLM_FUNC_QUALIFIER detail::tvec4 func( \ detail::tvec4 const & v) \ - { \ - return detail::tvec4( \ - func(v.x), \ - func(v.y), \ - func(v.z), \ - func(v.w)); \ - } + { \ + return detail::tvec4( \ + func(v.x), \ + func(v.y), \ + func(v.z), \ + func(v.w)); \ + } #define VECTORIZE_VEC(func) \ VECTORIZE2_VEC(func) \ @@ -65,46 +65,46 @@ VECTORIZE4_VEC(func) #define VECTORIZE2_VEC_SCA(func) \ - template \ - GLM_FUNC_QUALIFIER detail::tvec2 func \ + template \ + GLM_FUNC_QUALIFIER detail::tvec2 func \ ( \ detail::tvec2 const & x, \ typename detail::tvec2::value_type const & y \ ) \ - { \ - return detail::tvec2( \ - func(x.x, y), \ - func(x.y, y)); \ - } + { \ + return detail::tvec2( \ + func(x.x, y), \ + func(x.y, y)); \ + } #define VECTORIZE3_VEC_SCA(func) \ - template \ - GLM_FUNC_QUALIFIER detail::tvec3 func \ + template \ + GLM_FUNC_QUALIFIER detail::tvec3 func \ ( \ detail::tvec3 const & x, \ typename detail::tvec3::value_type const & y \ ) \ - { \ - return detail::tvec3( \ - func(x.x, y), \ - func(x.y, y), \ - func(x.z, y)); \ - } + { \ + return detail::tvec3( \ + func(x.x, y), \ + func(x.y, y), \ + func(x.z, y)); \ + } #define VECTORIZE4_VEC_SCA(func) \ - template \ - GLM_FUNC_QUALIFIER detail::tvec4 func \ + template \ + GLM_FUNC_QUALIFIER detail::tvec4 func \ ( \ detail::tvec4 const & x, \ typename detail::tvec4::value_type const & y \ ) \ - { \ - return detail::tvec4( \ - func(x.x, y), \ - func(x.y, y), \ - func(x.z, y), \ - func(x.w, y)); \ - } + { \ + return detail::tvec4( \ + func(x.x, y), \ + func(x.y, y), \ + func(x.z, y), \ + func(x.w, y)); \ + } #define VECTORIZE_VEC_SCA(func) \ VECTORIZE2_VEC_SCA(func) \ @@ -112,46 +112,46 @@ VECTORIZE4_VEC_SCA(func) #define VECTORIZE2_VEC_VEC(func) \ - template \ - GLM_FUNC_QUALIFIER detail::tvec2 func \ + template \ + GLM_FUNC_QUALIFIER detail::tvec2 func \ ( \ detail::tvec2 const & x, \ detail::tvec2 const & y \ ) \ - { \ - return detail::tvec2( \ - func(x.x, y.x), \ - func(x.y, y.y)); \ - } + { \ + return detail::tvec2( \ + func(x.x, y.x), \ + func(x.y, y.y)); \ + } #define VECTORIZE3_VEC_VEC(func) \ - template \ - GLM_FUNC_QUALIFIER detail::tvec3 func \ + template \ + GLM_FUNC_QUALIFIER detail::tvec3 func \ ( \ detail::tvec3 const & x, \ detail::tvec3 const & y \ ) \ - { \ - return detail::tvec3( \ - func(x.x, y.x), \ - func(x.y, y.y), \ - func(x.z, y.z)); \ - } + { \ + return detail::tvec3( \ + func(x.x, y.x), \ + func(x.y, y.y), \ + func(x.z, y.z)); \ + } #define VECTORIZE4_VEC_VEC(func) \ - template \ - GLM_FUNC_QUALIFIER detail::tvec4 func \ + template \ + GLM_FUNC_QUALIFIER detail::tvec4 func \ ( \ detail::tvec4 const & x, \ detail::tvec4 const & y \ ) \ - { \ - return detail::tvec4( \ - func(x.x, y.x), \ - func(x.y, y.y), \ - func(x.z, y.z), \ - func(x.w, y.w)); \ - } + { \ + return detail::tvec4( \ + func(x.x, y.x), \ + func(x.y, y.y), \ + func(x.z, y.z), \ + func(x.w, y.w)); \ + } #define VECTORIZE_VEC_VEC(func) \ VECTORIZE2_VEC_VEC(func) \ diff --git a/glm/core/dummy.cpp b/glm/core/dummy.cpp index 443c072f..db03cf89 100644 --- a/glm/core/dummy.cpp +++ b/glm/core/dummy.cpp @@ -31,7 +31,6 @@ #define GLM_MESSAGES #include "../glm.hpp" -#include "../ext.hpp" //#error "GLM is a header only library" diff --git a/glm/core/func_common.hpp b/glm/core/func_common.hpp index 9caa3e75..9ed943cc 100644 --- a/glm/core/func_common.hpp +++ b/glm/core/func_common.hpp @@ -46,27 +46,27 @@ namespace glm /// Returns x if x >= 0; otherwise, it returns -x. /// /// @tparam genType floating-point or signed integer; scalar or vector types. - /// - /// @see GLSL abs man page - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template + /// + /// @see GLSL abs man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template genType abs(genType const & x); /// Returns 1.0 if x > 0, 0.0 if x == 0, or -1.0 if x < 0. /// /// @tparam genType Floating-point or signed integer; scalar or vector types. /// - /// @see GLSL sign man page - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + /// @see GLSL sign man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template genType sign(genType const & x); - /// Returns a value equal to the nearest integer that is less then or equal to x. + /// Returns a value equal to the nearest integer that is less then or equal to x. /// /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL floor man page - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + /// + /// @see GLSL floor man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template genType floor(genType const & x); @@ -74,9 +74,9 @@ namespace glm /// whose absolute value is not larger than the absolute value of x. /// /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL trunc man page - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + /// + /// @see GLSL trunc man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template genType trunc(genType const & x); @@ -87,9 +87,9 @@ namespace glm /// same value as roundEven(x) for all values of x. /// /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL round man page - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + /// + /// @see GLSL round man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template genType round(genType const & x); @@ -98,40 +98,40 @@ namespace glm /// integer. (Both 3.5 and 4.5 for x will return 4.0.) /// /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL roundEven man page - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + /// + /// @see GLSL roundEven man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions /// @see New round to even technique template genType roundEven(genType const & x); /// Returns a value equal to the nearest integer /// that is greater than or equal to x. - /// + /// /// @tparam genType Floating-point scalar or vector types. /// - /// @see GLSL ceil man page + /// @see GLSL ceil man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template + template genType ceil(genType const & x); /// Return x - floor(x). - /// + /// /// @tparam genType Floating-point scalar or vector types. /// - /// @see GLSL fract man page - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template + /// @see GLSL fract man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template genType fract(genType const & x); /// Modulus. Returns x - y * floor(x / y) /// for each component in x using the floating point value y. /// /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL mod man page - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template + /// + /// @see GLSL mod man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template genType mod( genType const & x, genType const & y); @@ -140,10 +140,10 @@ namespace glm /// for each component in x using the floating point value y. /// /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL mod man page - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template + /// + /// @see GLSL mod man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template genType mod( genType const & x, typename genType::value_type const & y); @@ -152,22 +152,22 @@ namespace glm /// part (as a whole number floating point value). Both the /// return value and the output parameter will have the same /// sign as x. - /// + /// /// @tparam genType Floating-point scalar or vector types. /// - /// @see GLSL modf man page - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + /// @see GLSL modf man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template genType modf( genType const & x, genType & i); - /// Returns y if y < x; otherwise, it returns x. + /// Returns y if y < x; otherwise, it returns x. /// /// @tparam genType Floating-point or integer; scalar or vector types. - /// - /// @see GLSL min man page - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + /// + /// @see GLSL min man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template genType min( genType const & x, @@ -178,12 +178,12 @@ namespace glm genType const & x, typename genType::value_type const & y); - /// Returns y if x < y; otherwise, it returns x. + /// Returns y if x < y; otherwise, it returns x. /// /// @tparam genType Floating-point or integer; scalar or vector types. - /// - /// @see GLSL max man page - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + /// + /// @see GLSL max man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template genType max( genType const & x, @@ -194,13 +194,13 @@ namespace glm genType const & x, typename genType::value_type const & y); - /// Returns min(max(x, minVal), maxVal) for each component in x + /// Returns min(max(x, minVal), maxVal) for each component in x /// using the floating-point values minVal and maxVal. - /// + /// /// @tparam genType Floating-point or integer; scalar or vector types. /// - /// @see GLSL clamp man page - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + /// @see GLSL clamp man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template genType clamp( genType const & x, @@ -229,9 +229,9 @@ namespace glm //! provides different functionality than //! genType mix(genType x, genType y, genType(a)) //! where a is a Boolean vector. - /// - /// @see GLSL mix man page - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + /// + /// @see GLSL mix man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions /// /// @param[in] x Value to interpolate. /// @param[in] y Value to interpolate. @@ -259,9 +259,9 @@ namespace glm genTypeT mix(genTypeT const & x, genTypeT const & y, genTypeU const & a); //! 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 + //! + /// @see GLSL step man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template genType step( genType const & edge, @@ -283,9 +283,9 @@ namespace glm /// Results are undefined if edge0 >= edge1. /// /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL smoothstep man page - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + /// + /// @see GLSL smoothstep man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template genType smoothstep( genType const & edge0, @@ -305,11 +305,11 @@ namespace glm /// representations. /// /// /!\ When using compiler fast math, this function may fail. - /// + /// /// @tparam genType Floating-point scalar or vector types. /// - /// @see GLSL isnan man page - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + /// @see GLSL isnan man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template typename genType::bool_type isnan(genType const & x); @@ -318,10 +318,10 @@ namespace glm /// set of floating point representations. Returns false /// otherwise, including for implementations with no infinity /// representations. - /// + /// /// @tparam genType Floating-point scalar or vector types. /// - /// @see GLSL isinf man page + /// @see GLSL isinf man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template typename genType::bool_type isinf(genType const & x); @@ -332,9 +332,9 @@ namespace glm /// /// @tparam genType Single-precision floating-point scalar or vector types. /// @tparam genIType Signed integer scalar or vector types. - /// - /// @see GLSL floatBitsToInt man page - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + /// + /// @see GLSL floatBitsToInt man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template genIType floatBitsToInt(genType const & value); @@ -344,9 +344,9 @@ namespace glm /// /// @tparam genType Single-precision floating-point scalar or vector types. /// @tparam genUType Unsigned integer scalar or vector types. - /// - /// @see GLSL floatBitsToUint man page - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + /// + /// @see GLSL floatBitsToUint man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template genUType floatBitsToUint(genType const & value); @@ -355,39 +355,39 @@ namespace glm /// If an inf or NaN is passed in, it will not signal, and the /// resulting floating point value is unspecified. Otherwise, /// the bit-level representation is preserved. - /// + /// /// @tparam genType Single-precision floating-point scalar or vector types. /// @tparam genIType Signed integer scalar or vector types. /// - /// @see GLSL intBitsToFloat man page - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + /// @see GLSL intBitsToFloat man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions /// /// @todo Clarify this declaration, we don't need to actually specify the return type template genType intBitsToFloat(genIType const & value); - - /// Returns a floating-point value corresponding to a - /// unsigned integer encoding of a floating-point value. - /// If an inf or NaN is passed in, it will not signal, and the - /// resulting floating point value is unspecified. Otherwise, - /// the bit-level representation is preserved. - /// + + /// Returns a floating-point value corresponding to a + /// unsigned integer encoding of a floating-point value. + /// If an inf or NaN is passed in, it will not signal, and the + /// resulting floating point value is unspecified. Otherwise, + /// the bit-level representation is preserved. + /// /// @tparam genType Single-precision floating-point scalar or vector types. /// @tparam genUType Unsigned integer scalar or vector types. - /// - /// @see GLSL uintBitsToFloat man page - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + /// + /// @see GLSL uintBitsToFloat man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions /// /// @todo Clarify this declaration, we don't need to actually specify the return type - template - genType uintBitsToFloat(genUType const & value); - + template + genType uintBitsToFloat(genUType const & value); + /// Computes and returns a * b + c. /// /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL fma man page - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + /// + /// @see GLSL fma man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template genType fma(genType const & a, genType const & b, genType const & c); @@ -404,7 +404,7 @@ namespace glm /// @tparam genType Floating-point scalar or vector types. /// /// @see GLSL frexp man page - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template genType frexp(genType const & x, genIType & exp); @@ -418,7 +418,7 @@ namespace glm /// @tparam genType Floating-point scalar or vector types. /// /// @see GLSL ldexp man page; - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions template genType ldexp(genType const & x, genIType const & exp); diff --git a/glm/core/func_common.inl b/glm/core/func_common.inl index a47f0cc3..848ee88e 100644 --- a/glm/core/func_common.inl +++ b/glm/core/func_common.inl @@ -29,33 +29,33 @@ namespace glm{ namespace detail { - template - struct Abs_ - {}; + template + struct Abs_ + {}; - template - struct Abs_ - { - static genFIType get(genFIType const & x) - { - GLM_STATIC_ASSERT( - detail::type::is_float || - detail::type::is_int, "'abs' only accept floating-point and integer inputs"); - return x >= genFIType(0) ? x : -x; + template + struct Abs_ + { + static genFIType get(genFIType const & x) + { + GLM_STATIC_ASSERT( + detail::type::is_float || + detail::type::is_int, "'abs' only accept floating-point and integer inputs"); + return x >= genFIType(0) ? x : -x; // TODO, perf comp with: *(((int *) &x) + 1) &= 0x7fffffff; - } - }; + } + }; - template - struct Abs_ - { - static genFIType get(genFIType const & x) - { - GLM_STATIC_ASSERT( + template + struct Abs_ + { + static genFIType get(genFIType const & x) + { + GLM_STATIC_ASSERT( detail::type::is_uint, "'abs' only accept floating-point and integer inputs"); - return x; - } - }; + return x; + } + }; }//namespace detail // abs @@ -121,34 +121,34 @@ namespace detail VECTORIZE_VEC(trunc) - // round - template - GLM_FUNC_QUALIFIER genType round(genType const& x) - { + // round + template + GLM_FUNC_QUALIFIER genType round(genType const& x) + { GLM_STATIC_ASSERT(detail::type::is_float, "'round' only accept floating-point inputs"); if(x < 0) return genType(int(x - genType(0.5))); return genType(int(x + genType(0.5))); - } + } VECTORIZE_VEC(round) /* - // roundEven - template - GLM_FUNC_QUALIFIER genType roundEven(genType const& x) - { + // roundEven + template + GLM_FUNC_QUALIFIER genType roundEven(genType const& x) + { GLM_STATIC_ASSERT(detail::type::is_float, "'roundEven' only accept floating-point inputs"); return genType(int(x + genType(int(x) % 2))); - } + } */ - // roundEven - template - GLM_FUNC_QUALIFIER genType roundEven(genType const & x) - { + // roundEven + template + GLM_FUNC_QUALIFIER genType roundEven(genType const & x) + { GLM_STATIC_ASSERT(detail::type::is_float, "'roundEven' only accept floating-point inputs"); int Integer = int(x); @@ -179,98 +179,98 @@ namespace detail VECTORIZE_VEC(roundEven) - // ceil - template - GLM_FUNC_QUALIFIER genType ceil(genType const & x) - { + // ceil + template + GLM_FUNC_QUALIFIER genType ceil(genType const & x) + { GLM_STATIC_ASSERT(detail::type::is_float, "'ceil' only accept floating-point inputs"); - return ::std::ceil(x); - } + return ::std::ceil(x); + } VECTORIZE_VEC(ceil) - // fract - template - GLM_FUNC_QUALIFIER genType fract + // fract + template + GLM_FUNC_QUALIFIER genType fract ( genType const & x ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'fract' only accept floating-point inputs"); - return x - ::std::floor(x); - } + return x - ::std::floor(x); + } VECTORIZE_VEC(fract) - // mod - template - GLM_FUNC_QUALIFIER genType mod + // mod + template + GLM_FUNC_QUALIFIER genType mod ( genType const & x, genType const & y ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'mod' only accept floating-point inputs"); - return x - y * floor(x / y); - } + return x - y * floor(x / y); + } VECTORIZE_VEC_SCA(mod) VECTORIZE_VEC_VEC(mod) - // modf - template - GLM_FUNC_QUALIFIER genType modf + // modf + template + GLM_FUNC_QUALIFIER genType modf ( genType const & x, genType & i ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'modf' only accept floating-point inputs"); return std::modf(x, &i); - } + } - template - GLM_FUNC_QUALIFIER detail::tvec2 modf + template + GLM_FUNC_QUALIFIER detail::tvec2 modf ( detail::tvec2 const & x, detail::tvec2 & i ) - { - return detail::tvec2( - modf(x.x, i.x), - modf(x.y, i.y)); - } + { + return detail::tvec2( + modf(x.x, i.x), + modf(x.y, i.y)); + } - template - GLM_FUNC_QUALIFIER detail::tvec3 modf + template + GLM_FUNC_QUALIFIER detail::tvec3 modf ( detail::tvec3 const & x, detail::tvec3 & i ) - { - return detail::tvec3( - modf(x.x, i.x), - modf(x.y, i.y), - modf(x.z, i.z)); - } + { + return detail::tvec3( + modf(x.x, i.x), + modf(x.y, i.y), + modf(x.z, i.z)); + } - template - GLM_FUNC_QUALIFIER detail::tvec4 modf + template + GLM_FUNC_QUALIFIER detail::tvec4 modf ( detail::tvec4 const & x, detail::tvec4 & i ) - { - return detail::tvec4( - modf(x.x, i.x), - modf(x.y, i.y), - modf(x.z, i.z), - modf(x.w, i.w)); - } + { + return detail::tvec4( + modf(x.x, i.x), + modf(x.y, i.y), + modf(x.z, i.z), + modf(x.w, i.w)); + } //// Only valid if (INT_MIN <= x-y <= INT_MAX) //// min(x,y) @@ -280,53 +280,53 @@ namespace detail //r = x - ((x - y) & ((x - y) >> (sizeof(int) * //CHAR_BIT - 1))); - // min - template - GLM_FUNC_QUALIFIER genType min + // min + template + GLM_FUNC_QUALIFIER genType min ( genType const & x, genType const & y ) - { + { GLM_STATIC_ASSERT( detail::type::is_float || detail::type::is_int || detail::type::is_uint, "'min' only accept numbers"); - return x < y ? x : y; - } + return x < y ? x : y; + } VECTORIZE_VEC_SCA(min) VECTORIZE_VEC_VEC(min) - // max - template - GLM_FUNC_QUALIFIER genType max + // max + template + GLM_FUNC_QUALIFIER genType max ( genType const & x, genType const & y ) - { + { GLM_STATIC_ASSERT( detail::type::is_float || detail::type::is_int || detail::type::is_uint, "'max' only accept numbers"); return x > y ? x : y; - } + } VECTORIZE_VEC_SCA(max) VECTORIZE_VEC_VEC(max) - // clamp - template - GLM_FUNC_QUALIFIER valType clamp + // clamp + template + GLM_FUNC_QUALIFIER valType clamp ( valType const & x, valType const & minVal, valType const & maxVal ) - { + { GLM_STATIC_ASSERT( detail::type::is_float || detail::type::is_int || @@ -334,94 +334,94 @@ namespace detail // Old implementation, less predictable branching //if(x >= maxVal) return maxVal; - //if(x <= minVal) return minVal; - //return x; + //if(x <= minVal) return minVal; + //return x; return max(min(x, maxVal), minVal); - } + } - template - GLM_FUNC_QUALIFIER detail::tvec2 clamp + template + GLM_FUNC_QUALIFIER detail::tvec2 clamp ( detail::tvec2 const & x, typename detail::tvec2::value_type const & minVal, typename detail::tvec2::value_type const & maxVal ) - { - return detail::tvec2( - clamp(x.x, minVal, maxVal), - clamp(x.y, minVal, maxVal)); - } + { + return detail::tvec2( + clamp(x.x, minVal, maxVal), + clamp(x.y, minVal, maxVal)); + } - template - GLM_FUNC_QUALIFIER detail::tvec3 clamp + template + GLM_FUNC_QUALIFIER detail::tvec3 clamp ( detail::tvec3 const & x, typename detail::tvec3::value_type const & minVal, typename detail::tvec3::value_type const & maxVal ) - { - return detail::tvec3( - clamp(x.x, minVal, maxVal), - clamp(x.y, minVal, maxVal), - clamp(x.z, minVal, maxVal)); - } + { + return detail::tvec3( + clamp(x.x, minVal, maxVal), + clamp(x.y, minVal, maxVal), + clamp(x.z, minVal, maxVal)); + } - template - GLM_FUNC_QUALIFIER detail::tvec4 clamp + template + GLM_FUNC_QUALIFIER detail::tvec4 clamp ( detail::tvec4 const & x, typename detail::tvec4::value_type const & minVal, typename detail::tvec4::value_type const & maxVal ) - { - return detail::tvec4( - clamp(x.x, minVal, maxVal), - clamp(x.y, minVal, maxVal), - clamp(x.z, minVal, maxVal), - clamp(x.w, minVal, maxVal)); - } + { + return detail::tvec4( + clamp(x.x, minVal, maxVal), + clamp(x.y, minVal, maxVal), + clamp(x.z, minVal, maxVal), + clamp(x.w, minVal, maxVal)); + } - template - GLM_FUNC_QUALIFIER detail::tvec2 clamp + template + GLM_FUNC_QUALIFIER detail::tvec2 clamp ( detail::tvec2 const & x, detail::tvec2 const & minVal, detail::tvec2 const & maxVal ) - { - return detail::tvec2( - clamp(x.x, minVal.x, maxVal.x), - clamp(x.y, minVal.y, maxVal.y)); - } + { + return detail::tvec2( + clamp(x.x, minVal.x, maxVal.x), + clamp(x.y, minVal.y, maxVal.y)); + } - template - GLM_FUNC_QUALIFIER detail::tvec3 clamp + template + GLM_FUNC_QUALIFIER detail::tvec3 clamp ( detail::tvec3 const & x, detail::tvec3 const & minVal, detail::tvec3 const & maxVal ) - { - return detail::tvec3( - clamp(x.x, minVal.x, maxVal.x), - clamp(x.y, minVal.y, maxVal.y), - clamp(x.z, minVal.z, maxVal.z)); - } + { + return detail::tvec3( + clamp(x.x, minVal.x, maxVal.x), + clamp(x.y, minVal.y, maxVal.y), + clamp(x.z, minVal.z, maxVal.z)); + } - template - GLM_FUNC_QUALIFIER detail::tvec4 clamp + template + GLM_FUNC_QUALIFIER detail::tvec4 clamp ( detail::tvec4 const & x, detail::tvec4 const & minVal, detail::tvec4 const & maxVal ) - { - return detail::tvec4( - clamp(x.x, minVal.x, maxVal.x), - clamp(x.y, minVal.y, maxVal.y), - clamp(x.z, minVal.z, maxVal.z), - clamp(x.w, minVal.w, maxVal.w)); - } + { + return detail::tvec4( + clamp(x.x, minVal.x, maxVal.x), + clamp(x.y, minVal.y, maxVal.y), + clamp(x.z, minVal.z, maxVal.z), + clamp(x.w, minVal.w, maxVal.w)); + } // mix template @@ -612,194 +612,194 @@ namespace detail } // step - template - GLM_FUNC_QUALIFIER genType step + template + GLM_FUNC_QUALIFIER genType step ( genType const & edge, genType const & x ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'mix' only accept floating-point inputs"); - return x < edge ? genType(0) : genType(1); - } + return x < edge ? genType(0) : genType(1); + } - template - GLM_FUNC_QUALIFIER detail::tvec2 step + template + GLM_FUNC_QUALIFIER detail::tvec2 step ( typename detail::tvec2::value_type const & edge, detail::tvec2 const & x ) - { - return detail::tvec2( - x.x < edge ? T(0) : T(1), - x.y < edge ? T(0) : T(1)); - } + { + return detail::tvec2( + x.x < edge ? T(0) : T(1), + x.y < edge ? T(0) : T(1)); + } - template - GLM_FUNC_QUALIFIER detail::tvec3 step + template + GLM_FUNC_QUALIFIER detail::tvec3 step ( typename detail::tvec3::value_type const & edge, detail::tvec3 const & x ) - { + { return detail::tvec3( x.x < edge ? T(0) : T(1), x.y < edge ? T(0) : T(1), x.z < edge ? T(0) : T(1)); - } + } - template - GLM_FUNC_QUALIFIER detail::tvec4 step + template + GLM_FUNC_QUALIFIER detail::tvec4 step ( typename detail::tvec4::value_type const & edge, detail::tvec4 const & x ) - { - return detail::tvec4( - x.x < edge ? T(0) : T(1), - x.y < edge ? T(0) : T(1), - x.z < edge ? T(0) : T(1), - x.w < edge ? T(0) : T(1)); - } + { + return detail::tvec4( + x.x < edge ? T(0) : T(1), + x.y < edge ? T(0) : T(1), + x.z < edge ? T(0) : T(1), + x.w < edge ? T(0) : T(1)); + } - template - GLM_FUNC_QUALIFIER detail::tvec2 step + template + GLM_FUNC_QUALIFIER detail::tvec2 step ( detail::tvec2 const & edge, detail::tvec2 const & x ) - { - return detail::tvec2( - x.x < edge.x ? T(0) : T(1), - x.y < edge.y ? T(0) : T(1)); - } + { + return detail::tvec2( + x.x < edge.x ? T(0) : T(1), + x.y < edge.y ? T(0) : T(1)); + } - template - GLM_FUNC_QUALIFIER detail::tvec3 step + template + GLM_FUNC_QUALIFIER detail::tvec3 step ( detail::tvec3 const & edge, detail::tvec3 const & x ) - { - return detail::tvec3( - x.x < edge.x ? T(0) : T(1), - x.y < edge.y ? T(0) : T(1), - x.z < edge.z ? T(0) : T(1)); - } + { + return detail::tvec3( + x.x < edge.x ? T(0) : T(1), + x.y < edge.y ? T(0) : T(1), + x.z < edge.z ? T(0) : T(1)); + } - template - GLM_FUNC_QUALIFIER detail::tvec4 step + template + GLM_FUNC_QUALIFIER detail::tvec4 step ( detail::tvec4 const & edge, detail::tvec4 const & x ) - { - return detail::tvec4( - x.x < edge.x ? T(0) : T(1), - x.y < edge.y ? T(0) : T(1), - x.z < edge.z ? T(0) : T(1), - x.w < edge.w ? T(0) : T(1)); - } + { + return detail::tvec4( + x.x < edge.x ? T(0) : T(1), + x.y < edge.y ? T(0) : T(1), + x.z < edge.z ? T(0) : T(1), + x.w < edge.w ? T(0) : T(1)); + } - // smoothstep - template - GLM_FUNC_QUALIFIER genType smoothstep + // smoothstep + template + GLM_FUNC_QUALIFIER genType smoothstep ( genType const & edge0, genType const & edge1, genType const & x ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'mix' only accept floating-point inputs"); - genType tmp = clamp((x - edge0) / (edge1 - edge0), genType(0), genType(1)); - return tmp * tmp * (genType(3) - genType(2) * tmp); - } + genType tmp = clamp((x - edge0) / (edge1 - edge0), genType(0), genType(1)); + return tmp * tmp * (genType(3) - genType(2) * tmp); + } - template - GLM_FUNC_QUALIFIER detail::tvec2 smoothstep + template + GLM_FUNC_QUALIFIER detail::tvec2 smoothstep ( typename detail::tvec2::value_type const & edge0, typename detail::tvec2::value_type const & edge1, detail::tvec2 const & x ) - { - return detail::tvec2( - smoothstep(edge0, edge1, x.x), - smoothstep(edge0, edge1, x.y)); - } + { + return detail::tvec2( + smoothstep(edge0, edge1, x.x), + smoothstep(edge0, edge1, x.y)); + } - template - GLM_FUNC_QUALIFIER detail::tvec3 smoothstep + template + GLM_FUNC_QUALIFIER detail::tvec3 smoothstep ( typename detail::tvec3::value_type const & edge0, typename detail::tvec3::value_type const & edge1, detail::tvec3 const & x ) - { - return detail::tvec3( - smoothstep(edge0, edge1, x.x), - smoothstep(edge0, edge1, x.y), - smoothstep(edge0, edge1, x.z)); - } + { + return detail::tvec3( + smoothstep(edge0, edge1, x.x), + smoothstep(edge0, edge1, x.y), + smoothstep(edge0, edge1, x.z)); + } - template - GLM_FUNC_QUALIFIER detail::tvec4 smoothstep + template + GLM_FUNC_QUALIFIER detail::tvec4 smoothstep ( typename detail::tvec4::value_type const & edge0, typename detail::tvec4::value_type const & edge1, detail::tvec4 const & x ) - { - return detail::tvec4( - smoothstep(edge0, edge1, x.x), - smoothstep(edge0, edge1, x.y), - smoothstep(edge0, edge1, x.z), - smoothstep(edge0, edge1, x.w)); - } + { + return detail::tvec4( + smoothstep(edge0, edge1, x.x), + smoothstep(edge0, edge1, x.y), + smoothstep(edge0, edge1, x.z), + smoothstep(edge0, edge1, x.w)); + } - template - GLM_FUNC_QUALIFIER detail::tvec2 smoothstep + template + GLM_FUNC_QUALIFIER detail::tvec2 smoothstep ( detail::tvec2 const & edge0, detail::tvec2 const & edge1, detail::tvec2 const & x ) - { - return detail::tvec2( - smoothstep(edge0.x, edge1.x, x.x), - smoothstep(edge0.y, edge1.y, x.y)); - } + { + return detail::tvec2( + smoothstep(edge0.x, edge1.x, x.x), + smoothstep(edge0.y, edge1.y, x.y)); + } - template - GLM_FUNC_QUALIFIER detail::tvec3 smoothstep + template + GLM_FUNC_QUALIFIER detail::tvec3 smoothstep ( detail::tvec3 const & edge0, detail::tvec3 const & edge1, detail::tvec3 const & x ) - { - return detail::tvec3( - smoothstep(edge0.x, edge1.x, x.x), - smoothstep(edge0.y, edge1.y, x.y), - smoothstep(edge0.z, edge1.z, x.z)); - } + { + return detail::tvec3( + smoothstep(edge0.x, edge1.x, x.x), + smoothstep(edge0.y, edge1.y, x.y), + smoothstep(edge0.z, edge1.z, x.z)); + } - template - GLM_FUNC_QUALIFIER detail::tvec4 smoothstep + template + GLM_FUNC_QUALIFIER detail::tvec4 smoothstep ( detail::tvec4 const & edge0, detail::tvec4 const & edge1, detail::tvec4 const & x ) - { - return detail::tvec4( - smoothstep(edge0.x, edge1.x, x.x), - smoothstep(edge0.y, edge1.y, x.y), - smoothstep(edge0.z, edge1.z, x.z), - smoothstep(edge0.w, edge1.w, x.w)); - } + { + return detail::tvec4( + smoothstep(edge0.x, edge1.x, x.x), + smoothstep(edge0.y, edge1.y, x.y), + smoothstep(edge0.z, edge1.z, x.z), + smoothstep(edge0.w, edge1.w, x.w)); + } // TODO: Not working on MinGW... template @@ -808,7 +808,7 @@ namespace detail GLM_STATIC_ASSERT(detail::type::is_float, "'isnan' only accept floating-point inputs"); # if(GLM_COMPILER & (GLM_COMPILER_VC | GLM_COMPILER_INTEL)) - return _isnan(x) != 0; + return _isnan(x) != 0; # elif(GLM_COMPILER & GLM_COMPILER_GCC) # if(GLM_PLATFORM & GLM_PLATFORM_ANDROID) return _isnan(x) != 0; @@ -816,45 +816,45 @@ namespace detail return std::isnan(x); # endif # else - return std::isnan(x); + return std::isnan(x); # endif } - template - GLM_FUNC_QUALIFIER typename detail::tvec2::bool_type isnan + template + GLM_FUNC_QUALIFIER typename detail::tvec2::bool_type isnan ( detail::tvec2 const & x ) - { - return typename detail::tvec2::bool_type( - isnan(x.x), - isnan(x.y)); - } + { + return typename detail::tvec2::bool_type( + isnan(x.x), + isnan(x.y)); + } - template - GLM_FUNC_QUALIFIER typename detail::tvec3::bool_type isnan + template + GLM_FUNC_QUALIFIER typename detail::tvec3::bool_type isnan ( detail::tvec3 const & x ) - { - return typename detail::tvec3::bool_type( - isnan(x.x), - isnan(x.y), - isnan(x.z)); - } + { + return typename detail::tvec3::bool_type( + isnan(x.x), + isnan(x.y), + isnan(x.z)); + } - template - GLM_FUNC_QUALIFIER typename detail::tvec4::bool_type isnan + template + GLM_FUNC_QUALIFIER typename detail::tvec4::bool_type isnan ( detail::tvec4 const & x ) - { - return typename detail::tvec4::bool_type( - isnan(x.x), - isnan(x.y), - isnan(x.z), - isnan(x.w)); - } + { + return typename detail::tvec4::bool_type( + isnan(x.x), + isnan(x.y), + isnan(x.z), + isnan(x.w)); + } template GLM_FUNC_QUALIFIER bool isinf( @@ -863,7 +863,7 @@ namespace detail GLM_STATIC_ASSERT(detail::type::is_float, "'isinf' only accept floating-point inputs"); # if(GLM_COMPILER & (GLM_COMPILER_INTEL | GLM_COMPILER_VC)) - return _fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF; + return _fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF; # elif(GLM_COMPILER & GLM_COMPILER_GCC) # if(GLM_PLATFORM & GLM_PLATFORM_ANDROID) return _isinf(x) != 0; @@ -871,60 +871,60 @@ namespace detail return std::isinf(x); # endif # else - return std::isinf(x); + return std::isinf(x); # endif /* # if(GLM_COMPILER & GLM_COMPILER_VC) - return _fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF; + return _fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF; # elif(GLM_COMPILER & GLM_COMPILER_GCC) # if(GLM_PLATFORM & GLM_PLATFORM_ANDROID) - return _isinf(x) != 0; + return _isinf(x) != 0; # else - return std::isinf(x); + return std::isinf(x); # endif # elif(GLM_COMPILER & GLM_COMPILER_INTEL) - return isinf(x) != 0; + return isinf(x) != 0; # else - return std::isinf(x); + return std::isinf(x); # endif */ } - template - GLM_FUNC_QUALIFIER typename detail::tvec2::bool_type isinf + template + GLM_FUNC_QUALIFIER typename detail::tvec2::bool_type isinf ( detail::tvec2 const & x ) - { - return typename detail::tvec2::bool_type( - isinf(x.x), - isinf(x.y)); - } + { + return typename detail::tvec2::bool_type( + isinf(x.x), + isinf(x.y)); + } - template - GLM_FUNC_QUALIFIER typename detail::tvec3::bool_type isinf + template + GLM_FUNC_QUALIFIER typename detail::tvec3::bool_type isinf ( detail::tvec3 const & x ) - { - return typename detail::tvec3::bool_type( - isinf(x.x), - isinf(x.y), - isinf(x.z)); - } + { + return typename detail::tvec3::bool_type( + isinf(x.x), + isinf(x.y), + isinf(x.z)); + } - template - GLM_FUNC_QUALIFIER typename detail::tvec4::bool_type isinf + template + GLM_FUNC_QUALIFIER typename detail::tvec4::bool_type isinf ( detail::tvec4 const & x ) - { - return typename detail::tvec4::bool_type( - isinf(x.x), - isinf(x.y), - isinf(x.z), - isinf(x.w)); - } + { + return typename detail::tvec4::bool_type( + isinf(x.x), + isinf(x.y), + isinf(x.z), + isinf(x.w)); + } GLM_FUNC_QUALIFIER int floatBitsToInt(float const & value) { @@ -938,38 +938,38 @@ namespace detail return fi.i; } - GLM_FUNC_QUALIFIER detail::tvec2 floatBitsToInt + GLM_FUNC_QUALIFIER detail::tvec2 floatBitsToInt ( detail::tvec2 const & value ) - { - return detail::tvec2( - floatBitsToInt(value.x), - floatBitsToInt(value.y)); - } + { + return detail::tvec2( + floatBitsToInt(value.x), + floatBitsToInt(value.y)); + } - GLM_FUNC_QUALIFIER detail::tvec3 floatBitsToInt + GLM_FUNC_QUALIFIER detail::tvec3 floatBitsToInt ( detail::tvec3 const & value ) - { - return detail::tvec3( - floatBitsToInt(value.x), + { + return detail::tvec3( + floatBitsToInt(value.x), floatBitsToInt(value.y), floatBitsToInt(value.z)); - } + } - GLM_FUNC_QUALIFIER detail::tvec4 floatBitsToInt + GLM_FUNC_QUALIFIER detail::tvec4 floatBitsToInt ( detail::tvec4 const & value ) - { - return detail::tvec4( - floatBitsToInt(value.x), + { + return detail::tvec4( + floatBitsToInt(value.x), floatBitsToInt(value.y), floatBitsToInt(value.z), floatBitsToInt(value.w)); - } + } GLM_FUNC_QUALIFIER uint floatBitsToUint(float const & value) { @@ -983,38 +983,38 @@ namespace detail return fu.u; } - GLM_FUNC_QUALIFIER detail::tvec2 floatBitsToUint + GLM_FUNC_QUALIFIER detail::tvec2 floatBitsToUint ( detail::tvec2 const & value ) - { - return detail::tvec2( - floatBitsToUint(value.x), - floatBitsToUint(value.y)); - } + { + return detail::tvec2( + floatBitsToUint(value.x), + floatBitsToUint(value.y)); + } - GLM_FUNC_QUALIFIER detail::tvec3 floatBitsToUint + GLM_FUNC_QUALIFIER detail::tvec3 floatBitsToUint ( detail::tvec3 const & value ) - { - return detail::tvec3( - floatBitsToUint(value.x), + { + return detail::tvec3( + floatBitsToUint(value.x), floatBitsToUint(value.y), floatBitsToUint(value.z)); - } + } - GLM_FUNC_QUALIFIER detail::tvec4 floatBitsToUint + GLM_FUNC_QUALIFIER detail::tvec4 floatBitsToUint ( detail::tvec4 const & value ) - { - return detail::tvec4( - floatBitsToUint(value.x), + { + return detail::tvec4( + floatBitsToUint(value.x), floatBitsToUint(value.y), floatBitsToUint(value.z), floatBitsToUint(value.w)); - } + } GLM_FUNC_QUALIFIER float intBitsToFloat(int const & value) { @@ -1033,79 +1033,79 @@ namespace detail ( detail::tvec2 const & value ) - { - return detail::tvec2( - intBitsToFloat(value.x), - intBitsToFloat(value.y)); - } + { + return detail::tvec2( + intBitsToFloat(value.x), + intBitsToFloat(value.y)); + } GLM_FUNC_QUALIFIER detail::tvec3 intBitsToFloat ( detail::tvec3 const & value ) - { - return detail::tvec3( - intBitsToFloat(value.x), + { + return detail::tvec3( + intBitsToFloat(value.x), intBitsToFloat(value.y), intBitsToFloat(value.z)); - } + } - GLM_FUNC_QUALIFIER detail::tvec4 intBitsToFloat + GLM_FUNC_QUALIFIER detail::tvec4 intBitsToFloat ( detail::tvec4 const & value ) - { - return detail::tvec4( - intBitsToFloat(value.x), + { + return detail::tvec4( + intBitsToFloat(value.x), intBitsToFloat(value.y), intBitsToFloat(value.z), intBitsToFloat(value.w)); - } + } - GLM_FUNC_QUALIFIER float uintBitsToFloat(uint const & value) - { - union - { - float f; - uint u; - } fu; + GLM_FUNC_QUALIFIER float uintBitsToFloat(uint const & value) + { + union + { + float f; + uint u; + } fu; - fu.u = value; - return fu.f; - } + fu.u = value; + return fu.f; + } - GLM_FUNC_QUALIFIER detail::tvec2 uintBitsToFloat + GLM_FUNC_QUALIFIER detail::tvec2 uintBitsToFloat ( detail::tvec2 const & value ) - { - return detail::tvec2( - uintBitsToFloat(value.x), - uintBitsToFloat(value.y)); - } + { + return detail::tvec2( + uintBitsToFloat(value.x), + uintBitsToFloat(value.y)); + } - GLM_FUNC_QUALIFIER detail::tvec3 uintBitsToFloat + GLM_FUNC_QUALIFIER detail::tvec3 uintBitsToFloat ( detail::tvec3 const & value ) - { - return detail::tvec3( - uintBitsToFloat(value.x), + { + return detail::tvec3( + uintBitsToFloat(value.x), uintBitsToFloat(value.y), uintBitsToFloat(value.z)); - } + } - GLM_FUNC_QUALIFIER detail::tvec4 uintBitsToFloat + GLM_FUNC_QUALIFIER detail::tvec4 uintBitsToFloat ( detail::tvec4 const & value ) - { - return detail::tvec4( - uintBitsToFloat(value.x), + { + return detail::tvec4( + uintBitsToFloat(value.x), uintBitsToFloat(value.y), uintBitsToFloat(value.z), uintBitsToFloat(value.w)); - } + } template GLM_FUNC_QUALIFIER genType fma diff --git a/glm/core/func_exponential.hpp b/glm/core/func_exponential.hpp index 69399e86..557ac175 100644 --- a/glm/core/func_exponential.hpp +++ b/glm/core/func_exponential.hpp @@ -46,9 +46,9 @@ namespace glm /// @param x pow function is defined for input values of x defined in the range (inf-, inf+) in the limit of the type precision. /// @param y /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL pow man page - /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions + /// + /// @see GLSL pow man page + /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions template genType pow(genType const & x, genType const & y); @@ -56,9 +56,9 @@ namespace glm /// /// @param x exp function is defined for input values of x defined in the range (inf-, inf+) in the limit of the type precision. /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL exp man page - /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions + /// + /// @see GLSL exp man page + /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions template genType exp(genType const & x); @@ -68,9 +68,9 @@ namespace glm /// /// @param x log function is defined for input values of x defined in the range (0, inf+) in the limit of the type precision. /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL log man page - /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions + /// + /// @see GLSL log man page + /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions template genType log(genType const & x); @@ -78,40 +78,40 @@ namespace glm /// /// @param x exp2 function is defined for input values of x defined in the range (inf-, inf+) in the limit of the type precision. /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL exp2 man page - /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions + /// + /// @see GLSL exp2 man page + /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions template genType exp2(genType const & x); /// Returns the base 2 log of x, i.e., returns the value y, /// which satisfies the equation x = 2 ^ y. - /// + /// /// @param x log2 function is defined for input values of x defined in the range (0, inf+) in the limit of the type precision. /// @tparam genType Floating-point scalar or vector types. /// - /// @see GLSL log2 man page - /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions + /// @see GLSL log2 man page + /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions template genType log2(genType const & x); /// Returns the positive square root of x. - /// + /// /// @param x sqrt function is defined for input values of x defined in the range [0, inf+) in the limit of the type precision. /// @tparam genType Floating-point scalar or vector types. /// - /// @see GLSL sqrt man page - /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions + /// @see GLSL sqrt man page + /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions template genType sqrt(genType 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. /// @tparam genType Floating-point scalar or vector types. /// - /// @see GLSL inversesqrt man page - /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions + /// @see GLSL inversesqrt man page + /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions template genType inversesqrt(genType const & x); diff --git a/glm/core/func_exponential.inl b/glm/core/func_exponential.inl index 0fba6691..8bbf87a3 100644 --- a/glm/core/func_exponential.inl +++ b/glm/core/func_exponential.inl @@ -28,60 +28,60 @@ namespace glm { - // pow - template - GLM_FUNC_QUALIFIER genType pow + // pow + template + GLM_FUNC_QUALIFIER genType pow ( genType const & x, genType const & y ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'pow' only accept floating-point input"); - return ::std::pow(x, y); - } + return ::std::pow(x, y); + } VECTORIZE_VEC_VEC(pow) - // exp - template - GLM_FUNC_QUALIFIER genType exp + // exp + template + GLM_FUNC_QUALIFIER genType exp ( genType const & x ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'exp' only accept floating-point input"); - return ::std::exp(x); - } + return ::std::exp(x); + } VECTORIZE_VEC(exp) - // log - template - GLM_FUNC_QUALIFIER genType log + // log + template + GLM_FUNC_QUALIFIER genType log ( genType const & x ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'log' only accept floating-point input"); - return ::std::log(x); - } + return ::std::log(x); + } VECTORIZE_VEC(log) - //exp2, ln2 = 0.69314718055994530941723212145818f - template - GLM_FUNC_QUALIFIER genType exp2 + //exp2, ln2 = 0.69314718055994530941723212145818f + template + GLM_FUNC_QUALIFIER genType exp2 ( genType const & x ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'exp2' only accept floating-point input"); - return ::std::exp(genType(0.69314718055994530941723212145818) * x); - } + return ::std::exp(genType(0.69314718055994530941723212145818) * x); + } VECTORIZE_VEC(exp2) @@ -109,46 +109,46 @@ namespace _detail return T(::std::log(Value)) / T(0.69314718055994530941723212145818); } }; - + }//namespace _detail - // log2, ln2 = 0.69314718055994530941723212145818f - template - GLM_FUNC_QUALIFIER genType log2 + // log2, ln2 = 0.69314718055994530941723212145818f + template + GLM_FUNC_QUALIFIER genType log2 ( genType const & x ) - { + { assert(x > genType(0)); // log2 is only defined on the range (0, inf] return _detail::_compute_log2::ID>()(x); - } + } VECTORIZE_VEC(log2) - // sqrt - template - GLM_FUNC_QUALIFIER genType sqrt + // sqrt + template + GLM_FUNC_QUALIFIER genType sqrt ( genType const & x ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'sqrt' only accept floating-point input"); - return genType(::std::sqrt(x)); - } + return genType(::std::sqrt(x)); + } VECTORIZE_VEC(sqrt) - template - GLM_FUNC_QUALIFIER genType inversesqrt + template + GLM_FUNC_QUALIFIER genType inversesqrt ( genType const & x ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'inversesqrt' only accept floating-point input"); - return genType(1) / ::std::sqrt(x); - } + return genType(1) / ::std::sqrt(x); + } VECTORIZE_VEC(inversesqrt) diff --git a/glm/core/func_geometric.hpp b/glm/core/func_geometric.hpp index d24a9c86..1c92e1b8 100644 --- a/glm/core/func_geometric.hpp +++ b/glm/core/func_geometric.hpp @@ -42,21 +42,21 @@ namespace glm /// @{ /// Returns the length of x, i.e., sqrt(x * x). - /// + /// /// @tparam genType Floating-point vector types. /// - /// @see GLSL length man page - /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions + /// @see GLSL length man page + /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions template - typename genType::value_type length( + typename genType::value_type length( genType const & x); /// Returns the distance betwwen p0 and p1, i.e., length(p0 - p1). /// /// @tparam genType Floating-point vector types. - /// - /// @see GLSL distance man page - /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions + /// + /// @see GLSL distance man page + /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions template typename genType::value_type distance( genType const & p0, @@ -65,10 +65,10 @@ namespace glm /// Returns the dot product of x and y, i.e., result = x * y. /// /// @tparam genType Floating-point vector types. - /// - /// @see GLSL dot man page - /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions - template + /// + /// @see GLSL dot man page + /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions + template typename genType::value_type dot( genType const & x, genType const & y); @@ -76,18 +76,18 @@ namespace glm /// Returns the cross product of x and y. /// /// @tparam valType Floating-point scalar types. - /// - /// @see GLSL cross man page - /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions - template + /// + /// @see GLSL cross man page + /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions + template detail::tvec3 cross( detail::tvec3 const & x, detail::tvec3 const & y); /// Returns a vector in the same direction as x but with length of 1. - /// - /// @see GLSL normalize man page - /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions + /// + /// @see GLSL normalize man page + /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions template genType normalize( genType const & x); @@ -95,36 +95,36 @@ namespace glm /// If dot(Nref, I) < 0.0, return N, otherwise, return -N. /// /// @tparam genType Floating-point vector types. - /// - /// @see GLSL faceforward man page - /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions - template + /// + /// @see GLSL faceforward man page + /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions + template genType faceforward( genType const & N, genType const & I, genType const & Nref); - + /// For the incident vector I and surface orientation N, /// returns the reflection direction : result = I - 2.0 * dot(N, I) * N. /// /// @tparam genType Floating-point vector types. - /// - /// @see GLSL reflect man page - /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions - template + /// + /// @see GLSL reflect man page + /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions + template genType reflect( genType const & I, genType const & N); - + /// For the incident vector I and surface normal N, /// and the ratio of indices of refraction eta, /// return the refraction vector. /// /// @tparam genType Floating-point vector types. - /// - /// @see GLSL refract man page - /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions - template + /// + /// @see GLSL refract man page + /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions + template genType refract( genType const & I, genType const & N, diff --git a/glm/core/func_geometric.inl b/glm/core/func_geometric.inl index b13fe3a4..1923d05d 100644 --- a/glm/core/func_geometric.inl +++ b/glm/core/func_geometric.inl @@ -28,67 +28,67 @@ namespace glm { - // length - template + // length + template GLM_FUNC_QUALIFIER genType length ( genType const & x ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'length' only accept floating-point inputs"); - genType sqr = x * x; - return sqrt(sqr); - } + genType sqr = x * x; + return sqrt(sqr); + } template GLM_FUNC_QUALIFIER typename detail::tvec2::value_type length ( detail::tvec2 const & v ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'length' only accept floating-point inputs"); - typename detail::tvec2::value_type sqr = v.x * v.x + v.y * v.y; - return sqrt(sqr); - } + typename detail::tvec2::value_type sqr = v.x * v.x + v.y * v.y; + return sqrt(sqr); + } - template - GLM_FUNC_QUALIFIER typename detail::tvec3::value_type length + template + GLM_FUNC_QUALIFIER typename detail::tvec3::value_type length ( detail::tvec3 const & v ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'length' only accept floating-point inputs"); - typename detail::tvec3::value_type sqr = v.x * v.x + v.y * v.y + v.z * v.z; - return sqrt(sqr); - } + typename detail::tvec3::value_type sqr = v.x * v.x + v.y * v.y + v.z * v.z; + return sqrt(sqr); + } - template - GLM_FUNC_QUALIFIER typename detail::tvec4::value_type length + template + GLM_FUNC_QUALIFIER typename detail::tvec4::value_type length ( detail::tvec4 const & v ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'length' only accept floating-point inputs"); - typename detail::tvec4::value_type sqr = v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w; - return sqrt(sqr); - } + typename detail::tvec4::value_type sqr = v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w; + return sqrt(sqr); + } - // distance + // distance template - GLM_FUNC_QUALIFIER genType distance + GLM_FUNC_QUALIFIER genType distance ( genType const & p0, genType const & p1 ) - { - GLM_STATIC_ASSERT(detail::type::is_float, "'distance' only accept floating-point inputs"); + { + GLM_STATIC_ASSERT(detail::type::is_float, "'distance' only accept floating-point inputs"); return length(p1 - p0); - } + } template GLM_FUNC_QUALIFIER typename detail::tvec2::value_type distance @@ -96,35 +96,35 @@ namespace glm detail::tvec2 const & p0, detail::tvec2 const & p1 ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'distance' only accept floating-point inputs"); - return length(p1 - p0); - } + return length(p1 - p0); + } - template - GLM_FUNC_QUALIFIER typename detail::tvec3::value_type distance + template + GLM_FUNC_QUALIFIER typename detail::tvec3::value_type distance ( detail::tvec3 const & p0, detail::tvec3 const & p1 ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'distance' only accept floating-point inputs"); return length(p1 - p0); - } + } - template - GLM_FUNC_QUALIFIER typename detail::tvec4::value_type distance + template + GLM_FUNC_QUALIFIER typename detail::tvec4::value_type distance ( detail::tvec4 const & p0, detail::tvec4 const & p1 ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'distance' only accept floating-point inputs"); return length(p1 - p0); - } + } // dot template @@ -140,124 +140,124 @@ namespace glm return x * y; } - template + template GLM_FUNC_QUALIFIER typename detail::tvec2::value_type dot ( detail::tvec2 const & x, detail::tvec2 const & y ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'dot' only accept floating-point inputs"); return x.x * y.x + x.y * y.y; - } + } - template - GLM_FUNC_QUALIFIER T dot + template + GLM_FUNC_QUALIFIER T dot ( detail::tvec3 const & x, detail::tvec3 const & y ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'dot' only accept floating-point inputs"); return x.x * y.x + x.y * y.y + x.z * y.z; - } + } /* // SSE3 - GLM_FUNC_QUALIFIER float dot(const tvec4& x, const tvec4& y) - { - float Result; - __asm - { - mov esi, x - mov edi, y - movaps xmm0, [esi] - mulps xmm0, [edi] - haddps( _xmm0, _xmm0 ) - haddps( _xmm0, _xmm0 ) - movss Result, xmm0 - } - return Result; - } + GLM_FUNC_QUALIFIER float dot(const tvec4& x, const tvec4& y) + { + float Result; + __asm + { + mov esi, x + mov edi, y + movaps xmm0, [esi] + mulps xmm0, [edi] + haddps( _xmm0, _xmm0 ) + haddps( _xmm0, _xmm0 ) + movss Result, xmm0 + } + return Result; + } */ - template - GLM_FUNC_QUALIFIER T dot + template + GLM_FUNC_QUALIFIER T dot ( detail::tvec4 const & x, detail::tvec4 const & y ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'dot' only accept floating-point inputs"); - return x.x * y.x + x.y * y.y + x.z * y.z + x.w * y.w; - } + return x.x * y.x + x.y * y.y + x.z * y.z + x.w * y.w; + } - // cross - template - GLM_FUNC_QUALIFIER detail::tvec3 cross + // cross + template + GLM_FUNC_QUALIFIER detail::tvec3 cross ( detail::tvec3 const & x, detail::tvec3 const & y ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'cross' only accept floating-point inputs"); - return detail::tvec3( - x.y * y.z - y.y * x.z, - x.z * y.x - y.z * x.x, - x.x * y.y - y.x * x.y); - } + return detail::tvec3( + x.y * y.z - y.y * x.z, + x.z * y.x - y.z * x.x, + x.x * y.y - y.x * x.y); + } - // normalize - template - GLM_FUNC_QUALIFIER genType normalize + // normalize + template + GLM_FUNC_QUALIFIER genType normalize ( genType const & x ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'normalize' only accept floating-point inputs"); - return x < genType(0) ? genType(-1) : genType(1); - } + return x < genType(0) ? genType(-1) : genType(1); + } - // According to issue 10 GLSL 1.10 specification, if length(x) == 0 then result is undefine and generate an error - template - GLM_FUNC_QUALIFIER detail::tvec2 normalize + // According to issue 10 GLSL 1.10 specification, if length(x) == 0 then result is undefine and generate an error + template + GLM_FUNC_QUALIFIER detail::tvec2 normalize ( detail::tvec2 const & x ) - { + { GLM_STATIC_ASSERT(detail::type::is_float, "'normalize' only accept floating-point inputs"); typename detail::tvec2::value_type sqr = x.x * x.x + x.y * x.y; - return x * inversesqrt(sqr); - } + return x * inversesqrt(sqr); + } - template - GLM_FUNC_QUALIFIER detail::tvec3 normalize + template + GLM_FUNC_QUALIFIER detail::tvec3 normalize ( detail::tvec3 const & x ) - { - GLM_STATIC_ASSERT(detail::type::is_float, "'normalize' only accept floating-point inputs"); + { + GLM_STATIC_ASSERT(detail::type::is_float, "'normalize' only accept floating-point inputs"); typename detail::tvec3::value_type sqr = x.x * x.x + x.y * x.y + x.z * x.z; - return x * inversesqrt(sqr); - } + return x * inversesqrt(sqr); + } - template - GLM_FUNC_QUALIFIER detail::tvec4 normalize + template + GLM_FUNC_QUALIFIER detail::tvec4 normalize ( detail::tvec4 const & x ) - { - GLM_STATIC_ASSERT(detail::type::is_float, "'normalize' only accept floating-point inputs"); + { + GLM_STATIC_ASSERT(detail::type::is_float, "'normalize' only accept floating-point inputs"); typename detail::tvec4::value_type sqr = x.x * x.x + x.y * x.y + x.z * x.z + x.w * x.w; - return x * inversesqrt(sqr); - } + return x * inversesqrt(sqr); + } - // faceforward + // faceforward template GLM_FUNC_QUALIFIER genType faceforward ( @@ -280,43 +280,43 @@ namespace glm return I - N * dot(N, I) * genType(2); } - // refract - template - GLM_FUNC_QUALIFIER genType refract + // refract + template + GLM_FUNC_QUALIFIER genType refract ( genType const & I, genType const & N, genType const & eta ) - { + { //It could be a vector //GLM_STATIC_ASSERT(detail::type::is_float); - genType dotValue = dot(N, I); - genType k = genType(1) - eta * eta * (genType(1) - dotValue * dotValue); - if(k < genType(0)) - return genType(0); - else - return eta * I - (eta * dotValue + sqrt(k)) * N; - } + genType dotValue = dot(N, I); + genType k = genType(1) - eta * eta * (genType(1) - dotValue * dotValue); + if(k < genType(0)) + return genType(0); + else + return eta * I - (eta * dotValue + sqrt(k)) * N; + } - template - GLM_FUNC_QUALIFIER genType refract + template + GLM_FUNC_QUALIFIER genType refract ( genType const & I, genType const & N, typename genType::value_type const & eta ) - { + { //It could be a vector //GLM_STATIC_ASSERT(detail::type::is_float); - typename genType::value_type dotValue = dot(N, I); - typename genType::value_type k = typename genType::value_type(1) - eta * eta * (typename genType::value_type(1) - dotValue * dotValue); - if(k < typename genType::value_type(0)) - return genType(0); - else - return eta * I - (eta * dotValue + sqrt(k)) * N; - } + typename genType::value_type dotValue = dot(N, I); + typename genType::value_type k = typename genType::value_type(1) - eta * eta * (typename genType::value_type(1) - dotValue * dotValue); + if(k < typename genType::value_type(0)) + return genType(0); + else + return eta * I - (eta * dotValue + sqrt(k)) * N; + } }//namespace glm diff --git a/glm/core/func_integer.hpp b/glm/core/func_integer.hpp index 1044e273..affbcd8f 100644 --- a/glm/core/func_integer.hpp +++ b/glm/core/func_integer.hpp @@ -49,8 +49,8 @@ namespace glm /// /// @tparam genUType Unsigned integer scalar or vector types. /// - /// @see GLSL uaddCarry man page - /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions + /// @see GLSL uaddCarry man page + /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions template genUType uaddCarry( genUType const & x, @@ -63,8 +63,8 @@ namespace glm /// /// @tparam genUType Unsigned integer scalar or vector types. /// - /// @see GLSL usubBorrow man page - /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions + /// @see GLSL usubBorrow man page + /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions template genUType usubBorrow( genUType const & x, @@ -77,8 +77,8 @@ namespace glm /// /// @tparam genUType Unsigned integer scalar or vector types. /// - /// @see GLSL umulExtended man page - /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions + /// @see GLSL umulExtended man page + /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions template void umulExtended( genUType const & x, @@ -92,8 +92,8 @@ namespace glm /// /// @tparam genIType Signed integer scalar or vector types. /// - /// @see GLSL imulExtended man page - /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions + /// @see GLSL imulExtended man page + /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions template void imulExtended( genIType const & x, @@ -114,8 +114,8 @@ namespace glm /// /// @tparam genIUType Signed or unsigned integer scalar or vector types. /// - /// @see GLSL bitfieldExtract man page - /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions + /// @see GLSL bitfieldExtract man page + /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions template genIUType bitfieldExtract( genIUType const & Value, @@ -134,7 +134,7 @@ namespace glm /// /// @tparam genIUType Signed or unsigned integer scalar or vector types. /// - /// @see GLSL bitfieldInsert man page + /// @see GLSL bitfieldInsert man page /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions template genIUType bitfieldInsert( @@ -149,8 +149,8 @@ namespace glm /// /// @tparam genIUType Signed or unsigned integer scalar or vector types. /// - /// @see GLSL bitfieldReverse man page - /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions + /// @see GLSL bitfieldReverse man page + /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions template genIUType bitfieldReverse(genIUType const & Value); @@ -158,8 +158,8 @@ namespace glm /// /// @tparam genIUType Signed or unsigned integer scalar or vector types. /// - /// @see GLSL bitCount man page - /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions + /// @see GLSL bitCount man page + /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions /// /// @todo Clarify the declaration to specify that scalars are suported. template class genIUType> @@ -171,8 +171,8 @@ namespace glm /// /// @tparam genIUType Signed or unsigned integer scalar or vector types. /// - /// @see GLSL findLSB man page - /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions + /// @see GLSL findLSB man page + /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions /// /// @todo Clarify the declaration to specify that scalars are suported. template class genIUType> @@ -185,8 +185,8 @@ namespace glm /// /// @tparam genIUType Signed or unsigned integer scalar or vector types. /// - /// @see GLSL findMSB man page - /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions + /// @see GLSL findMSB man page + /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions /// /// @todo Clarify the declaration to specify that scalars are suported. template class genIUType> diff --git a/glm/core/func_matrix.hpp b/glm/core/func_matrix.hpp index 41acf596..ac1fda84 100644 --- a/glm/core/func_matrix.hpp +++ b/glm/core/func_matrix.hpp @@ -49,9 +49,9 @@ namespace glm /// result[i][j] is the scalar product of x[i][j] and y[i][j]. /// /// @tparam matType Floating-point matrix types. - /// - /// @see GLSL matrixCompMult man page - /// @see GLSL 4.20.8 specification, section 8.6 Matrix Functions + /// + /// @see GLSL matrixCompMult man page + /// @see GLSL 4.20.8 specification, section 8.6 Matrix Functions template matType matrixCompMult( matType const & x, @@ -62,12 +62,12 @@ namespace glm /// and does a linear algebraic matrix multiply c * r. /// /// @tparam matType Floating-point matrix types. - /// - /// @see GLSL outerProduct man page - /// @see GLSL 4.20.8 specification, section 8.6 Matrix Functions + /// + /// @see GLSL outerProduct man page + /// @see GLSL 4.20.8 specification, section 8.6 Matrix Functions /// /// @todo Clarify the declaration to specify that matType doesn't have to be provided when used. - template + template matType outerProduct( vecType const & c, vecType const & r); @@ -75,19 +75,19 @@ namespace glm /// Returns the transposed matrix of x /// /// @tparam matType Floating-point matrix types. - /// - /// @see GLSL transpose man page - /// @see GLSL 4.20.8 specification, section 8.6 Matrix Functions - template + /// + /// @see GLSL transpose man page + /// @see GLSL 4.20.8 specification, section 8.6 Matrix Functions + template typename matType::transpose_type transpose( matType const & x); /// Return the determinant of a mat2 matrix. /// /// @tparam valType Floating-point scalar types. - /// - /// @see GLSL determinant man page - /// @see GLSL 4.20.8 specification, section 8.6 Matrix Functions + /// + /// @see GLSL determinant man page + /// @see GLSL 4.20.8 specification, section 8.6 Matrix Functions template typename detail::tmat2x2::value_type determinant( detail::tmat2x2 const & m); @@ -95,9 +95,9 @@ namespace glm /// Return the determinant of a mat3 matrix. /// /// @tparam valType Floating-point scalar types. - /// - /// @see GLSL determinant man page - /// @see GLSL 4.20.8 specification, section 8.6 Matrix Functions + /// + /// @see GLSL determinant man page + /// @see GLSL 4.20.8 specification, section 8.6 Matrix Functions template typename detail::tmat3x3::value_type determinant( detail::tmat3x3 const & m); @@ -105,19 +105,19 @@ namespace glm /// Return the determinant of a mat4 matrix. /// /// @tparam valType Floating-point scalar types. - /// - /// @see GLSL determinant man page - /// @see GLSL 4.20.8 specification, section 8.6 Matrix Functions - template + /// + /// @see GLSL determinant man page + /// @see GLSL 4.20.8 specification, section 8.6 Matrix Functions + template typename detail::tmat4x4::value_type determinant( detail::tmat4x4 const & m); /// Return the inverse of a mat2 matrix. /// /// @tparam valType Floating-point scalar types. - /// - /// @see GLSL inverse man page - /// @see GLSL 4.20.8 specification, section 8.6 Matrix Functions + /// + /// @see GLSL inverse man page + /// @see GLSL 4.20.8 specification, section 8.6 Matrix Functions template detail::tmat2x2 inverse( detail::tmat2x2 const & m); @@ -125,9 +125,9 @@ namespace glm /// Return the inverse of a mat3 matrix. /// /// @tparam valType Floating-point scalar types. - /// - /// @see GLSL inverse man page - /// @see GLSL 4.20.8 specification, section 8.6 Matrix Functions + /// + /// @see GLSL inverse man page + /// @see GLSL 4.20.8 specification, section 8.6 Matrix Functions template detail::tmat3x3 inverse( detail::tmat3x3 const & m); @@ -135,9 +135,9 @@ namespace glm /// Return the inverse of a mat4 matrix. /// /// @tparam valType Floating-point scalar types. - /// - /// @see GLSL inverse man page - /// @see GLSL 4.20.8 specification, section 8.6 Matrix Functions + /// + /// @see GLSL inverse man page + /// @see GLSL 4.20.8 specification, section 8.6 Matrix Functions template detail::tmat4x4 inverse( detail::tmat4x4 const & m); diff --git a/glm/core/func_matrix.inl b/glm/core/func_matrix.inl index 2d18547a..3b07b74b 100644 --- a/glm/core/func_matrix.inl +++ b/glm/core/func_matrix.inl @@ -576,7 +576,7 @@ namespace glm T Determinant = glm::dot(m[0], Row0); Inverse /= Determinant; - + return Inverse; } }//namespace glm diff --git a/glm/core/func_noise.hpp b/glm/core/func_noise.hpp index 296554e1..369f56de 100644 --- a/glm/core/func_noise.hpp +++ b/glm/core/func_noise.hpp @@ -46,8 +46,8 @@ namespace glm /// Returns a 1D noise value based on the input value x. /// /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL noise1 man page + /// + /// @see GLSL noise1 man page /// @see GLSL 4.20.8 specification, section 8.13 Noise Functions template typename genType::value_type noise1(genType const & x); @@ -55,27 +55,27 @@ namespace glm /// Returns a 2D noise value based on the input value x. /// /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL noise2 man page - /// @see GLSL 4.20.8 specification, section 8.13 Noise Functions + /// + /// @see GLSL noise2 man page + /// @see GLSL 4.20.8 specification, section 8.13 Noise Functions template detail::tvec2 noise2(genType const & x); /// Returns a 3D noise value based on the input value x. /// /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL noise3 man page - /// @see GLSL 4.20.8 specification, section 8.13 Noise Functions + /// + /// @see GLSL noise3 man page + /// @see GLSL 4.20.8 specification, section 8.13 Noise Functions template detail::tvec3 noise3(genType const & x); /// Returns a 4D noise value based on the input value x. /// /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL noise4 man page - /// @see GLSL 4.20.8 specification, section 8.13 Noise Functions + /// + /// @see GLSL noise4 man page + /// @see GLSL 4.20.8 specification, section 8.13 Noise Functions template detail::tvec4 noise4(genType const & x); diff --git a/glm/core/func_noise.inl b/glm/core/func_noise.inl index af197e41..a53ba5a7 100644 --- a/glm/core/func_noise.inl +++ b/glm/core/func_noise.inl @@ -27,7 +27,7 @@ /////////////////////////////////////////////////////////////////////////////////// namespace glm -{ +{ template GLM_FUNC_QUALIFIER T noise1(T const & x) { diff --git a/glm/core/func_packing.hpp b/glm/core/func_packing.hpp index 91582b23..e4f26dcb 100644 --- a/glm/core/func_packing.hpp +++ b/glm/core/func_packing.hpp @@ -37,142 +37,141 @@ #define GLM_CORE_func_packing GLM_VERSION namespace glm -{ +{ /// @addtogroup core_func_packing /// @{ - //! First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values. - //! Then, the results are packed into the returned 32-bit unsigned integer. - //! - //! The conversion for component c of v to fixed point is done as follows: - //! packUnorm2x16: round(clamp(c, 0, +1) * 65535.0) - //! - //! The first component of the vector will be written to the least significant bits of the output; - //! the last component will be written to the most significant bits. - //! - /// @see GLSL packUnorm2x16 man page - /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions + //! First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values. + //! Then, the results are packed into the returned 32-bit unsigned integer. + //! + //! The conversion for component c of v to fixed point is done as follows: + //! packUnorm2x16: round(clamp(c, 0, +1) * 65535.0) + //! + //! The first component of the vector will be written to the least significant bits of the output; + //! the last component will be written to the most significant bits. + //! + /// @see GLSL packUnorm2x16 man page + /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions detail::uint32 packUnorm2x16(detail::tvec2 const & v); - //! First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values. - //! Then, the results are packed into the returned 32-bit unsigned integer. - //! - //! The conversion for component c of v to fixed point is done as follows: - //! packSnorm2x16: round(clamp(v, -1, +1) * 32767.0) - //! - //! The first component of the vector will be written to the least significant bits of the output; - //! the last component will be written to the most significant bits. - //! - /// @see GLSL packSnorm2x16 man page - /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions + //! First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values. + //! Then, the results are packed into the returned 32-bit unsigned integer. + //! + //! The conversion for component c of v to fixed point is done as follows: + //! packSnorm2x16: round(clamp(v, -1, +1) * 32767.0) + //! + //! The first component of the vector will be written to the least significant bits of the output; + //! the last component will be written to the most significant bits. + //! + /// @see GLSL packSnorm2x16 man page + /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions detail::uint32 packSnorm2x16(detail::tvec2 const & v); - - //! First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values. - //! Then, the results are packed into the returned 32-bit unsigned integer. - //! - //! The conversion for component c of v to fixed point is done as follows: - //! packUnorm4x8: round(clamp(c, 0, +1) * 255.0) - //! - //! The first component of the vector will be written to the least significant bits of the output; - //! the last component will be written to the most significant bits. - //! - /// @see GLSL packUnorm4x8 man page - /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions + + //! First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values. + //! Then, the results are packed into the returned 32-bit unsigned integer. + //! + //! The conversion for component c of v to fixed point is done as follows: + //! packUnorm4x8: round(clamp(c, 0, +1) * 255.0) + //! + //! The first component of the vector will be written to the least significant bits of the output; + //! the last component will be written to the most significant bits. + //! + /// @see GLSL packUnorm4x8 man page + /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions detail::uint32 packUnorm4x8(detail::tvec4 const & v); - - //! First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values. - //! Then, the results are packed into the returned 32-bit unsigned integer. - //! - //! The conversion for component c of v to fixed point is done as follows: - //! packSnorm4x8: round(clamp(c, -1, +1) * 127.0) - //! - //! The first component of the vector will be written to the least significant bits of the output; - //! the last component will be written to the most significant bits. - //! - /// @see GLSL packSnorm4x8 man page - /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions + + //! First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values. + //! Then, the results are packed into the returned 32-bit unsigned integer. + //! + //! The conversion for component c of v to fixed point is done as follows: + //! packSnorm4x8: round(clamp(c, -1, +1) * 127.0) + //! + //! The first component of the vector will be written to the least significant bits of the output; + //! the last component will be written to the most significant bits. + //! + /// @see GLSL packSnorm4x8 man page + /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions detail::uint32 packSnorm4x8(detail::tvec4 const & v); - //! First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers. - //! Then, each component is converted to a normalized floating-point value to generate the returned two- or four-component vector. - //! - //! The conversion for unpacked fixed-point value f to floating point is done as follows: - //! unpackUnorm2x16: f / 65535.0 - //! - //! The first component of the returned vector will be extracted from the least significant bits of the input; - //! the last component will be extracted from the most significant bits. - //! - /// @see GLSL unpackUnorm2x16 man page - /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions + //! First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers. + //! Then, each component is converted to a normalized floating-point value to generate the returned two- or four-component vector. + //! + //! The conversion for unpacked fixed-point value f to floating point is done as follows: + //! unpackUnorm2x16: f / 65535.0 + //! + //! The first component of the returned vector will be extracted from the least significant bits of the input; + //! the last component will be extracted from the most significant bits. + //! + /// @see GLSL unpackUnorm2x16 man page + /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions detail::tvec2 unpackUnorm2x16(detail::uint32 const & p); - //! First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers. - //! Then, each component is converted to a normalized floating-point value to generate the returned two- or four-component vector. - //! - //! The conversion for unpacked fixed-point value f to floating point is done as follows: - //! unpackSnorm2x16: clamp(f / 32767.0, -1, +1) - //! - //! The first component of the returned vector will be extracted from the least significant bits of the input; - //! the last component will be extracted from the most significant bits. - //! - /// @see GLSL unpackSnorm2x16 man page - /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions + //! First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers. + //! Then, each component is converted to a normalized floating-point value to generate the returned two- or four-component vector. + //! + //! The conversion for unpacked fixed-point value f to floating point is done as follows: + //! unpackSnorm2x16: clamp(f / 32767.0, -1, +1) + //! + //! The first component of the returned vector will be extracted from the least significant bits of the input; + //! the last component will be extracted from the most significant bits. + //! + /// @see GLSL unpackSnorm2x16 man page + /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions detail::tvec2 unpackSnorm2x16(detail::uint32 const & p); - - /// First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers. - /// Then, each component is converted to a normalized floating-point value to generate the returned two- or four-component vector. - /// - /// The conversion for unpacked fixed-point value f to floating point is done as follows: - /// unpackUnorm4x8: f / 255.0 - /// - /// The first component of the returned vector will be extracted from the least significant bits of the input; - /// the last component will be extracted from the most significant bits. - /// - /// @see GLSL unpackUnorm4x8 man page - /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions - detail::tvec4 unpackUnorm4x8(detail::uint32 const & p); - - /// First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers. - /// Then, each component is converted to a normalized floating-point value to generate the returned two- or four-component vector. - /// - /// The conversion for unpacked fixed-point value f to floating point is done as follows: - /// unpackSnorm4x8: clamp(f / 127.0, -1, +1) - /// - /// The first component of the returned vector will be extracted from the least significant bits of the input; - /// the last component will be extracted from the most significant bits. - /// - /// @see GLSL unpackSnorm4x8 man page - /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions + + /// First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers. + /// Then, each component is converted to a normalized floating-point value to generate the returned two- or four-component vector. + /// + /// The conversion for unpacked fixed-point value f to floating point is done as follows: + /// unpackUnorm4x8: f / 255.0 + /// + /// The first component of the returned vector will be extracted from the least significant bits of the input; + /// the last component will be extracted from the most significant bits. + /// + /// @see GLSL unpackUnorm4x8 man page + /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions + detail::tvec4 unpackUnorm4x8(detail::uint32 const & p); + + /// First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers. + /// Then, each component is converted to a normalized floating-point value to generate the returned two- or four-component vector. + /// + /// The conversion for unpacked fixed-point value f to floating point is done as follows: + /// unpackSnorm4x8: clamp(f / 127.0, -1, +1) + /// + /// The first component of the returned vector will be extracted from the least significant bits of the input; + /// the last component will be extracted from the most significant bits. + /// + /// @see GLSL unpackSnorm4x8 man page + /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions detail::tvec4 unpackSnorm4x8(detail::uint32 const & p); - /// Returns a double-precision value obtained by packing the components of v into a 64-bit value. - /// If an IEEE 754 Inf or NaN is created, it will not signal, and the resulting floating point value is unspecified. - /// Otherwise, the bit- level representation of v is preserved. - /// The first vector component specifies the 32 least significant bits; - /// the second component specifies the 32 most significant bits. - /// - /// @see GLSL packDouble2x32 man page - /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions + /// Returns a double-precision value obtained by packing the components of v into a 64-bit value. + /// If an IEEE 754 Inf or NaN is created, it will not signal, and the resulting floating point value is unspecified. + /// Otherwise, the bit- level representation of v is preserved. + /// The first vector component specifies the 32 least significant bits; + /// the second component specifies the 32 most significant bits. + /// + /// @see GLSL packDouble2x32 man page + /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions double packDouble2x32(detail::tvec2 const & v); - - /// Returns a two-component unsigned integer vector representation of v. - /// The bit-level representation of v is preserved. - /// The first component of the vector contains the 32 least significant bits of the double; - /// the second component consists the 32 most significant bits. - /// - /// @see GLSL unpackDouble2x32 man page - /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions + + /// Returns a two-component unsigned integer vector representation of v. + /// The bit-level representation of v is preserved. + /// The first component of the vector contains the 32 least significant bits of the double; + /// the second component consists the 32 most significant bits. + /// + /// @see GLSL unpackDouble2x32 man page + /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions detail::tvec2 unpackDouble2x32(double const & v); - /// Returns an unsigned integer obtained by converting the components of a two-component floating-point vector /// to the 16-bit floating-point representation found in the OpenGL Specification, /// and then packing these two 16- bit integers into a 32-bit unsigned integer. /// The first vector component specifies the 16 least-significant bits of the result; /// the second component specifies the 16 most-significant bits. - /// - /// @see GLSL packHalf2x16 man page - /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions + /// + /// @see GLSL packHalf2x16 man page + /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions uint packHalf2x16(vec2 const & v); /// Returns a two-component floating-point vector with components obtained by unpacking a 32-bit unsigned integer into a pair of 16-bit values, @@ -180,9 +179,9 @@ namespace glm /// and converting them to 32-bit floating-point values. /// The first component of the vector is obtained from the 16 least-significant bits of v; /// the second component is obtained from the 16 most-significant bits of v. - /// - /// @see GLSL unpackHalf2x16 man page - /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions + /// + /// @see GLSL unpackHalf2x16 man page + /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions vec2 unpackHalf2x16(uint const & v); /// @} diff --git a/glm/core/func_packing.inl b/glm/core/func_packing.inl index b025895a..27197151 100644 --- a/glm/core/func_packing.inl +++ b/glm/core/func_packing.inl @@ -146,32 +146,32 @@ namespace glm GLM_FUNC_QUALIFIER uint packHalf2x16(detail::tvec2 const & v) { - union helper - { - uint other; - struct - { - detail::hdata a, b; - } orig; - } Pack; + union helper + { + uint other; + struct + { + detail::hdata a, b; + } orig; + } Pack; - Pack.orig.a = detail::toFloat16(v.x); - Pack.orig.b = detail::toFloat16(v.y); + Pack.orig.a = detail::toFloat16(v.x); + Pack.orig.b = detail::toFloat16(v.y); return *(uint*)&Pack; } GLM_FUNC_QUALIFIER vec2 unpackHalf2x16(uint const & v) { - union helper - { - uint other; - struct - { - detail::hdata a, b; - } orig; - } Unpack; - Unpack.other = v; - + union helper + { + uint other; + struct + { + detail::hdata a, b; + } orig; + } Unpack; + Unpack.other = v; + return vec2(detail::toFloat32(Unpack.orig.a), detail::toFloat32(Unpack.orig.b)); } }//namespace glm diff --git a/glm/core/func_trigonometric.hpp b/glm/core/func_trigonometric.hpp index ba57cb67..ccb7f9ea 100644 --- a/glm/core/func_trigonometric.hpp +++ b/glm/core/func_trigonometric.hpp @@ -48,18 +48,18 @@ namespace glm /// Converts degrees to radians and returns the result. /// /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL radians man page - /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions + /// + /// @see GLSL radians man page + /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions template genType radians(genType const & degrees); /// Converts radians to degrees and returns the result. - /// + /// /// @tparam genType Floating-point scalar or vector types. /// - /// @see GLSL degrees man page - /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions + /// @see GLSL degrees man page + /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions template genType degrees(genType const & radians); @@ -67,9 +67,9 @@ namespace glm /// The values returned by this function will range from [-1, 1]. /// /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL sin man page - /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions + /// + /// @see GLSL sin man page + /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions template genType sin(genType const & angle); @@ -77,40 +77,40 @@ namespace glm /// The values returned by this function will range from [-1, 1]. /// /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL cos man page - /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions + /// + /// @see GLSL cos man page + /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions template genType cos(genType const & angle); /// The standard trigonometric tangent function. - /// + /// /// @tparam genType Floating-point scalar or vector types. /// - /// @see GLSL tan man page - /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions + /// @see GLSL tan man page + /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions template genType tan(genType const & angle); /// Arc sine. Returns an angle whose sine is x. /// The range of values returned by this function is [-PI/2, PI/2]. /// Results are undefined if |x| > 1. - /// + /// /// @tparam genType Floating-point scalar or vector types. /// - /// @see GLSL asin man page - /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions + /// @see GLSL asin man page + /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions template genType asin(genType const & x); /// Arc cosine. Returns an angle whose sine is x. /// The range of values returned by this function is [0, PI]. /// Results are undefined if |x| > 1. - /// + /// /// @tparam genType Floating-point scalar or vector types. /// - /// @see GLSL acos man page - /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions + /// @see GLSL acos man page + /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions template genType acos(genType const & x); @@ -119,67 +119,67 @@ namespace glm /// quadrant the angle is in. The range of values returned /// by this function is [-PI, PI]. Results are undefined /// if x and y are both 0. - /// + /// /// @tparam genType Floating-point scalar or vector types. /// - /// @see GLSL atan man page - /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions + /// @see GLSL atan man page + /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions template genType atan(genType const & y, genType const & x); /// Arc tangent. Returns an angle whose tangent is y_over_x. /// The range of values returned by this function is [-PI/2, PI/2]. - /// + /// /// @tparam genType Floating-point scalar or vector types. /// - /// @see GLSL atan man page + /// @see GLSL atan man page /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions template genType atan(genType const & y_over_x); /// Returns the hyperbolic sine function, (exp(x) - exp(-x)) / 2 - /// + /// /// @tparam genType Floating-point scalar or vector types. /// - /// @see GLSL sinh man page - /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions + /// @see GLSL sinh man page + /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions template genType sinh(genType const & angle); /// Returns the hyperbolic cosine function, (exp(x) + exp(-x)) / 2 - /// + /// /// @tparam genType Floating-point scalar or vector types. /// - /// @see GLSL cosh man page - /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions + /// @see GLSL cosh man page + /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions template genType cosh(genType const & angle); /// Returns the hyperbolic tangent function, sinh(angle) / cosh(angle) - /// + /// /// @tparam genType Floating-point scalar or vector types. /// - /// @see GLSL tanh man page - /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions + /// @see GLSL tanh man page + /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions template genType tanh(genType const & angle); /// Arc hyperbolic sine; returns the inverse of sinh. - /// + /// /// @tparam genType Floating-point scalar or vector types. /// - /// @see GLSL asinh man page - /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions + /// @see GLSL asinh man page + /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions template genType asinh(genType const & x); /// Arc hyperbolic cosine; returns the non-negative inverse /// of cosh. Results are undefined if x < 1. - /// + /// /// @tparam genType Floating-point scalar or vector types. /// - /// @see GLSL acosh man page - /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions + /// @see GLSL acosh man page + /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions template genType acosh(genType const & x); @@ -187,9 +187,9 @@ namespace glm /// Results are undefined if abs(x) >= 1. /// /// @tparam genType Floating-point scalar or vector types. - /// - /// @see GLSL atanh man page - /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions + /// + /// @see GLSL atanh man page + /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions template genType atanh(genType const & x); diff --git a/glm/core/func_vector_relational.hpp b/glm/core/func_vector_relational.hpp index 8afba380..7b5a7cd0 100644 --- a/glm/core/func_vector_relational.hpp +++ b/glm/core/func_vector_relational.hpp @@ -51,82 +51,82 @@ namespace glm /// Returns the component-wise comparison result of x < y. /// /// @tparam vecType Floating-point or integer vector types. - /// - /// @see GLSL lessThan man page - /// @see GLSL 4.20.8 specification, section 8.7 Vector Relational Functions - template + /// + /// @see GLSL lessThan man page + /// @see GLSL 4.20.8 specification, section 8.7 Vector Relational Functions + template typename vecType::bool_type lessThan(vecType const & x, vecType const & y); /// Returns the component-wise comparison of result x <= y. - /// + /// /// @tparam vecType Floating-point or integer vector types. /// - /// @see GLSL lessThanEqual man page - /// @see GLSL 4.20.8 specification, section 8.7 Vector Relational Functions + /// @see GLSL lessThanEqual man page + /// @see GLSL 4.20.8 specification, section 8.7 Vector Relational Functions template typename vecType::bool_type lessThanEqual(vecType const & x, vecType const & y); /// Returns the component-wise comparison of result x > y. - /// + /// /// @tparam vecType Floating-point or integer vector types. /// - /// @see GLSL greaterThan man page - /// @see GLSL 4.20.8 specification, section 8.7 Vector Relational Functions + /// @see GLSL greaterThan man page + /// @see GLSL 4.20.8 specification, section 8.7 Vector Relational Functions template typename vecType::bool_type greaterThan(vecType const & x, vecType const & y); /// Returns the component-wise comparison of result x >= y. - /// + /// /// @tparam vecType Floating-point or integer vector types. /// - /// @see GLSL greaterThanEqual man page - /// @see GLSL 4.20.8 specification, section 8.7 Vector Relational Functions + /// @see GLSL greaterThanEqual man page + /// @see GLSL 4.20.8 specification, section 8.7 Vector Relational Functions template typename vecType::bool_type greaterThanEqual(vecType const & x, vecType const & y); /// Returns the component-wise comparison of result x == y. - /// + /// /// @tparam vecType Floating-point, integer or boolean vector types. /// - /// @see GLSL equal man page - /// @see GLSL 4.20.8 specification, section 8.7 Vector Relational Functions + /// @see GLSL equal man page + /// @see GLSL 4.20.8 specification, section 8.7 Vector Relational Functions template typename vecType::bool_type equal(vecType const & x, vecType const & y); /// Returns the component-wise comparison of result x != y. /// /// @tparam vecType Floating-point, integer or boolean vector types. - /// - /// @see GLSL notEqual man page - /// @see GLSL 4.20.8 specification, section 8.7 Vector Relational Functions + /// + /// @see GLSL notEqual man page + /// @see GLSL 4.20.8 specification, section 8.7 Vector Relational Functions template typename vecType::bool_type notEqual(vecType const & x, vecType const & y); /// Returns true if any component of x is true. /// /// @tparam vecType Boolean vector types. - /// - /// @see GLSL any man page - /// @see GLSL 4.20.8 specification, section 8.7 Vector Relational Functions + /// + /// @see GLSL any man page + /// @see GLSL 4.20.8 specification, section 8.7 Vector Relational Functions template