class vecType> - inline bool any(vecType const & v) - { - bool Result = false; - for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i) - Result = Result || v[i]; - return Result; - } - - //! Returns true if all components of x are true. - //! (From GLSL 1.30.08 specification, section 8.6) - template
class vecType> - inline bool all(vecType const & v) - { - bool Result = true; - for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i) - Result = Result && v[i]; - return Result; - } - - //! Returns the component-wise logical complement of x. - //! (From GLSL 1.30.08 specification, section 8.6) - template
class vecType, typename T, precision P> + GLM_FUNC_DECL vecType step( + T const & edge, + vecType const & x); + + /// Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and + /// performs smooth Hermite interpolation between 0 and 1 + /// when edge0 < x < edge1. This is useful in cases where + /// you would want a threshold function with a smooth + /// transition. This is equivalent to: + /// genType t; + /// t = clamp ((x - edge0) / (edge1 - edge0), 0, 1); + /// return t * t * (3 - 2 * t); + /// 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 + template + GLM_FUNC_DECL genType smoothstep( + genType const & edge0, + genType const & edge1, + genType const & x); + + template + GLM_FUNC_DECL genType smoothstep( + typename genType::value_type const & edge0, + typename genType::value_type const & edge1, + genType const & x); + + /// Returns true if x holds a NaN (not a number) + /// representation in the underlying implementation's set of + /// floating point representations. Returns false otherwise, + /// including for implementations with no NaN + /// 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 + template + GLM_FUNC_DECL typename genType::bool_type isnan(genType const & x); + + /// Returns true if x holds a positive infinity or negative + /// infinity representation in the underlying implementation's + /// 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 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL typename genType::bool_type isinf(genType const & x); + + /// Returns a signed integer value representing + /// the encoding of a floating-point value. The floating-point + /// value's bit-level representation is preserved. + /// + /// @see GLSL floatBitsToInt man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + GLM_FUNC_DECL int floatBitsToInt(float const & v); + + /// Returns a signed integer value representing + /// the encoding of a floating-point value. The floatingpoint + /// value's bit-level representation is preserved. + /// + /// @see GLSL floatBitsToInt man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template
class vecType, precision P> + GLM_FUNC_DECL vecType floatBitsToInt(vecType const & v); + + /// Returns a unsigned integer value representing + /// the encoding of a floating-point value. The floatingpoint + /// value's bit-level representation is preserved. + /// + /// @see GLSL floatBitsToUint man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + GLM_FUNC_DECL uint floatBitsToUint(float const & v); + + /// Returns a unsigned integer value representing + /// the encoding of a floating-point value. The floatingpoint + /// value's bit-level representation is preserved. + /// + /// @see GLSL floatBitsToUint man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template
class vecType, precision P> + GLM_FUNC_DECL vecType floatBitsToUint(vecType const & v); + + /// Returns a floating-point value corresponding to a signed + /// 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. + /// + /// @see GLSL intBitsToFloat man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + GLM_FUNC_DECL float intBitsToFloat(int const & v); + + /// Returns a floating-point value corresponding to a signed + /// 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. + /// + /// @see GLSL intBitsToFloat man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template
class vecType, precision P> + GLM_FUNC_DECL vecType intBitsToFloat(vecType const & v); + + /// 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. + /// + /// @see GLSL uintBitsToFloat man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + GLM_FUNC_DECL float uintBitsToFloat(uint const & v); + + /// 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. + /// + /// @see GLSL uintBitsToFloat man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template
class vecType, precision P> + GLM_FUNC_DECL vecType uintBitsToFloat(vecType const & v); + + /// 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 + template + GLM_FUNC_DECL genType fma(genType const & a, genType const & b, genType const & c); + + /// Splits x into a floating-point significand in the range + /// [0.5, 1.0) and an integral exponent of two, such that: + /// x = significand * exp(2, exponent) + /// + /// The significand is returned by the function and the + /// exponent is returned in the parameter exp. For a + /// floating-point value of zero, the significant and exponent + /// are both zero. For a floating-point value that is an + /// infinity or is not a number, the results are undefined. + /// + /// @tparam genType Floating-point scalar or vector types. + /// + /// @see GLSL frexp man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL genType frexp(genType const & x, genIType & exp); + + /// Builds a floating-point number from x and the + /// corresponding integral exponent of two in exp, returning: + /// significand * exp(2, exponent) + /// + /// If this product is too large to be represented in the + /// floating-point type, the result is undefined. + /// + /// @tparam genType Floating-point scalar or vector types. + /// + /// @see GLSL ldexp man page; + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL genType ldexp(genType const & x, genIType const & exp); + + /// @} +}//namespace glm + +#include "func_common.inl" + +#endif//GLM_FUNC_COMMON_INCLUDED diff --git a/ThirdParty/include/glm/detail/func_common.inl b/ThirdParty/include/glm/detail/func_common.inl new file mode 100644 index 0000000000000000000000000000000000000000..2a6658d6193b17ee3fbeefdaccf366a745687820 --- /dev/null +++ b/ThirdParty/include/glm/detail/func_common.inl @@ -0,0 +1,1036 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/core/func_common.inl +/// @date 2008-08-03 / 2011-06-15 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +#include "func_vector_relational.hpp" +#include "type_vec2.hpp" +#include "type_vec3.hpp" +#include "type_vec4.hpp" +#include "_vectorize.hpp" +#include + +namespace glm{ +namespace detail +{ + template + struct compute_abs + {}; + + template + struct compute_abs + { + GLM_FUNC_QUALIFIER static genFIType call(genFIType const & x) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559 || std::numeric_limits::is_signed, + "'abs' only accept floating-point and integer scalar or vector inputs"); + return x >= genFIType(0) ? x : -x; + // TODO, perf comp with: *(((int *) &x) + 1) &= 0x7fffffff; + } + }; + + template + struct compute_abs + { + GLM_FUNC_QUALIFIER static genFIType call(genFIType const & x) + { + GLM_STATIC_ASSERT( + !std::numeric_limits::is_signed && std::numeric_limits::is_integer, + "'abs' only accept floating-point and integer scalar or vector inputs"); + return x; + } + }; + + template class vecType> + struct compute_mix_vector + { + GLM_FUNC_QUALIFIER static vecType call(vecType const & x, vecType const & y, vecType const & a) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'mix' only accept floating-point inputs for the interpolator a"); + + return vecType(vecType(x) + a * vecType(y - x)); + } + }; + + template class vecType> + struct compute_mix_vector + { + GLM_FUNC_QUALIFIER static vecType call(vecType const & x, vecType const & y, vecType const & a) + { + vecType Result; + for(length_t i = 0; i < x.length(); ++i) + Result[i] = a[i] ? y[i] : x[i]; + return Result; + } + }; + + template class vecType> + struct compute_mix_scalar + { + GLM_FUNC_QUALIFIER static vecType call(vecType const & x, vecType const & y, U const & a) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'mix' only accept floating-point inputs for the interpolator a"); + + return vecType(vecType(x) + a * vecType(y - x)); + } + }; + + template class vecType> + struct compute_mix_scalar + { + GLM_FUNC_QUALIFIER static vecType call(vecType const & x, vecType const & y, bool const & a) + { + return a ? y : x; + } + }; + + template + struct compute_mix + { + GLM_FUNC_QUALIFIER static T call(T const & x, T const & y, U const & a) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'mix' only accept floating-point inputs for the interpolator a"); + + return static_cast(static_cast(x) + a * static_cast(y - x)); + } + }; + + template + struct compute_mix + { + GLM_FUNC_QUALIFIER static T call(T const & x, T const & y, bool const & a) + { + return a ? y : x; + } + }; +}//namespace detail + + // abs + template + GLM_FUNC_QUALIFIER genFIType abs + ( + genFIType const & x + ) + { + return detail::compute_abs::is_signed>::call(x); + } + + VECTORIZE_VEC(abs) + + // sign + //Try something like based on x >> 31 to get the sign bit + template + GLM_FUNC_QUALIFIER genFIType sign + ( + genFIType const & x + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559 || + (std::numeric_limits::is_signed && std::numeric_limits::is_integer), "'sign' only accept signed inputs"); + + genFIType result; + if(x > genFIType(0)) + result = genFIType(1); + else if(x < genFIType(0)) + result = genFIType(-1); + else + result = genFIType(0); + return result; + } + + VECTORIZE_VEC(sign) + + // floor + template + GLM_FUNC_QUALIFIER genType floor(genType const & x) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'floor' only accept floating-point inputs"); + + return ::std::floor(x); + } + + VECTORIZE_VEC(floor) + + // trunc + template + GLM_FUNC_QUALIFIER genType trunc(genType const & x) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'trunc' only accept floating-point inputs"); + + // TODO, add C++11 std::trunk + return x < 0 ? -floor(-x) : floor(x); + } + + VECTORIZE_VEC(trunc) + + // round + template + GLM_FUNC_QUALIFIER genType round(genType const& x) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'round' only accept floating-point inputs"); + + // TODO, add C++11 std::round + return x < 0 ? genType(int(x - genType(0.5))) : genType(int(x + genType(0.5))); + } + + VECTORIZE_VEC(round) + +/* + // roundEven + template + GLM_FUNC_QUALIFIER genType roundEven(genType const& x) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'roundEven' only accept floating-point inputs"); + + return genType(int(x + genType(int(x) % 2))); + } +*/ + + // roundEven + template + GLM_FUNC_QUALIFIER genType roundEven(genType const & x) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'roundEven' only accept floating-point inputs"); + + int Integer = static_cast(x); + genType IntegerPart = static_cast(Integer); + genType FractionalPart = fract(x); + + if(FractionalPart > static_cast(0.5) || FractionalPart < static_cast(0.5)) + { + return round(x); + } + else if((Integer % 2) == 0) + { + return IntegerPart; + } + else if(x <= static_cast(0)) // Work around... + { + return IntegerPart - static_cast(1); + } + else + { + return IntegerPart + static_cast(1); + } + //else // Bug on MinGW 4.5.2 + //{ + // return mix(IntegerPart + genType(-1), IntegerPart + genType(1), x <= genType(0)); + //} + } + + VECTORIZE_VEC(roundEven) + + // ceil + template + GLM_FUNC_QUALIFIER genType ceil(genType const & x) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'ceil' only accept floating-point inputs"); + + return ::std::ceil(x); + } + + VECTORIZE_VEC(ceil) + + // fract + template + GLM_FUNC_QUALIFIER genType fract + ( + genType const & x + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'fract' only accept floating-point inputs"); + + return x - floor(x); + } + + VECTORIZE_VEC(fract) + + // mod + template + GLM_FUNC_QUALIFIER genType mod + ( + genType const & x, + genType const & y + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'mod' only accept floating-point inputs"); + + return x - y * floor(x / y); + } + + VECTORIZE_VEC_SCA(mod) + VECTORIZE_VEC_VEC(mod) + + // modf + template + GLM_FUNC_QUALIFIER genType modf + ( + genType const & x, + genType & i + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'modf' only accept floating-point inputs"); + + return std::modf(x, &i); + } + + 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)); + } + + 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)); + } + + 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)); + } + + //// Only valid if (INT_MIN <= x-y <= INT_MAX) + //// min(x,y) + //r = y + ((x - y) & ((x - y) >> (sizeof(int) * + //CHAR_BIT - 1))); + //// max(x,y) + //r = x - ((x - y) & ((x - y) >> (sizeof(int) * + //CHAR_BIT - 1))); + + // min + template + GLM_FUNC_QUALIFIER genType min + ( + genType const & x, + genType const & y + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559 || std::numeric_limits::is_integer, + "'min' only accept floating-point or integer inputs"); + + return x < y ? x : y; + } + + VECTORIZE_VEC_SCA(min) + VECTORIZE_VEC_VEC(min) + + // max + template + GLM_FUNC_QUALIFIER genType max + ( + genType const & x, + genType const & y + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559 || std::numeric_limits::is_integer, + "'max' only accept floating-point or integer inputs"); + + return x > y ? x : y; + } + + VECTORIZE_VEC_SCA(max) + VECTORIZE_VEC_VEC(max) + + // clamp + template + GLM_FUNC_QUALIFIER genType clamp + ( + genType const & x, + genType const & minVal, + genType const & maxVal + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559 || std::numeric_limits::is_integer, + "'clamp' only accept floating-point or integer inputs"); + + return min(maxVal, max(minVal, x)); + } + + template + GLM_FUNC_QUALIFIER detail::tvec2 clamp + ( + detail::tvec2 const & x, + T const & minVal, + T const & maxVal + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559 || std::numeric_limits::is_integer, + "'clamp' only accept floating-point or integer inputs"); + + return detail::tvec2( + clamp(x.x, minVal, maxVal), + clamp(x.y, minVal, maxVal)); + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 clamp + ( + detail::tvec3 const & x, + T const & minVal, + T const & maxVal + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559 || std::numeric_limits::is_integer, + "'clamp' only accept floating-point or integer inputs"); + + 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 + ( + detail::tvec4 const & x, + T const & minVal, + T const & maxVal + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559 || std::numeric_limits::is_integer, + "'clamp' only accept floating-point or integer inputs"); + + 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 + ( + detail::tvec2 const & x, + detail::tvec2 const & minVal, + detail::tvec2 const & maxVal + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559 || std::numeric_limits::is_integer, + "'clamp' only accept floating-point or integer inputs"); + + return detail::tvec2( + clamp(x.x, minVal.x, maxVal.x), + clamp(x.y, minVal.y, maxVal.y)); + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 clamp + ( + detail::tvec3 const & x, + detail::tvec3 const & minVal, + detail::tvec3 const & maxVal + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559 || std::numeric_limits::is_integer, + "'clamp' only accept floating-point or integer inputs"); + + 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 + ( + detail::tvec4 const & x, + detail::tvec4 const & minVal, + detail::tvec4 const & maxVal + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559 || std::numeric_limits::is_integer, + "'clamp' only accept floating-point or integer inputs"); + + 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)); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType mix + ( + vecType const & x, + vecType const & y, + vecType const & a + ) + { + return detail::compute_mix_vector::call(x, y, a); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType mix + ( + vecType const & x, + vecType const & y, + U const & a + ) + { + return detail::compute_mix_scalar::call(x, y, a); + } + + template + GLM_FUNC_QUALIFIER genTypeT mix + ( + genTypeT const & x, + genTypeT const & y, + genTypeU const & a + ) + { + return detail::compute_mix::call(x, y, a); + } + + // step + template + GLM_FUNC_QUALIFIER genType step + ( + genType const & edge, + genType const & x + ) + { + return mix(genType(1), genType(0), glm::lessThan(x, edge)); + } + + template
class vecType, typename T, precision P> + GLM_FUNC_QUALIFIER vecType step + ( + T const & edge, + vecType const & x + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'step' only accept floating-point inputs"); + + return mix(vecType(1), vecType(0), glm::lessThan(x, vecType(edge))); + } + + // smoothstep + template + GLM_FUNC_QUALIFIER genType smoothstep + ( + genType const & edge0, + genType const & edge1, + genType const & x + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'smoothstep' only accept floating-point inputs"); + + 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 + ( + T const & edge0, + T const & edge1, + detail::tvec2 const & x + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'smoothstep' only accept floating-point inputs"); + + return detail::tvec2( + smoothstep(edge0, edge1, x.x), + smoothstep(edge0, edge1, x.y)); + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 smoothstep + ( + T const & edge0, + T const & edge1, + detail::tvec3 const & x + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'smoothstep' only accept floating-point inputs"); + + 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 + ( + T const & edge0, + T const & edge1, + detail::tvec4 const & x + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'smoothstep' only accept floating-point inputs"); + + 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 + ( + detail::tvec2 const & edge0, + detail::tvec2 const & edge1, + detail::tvec2 const & x + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'smoothstep' only accept floating-point inputs"); + + return detail::tvec2( + smoothstep(edge0.x, edge1.x, x.x), + smoothstep(edge0.y, edge1.y, x.y)); + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 smoothstep + ( + detail::tvec3 const & edge0, + detail::tvec3 const & edge1, + detail::tvec3 const & x + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'smoothstep' only accept floating-point inputs"); + + 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 + ( + detail::tvec4 const & edge0, + detail::tvec4 const & edge1, + detail::tvec4 const & x + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'smoothstep' only accept floating-point inputs"); + + 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 + GLM_FUNC_QUALIFIER bool isnan(genType const & x) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'isnan' only accept floating-point inputs"); + +# if(GLM_COMPILER & (GLM_COMPILER_VC | GLM_COMPILER_INTEL)) + return _isnan(x) != 0; +# elif(GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_CLANG)) +# if(GLM_PLATFORM & GLM_PLATFORM_ANDROID && __cplusplus < 201103L) + return _isnan(x) != 0; +# else + return std::isnan(x); +# endif +# elif(GLM_COMPILER & GLM_COMPILER_CUDA) + return isnan(x) != 0; +# else + return std::isnan(x); +# endif + } + + template + GLM_FUNC_QUALIFIER typename detail::tvec2::bool_type isnan + ( + detail::tvec2 const & x + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'isnan' only accept floating-point inputs"); + + return typename detail::tvec2::bool_type( + isnan(x.x), + isnan(x.y)); + } + + template + GLM_FUNC_QUALIFIER typename detail::tvec3::bool_type isnan + ( + detail::tvec3 const & x + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'isnan' only accept floating-point inputs"); + + 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 + ( + detail::tvec4 const & x + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'isnan' only accept floating-point inputs"); + + return typename detail::tvec4::bool_type( + isnan(x.x), + isnan(x.y), + isnan(x.z), + isnan(x.w)); + } + + template + GLM_FUNC_QUALIFIER bool isinf( + genType const & x) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'isinf' only accept floating-point inputs"); + +# if(GLM_COMPILER & (GLM_COMPILER_INTEL | GLM_COMPILER_VC)) + return _fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF; +# elif(GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_CLANG)) +# if(GLM_PLATFORM & GLM_PLATFORM_ANDROID && __cplusplus < 201103L) + return _isinf(x) != 0; +# else + return std::isinf(x); +# endif +# elif(GLM_COMPILER & GLM_COMPILER_CUDA) + // http://developer.download.nvidia.com/compute/cuda/4_2/rel/toolkit/docs/online/group__CUDA__MATH__DOUBLE_g13431dd2b40b51f9139cbb7f50c18fab.html#g13431dd2b40b51f9139cbb7f50c18fab + return isinf(double(x)) != 0; +# else + return std::isinf(x); +# endif + } + + template + GLM_FUNC_QUALIFIER typename detail::tvec2::bool_type isinf + ( + detail::tvec2 const & x + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'isinf' only accept floating-point inputs"); + + return typename detail::tvec2::bool_type( + isinf(x.x), + isinf(x.y)); + } + + template + GLM_FUNC_QUALIFIER typename detail::tvec3::bool_type isinf + ( + detail::tvec3 const & x + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'isinf' only accept floating-point inputs"); + + 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 + ( + detail::tvec4 const & x + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'isinf' only accept floating-point inputs"); + + 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 & v) + { + return reinterpret_cast(const_cast(v)); + } + + template
class vecType, precision P> + GLM_FUNC_QUALIFIER vecType floatBitsToInt(vecType const & v) + { + return reinterpret_cast&>(const_cast&>(v)); + } + + GLM_FUNC_QUALIFIER uint floatBitsToUint(float const & v) + { + return reinterpret_cast(const_cast(v)); + } + + template
class vecType, precision P> + GLM_FUNC_QUALIFIER vecType floatBitsToUint(vecType const & v) + { + return reinterpret_cast&>(const_cast&>(v)); + } + + GLM_FUNC_QUALIFIER float intBitsToFloat(int const & v) + { + return reinterpret_cast(const_cast(v)); + } + + template
class vecType, precision P> + GLM_FUNC_QUALIFIER vecType intBitsToFloat(vecType const & v) + { + return reinterpret_cast&>(const_cast&>(v)); + } + + GLM_FUNC_QUALIFIER float uintBitsToFloat(uint const & v) + { + return reinterpret_cast(const_cast(v)); + } + + template
class vecType, precision P> + GLM_FUNC_QUALIFIER vecType uintBitsToFloat(vecType const & v) + { + return reinterpret_cast&>(const_cast&>(v)); + } + + template + GLM_FUNC_QUALIFIER genType fma + ( + genType const & a, + genType const & b, + genType const & c + ) + { + return a * b + c; + } + + template + GLM_FUNC_QUALIFIER genType frexp + ( + genType const & x, + int & exp + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'frexp' only accept floating-point inputs"); + + return std::frexp(x, exp); + } + + template + GLM_FUNC_QUALIFIER detail::tvec2 frexp + ( + detail::tvec2 const & x, + detail::tvec2 & exp + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'frexp' only accept floating-point inputs"); + + return detail::tvec2( + frexp(x.x, exp.x), + frexp(x.y, exp.y)); + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 frexp + ( + detail::tvec3 const & x, + detail::tvec3 & exp + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'frexp' only accept floating-point inputs"); + + return detail::tvec3( + frexp(x.x, exp.x), + frexp(x.y, exp.y), + frexp(x.z, exp.z)); + } + + template + GLM_FUNC_QUALIFIER detail::tvec4 frexp + ( + detail::tvec4 const & x, + detail::tvec4 & exp + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'frexp' only accept floating-point inputs"); + + return detail::tvec4( + frexp(x.x, exp.x), + frexp(x.y, exp.y), + frexp(x.z, exp.z), + frexp(x.w, exp.w)); + } + + template + GLM_FUNC_QUALIFIER genType ldexp + ( + genType const & x, + int const & exp + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'frexp' only accept floating-point inputs"); + + return std::ldexp(x, exp); + } + + template + GLM_FUNC_QUALIFIER detail::tvec2 ldexp + ( + detail::tvec2 const & x, + detail::tvec2 const & exp + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'ldexp' only accept floating-point inputs"); + + return detail::tvec2( + ldexp(x.x, exp.x), + ldexp(x.y, exp.y)); + } + + template + GLM_FUNC_QUALIFIER detail::tvec3 ldexp + ( + detail::tvec3 const & x, + detail::tvec3 const & exp + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'ldexp' only accept floating-point inputs"); + + return detail::tvec3( + ldexp(x.x, exp.x), + ldexp(x.y, exp.y), + ldexp(x.z, exp.z)); + } + + template + GLM_FUNC_QUALIFIER detail::tvec4 ldexp + ( + detail::tvec4 const & x, + detail::tvec4 const & exp + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'ldexp' only accept floating-point inputs"); + + return detail::tvec4( + ldexp(x.x, exp.x), + ldexp(x.y, exp.y), + ldexp(x.z, exp.z), + ldexp(x.w, exp.w)); + } + +}//namespace glm diff --git a/ThirdParty/include/glm/detail/func_exponential.hpp b/ThirdParty/include/glm/detail/func_exponential.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d0a8928a75cd45cc8d16fbb0d622149f2181eb4a --- /dev/null +++ b/ThirdParty/include/glm/detail/func_exponential.hpp @@ -0,0 +1,132 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/core/func_exponential.hpp +/// @date 2008-08-08 / 2011-06-14 +/// @author Christophe Riccio +/// +/// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions +/// +/// @defgroup core_func_exponential Exponential functions +/// @ingroup core +/// +/// These all operate component-wise. The description is per component. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef glm_core_func_exponential +#define glm_core_func_exponential + +#include "type_vec1.hpp" +#include "type_vec2.hpp" +#include "type_vec3.hpp" +#include "type_vec4.hpp" +#include + +namespace glm +{ + /// @addtogroup core_func_exponential + /// @{ + + /// Returns 'base' raised to the power 'exponent'. + /// + /// @param base Floating point value. pow function is defined for input values of x defined in the range (inf-, inf+) in the limit of the type precision. + /// @param exponent Floating point value representing the 'exponent'. + /// @tparam genType Floating-point scalar or vector types. + /// + /// @see GLSL pow man page + /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions + template + GLM_FUNC_DECL genType pow(genType const & base, genType const & exponent); + + /// Returns the natural exponentiation of x, i.e., e^x. + /// + /// @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 + template + GLM_FUNC_DECL genType exp(genType const & x); + + /// Returns the natural logarithm of x, i.e., + /// returns the value y which satisfies the equation x = e^y. + /// Results are undefined if x <= 0. + /// + /// @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 + template + GLM_FUNC_DECL genType log(genType const & x); + + /// Returns 2 raised to the x power. + /// + /// @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 + template + GLM_FUNC_DECL 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 + template + GLM_FUNC_DECL genType log2(genType 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 + //template + //GLM_FUNC_DECL genType sqrt(genType const & x); + + template class vecType> + GLM_FUNC_DECL vecType sqrt(vecType const & x); + + /// Returns the reciprocal of the positive square root of x. + /// + /// @param x inversesqrt function is defined for input values of x defined in the range [0, inf+) in the limit of the type precision. + /// @tparam genType Floating-point scalar or vector types. + /// + /// @see GLSL inversesqrt man page + /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions + template + GLM_FUNC_DECL genType inversesqrt(genType const & x); + + /// @} +}//namespace glm + +#include "func_exponential.inl" + +#endif//glm_core_func_exponential diff --git a/ThirdParty/include/glm/detail/func_exponential.inl b/ThirdParty/include/glm/detail/func_exponential.inl new file mode 100644 index 0000000000000000000000000000000000000000..f8bd5093cd79d8c6b0f9d7024396ba2876e1cbe1 --- /dev/null +++ b/ThirdParty/include/glm/detail/func_exponential.inl @@ -0,0 +1,247 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/core/func_exponential.inl +/// @date 2008-08-03 / 2011-06-15 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +#include "func_vector_relational.hpp" +#include "_vectorize.hpp" +#include +#include + +namespace glm{ +namespace detail +{ + template + struct compute_log2 + { + template + T operator() (T const & Value) const; + }; + + template <> + struct compute_log2 + { + template + GLM_FUNC_QUALIFIER T operator() (T const & Value) const + { + return static_cast(::std::log(Value)) * static_cast(1.4426950408889634073599246810019); + } + }; + + template
class vecType, typename T, precision P> + struct compute_inversesqrt + { + GLM_FUNC_QUALIFIER static vecType call(vecType const & x) + { + return static_cast(1) / sqrt(x); + } + }; + + template
class vecType> + struct compute_inversesqrt + { + GLM_FUNC_QUALIFIER static vecType call(vecType const & x) + { + vecType tmp(x); + vecType xhalf(tmp * 0.5f); + vecType* p = reinterpret_cast*>(const_cast*>(&x)); + vecType i = vecType(0x5f375a86) - (*p >> vecType(1)); + vecType* ptmp = reinterpret_cast*>(&i); + tmp = *ptmp; + tmp = tmp * (1.5f - xhalf * tmp * tmp); + return tmp; + } + }; +}//namespace detail + + // pow + template + GLM_FUNC_QUALIFIER genType pow + ( + genType const & x, + genType const & y + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'pow' only accept floating-point inputs"); + + return std::pow(x, y); + } + + VECTORIZE_VEC_VEC(pow) + + // exp + template + GLM_FUNC_QUALIFIER genType exp + ( + genType const & x + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'exp' only accept floating-point inputs"); + + return std::exp(x); + } + + VECTORIZE_VEC(exp) + + // log + template + GLM_FUNC_QUALIFIER genType log + ( + genType const & x + ) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'log' only accept floating-point inputs"); + + return std::log(x); + } + + VECTORIZE_VEC(log) + + //exp2, ln2 = 0.69314718055994530941723212145818f + template + GLM_FUNC_QUALIFIER genType exp2(genType const & x) + { + GLM_STATIC_ASSERT( + std::numeric_limits::is_iec559, + "'exp2' only accept floating-point inputs"); + + return std::exp(static_cast(0.69314718055994530941723212145818) * x); + } + + VECTORIZE_VEC(exp2) + + // log2, ln2 = 0.69314718055994530941723212145818f + template + GLM_FUNC_QUALIFIER genType log2(genType x) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || std::numeric_limits::is_integer, + "GLM core 'log2' only accept floating-point inputs. Include for additional integer support."); + + assert(x > genType(0)); // log2 is only defined on the range (0, inf] + return detail::compute_log2::is_iec559>()(x); + } + + VECTORIZE_VEC(log2) + + namespace detail + { + template
class vecType, typename T, precision P> + struct compute_sqrt{}; + + template + struct compute_sqrt + { + GLM_FUNC_QUALIFIER static detail::tvec1 call(detail::tvec1 const & x) + { + return detail::tvec1(std::sqrt(x.x)); + } + }; + + template + struct compute_sqrt + { + GLM_FUNC_QUALIFIER static detail::tvec2 call(detail::tvec2 const & x) + { + return detail::tvec2(std::sqrt(x.x), std::sqrt(x.y)); + } + }; + + template + struct compute_sqrt + { + GLM_FUNC_QUALIFIER static detail::tvec3 call(detail::tvec3 const & x) + { + return detail::tvec3(std::sqrt(x.x), std::sqrt(x.y), std::sqrt(x.z)); + } + }; + + template + struct compute_sqrt + { + GLM_FUNC_QUALIFIER static detail::tvec4 call(detail::tvec4 const & x) + { + return detail::tvec4(std::sqrt(x.x), std::sqrt(x.y), std::sqrt(x.z), std::sqrt(x.w)); + } + }; + }//namespace detail + + // sqrt + GLM_FUNC_QUALIFIER float sqrt(float x) + { +# ifdef __CUDACC__ // Wordaround for a CUDA compiler bug up to CUDA6 + detail::tvec1 tmp(detail::compute_sqrt::call(x)); + return tmp.x; +# else + return detail::compute_sqrt::call(x).x; +# endif + } + + GLM_FUNC_QUALIFIER double sqrt(double x) + { +# ifdef __CUDACC__ // Wordaround for a CUDA compiler bug up to CUDA6 + detail::tvec1 tmp(detail::compute_sqrt::call(x)); + return tmp.x; +# else + return detail::compute_sqrt::call(x).x; +# endif + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType sqrt(vecType const & x) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'sqrt' only accept floating-point inputs"); + return detail::compute_sqrt::call(x); + } + + // inversesqrt + GLM_FUNC_QUALIFIER float inversesqrt(float const & x) + { + return 1.0f / sqrt(x); + } + + GLM_FUNC_QUALIFIER double inversesqrt(double const & x) + { + return 1.0 / sqrt(x); + } + + template
class vecType, typename T, precision P> + GLM_FUNC_QUALIFIER vecType inversesqrt + ( + vecType const & x + ) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'inversesqrt' only accept floating-point inputs"); + return detail::compute_inversesqrt::call(x); + } + + VECTORIZE_VEC(inversesqrt) +}//namespace glm diff --git a/ThirdParty/include/glm/detail/func_geometric.hpp b/ThirdParty/include/glm/detail/func_geometric.hpp new file mode 100644 index 0000000000000000000000000000000000000000..c2f5a89c971a2c85b2d4a91b69889e336449770d --- /dev/null +++ b/ThirdParty/include/glm/detail/func_geometric.hpp @@ -0,0 +1,151 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/core/func_geometric.hpp +/// @date 2008-08-03 / 2011-06-14 +/// @author Christophe Riccio +/// +/// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions +/// +/// @defgroup core_func_geometric Geometric functions +/// @ingroup core +/// +/// These operate on vectors as vectors, not component-wise. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef glm_core_func_geometric +#define glm_core_func_geometric + +#include "type_vec3.hpp" + +namespace glm +{ + /// @addtogroup core_func_geometric + /// @{ + + /// 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 + template + GLM_FUNC_DECL 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 + template + GLM_FUNC_DECL typename genType::value_type distance( + genType const & p0, + genType const & p1); + + /// 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 class vecType> + GLM_FUNC_DECL T dot( + vecType const & x, + vecType const & y); + + /// 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 + GLM_FUNC_DECL genType dot( + genType const & x, + genType const & y); + + /// 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 + GLM_FUNC_DECL 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 + template + GLM_FUNC_DECL genType normalize( + genType const & x); + + /// 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 + GLM_FUNC_DECL 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 + GLM_FUNC_DECL 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 class vecType> + GLM_FUNC_DECL vecType refract( + vecType const & I, + vecType const & N, + T const & eta); + + /// @} +}//namespace glm + +#include "func_geometric.inl" + +#endif//glm_core_func_geometric diff --git a/ThirdParty/include/glm/detail/func_geometric.inl b/ThirdParty/include/glm/detail/func_geometric.inl new file mode 100644 index 0000000000000000000000000000000000000000..f7b8a56cc5c2bb48e83affc5b81f004593ecb781 --- /dev/null +++ b/ThirdParty/include/glm/detail/func_geometric.inl @@ -0,0 +1,339 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref core +/// @file glm/core/func_geometric.inl +/// @date 2008-08-03 / 2011-06-15 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// + +#include "func_exponential.hpp" +#include "func_common.hpp" +#include "type_vec2.hpp" +#include "type_vec4.hpp" +#include "type_float.hpp" + +namespace glm{ +namespace detail +{ + template