diff --git a/CMakeLists.txt b/CMakeLists.txt index 484e8559..466a6c6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,27 +46,33 @@ if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" if(GLM_TEST_ENABLE_CXX_1Z) set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++1z") set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") - set(CMAKE_CXX_FLAGS "-std=c++1Z") + set(CMAKE_CXX_FLAGS "-std=c++1z") + message(STATUS "Build with C++1z features") elseif(GLM_TEST_ENABLE_CXX_14) set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++14") set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") set(CMAKE_CXX_FLAGS "-std=c++14") + message(STATUS "Build with C++14 features") elseif(GLM_TEST_ENABLE_CXX_1Y) set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++1y") set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") set(CMAKE_CXX_FLAGS "-std=c++1y") + message(STATUS "Build with C++1y features") elseif(GLM_TEST_ENABLE_CXX_11) set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11") set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") set(CMAKE_CXX_FLAGS "-std=c++11") + message(STATUS "Build with C++11 features") elseif(GLM_TEST_ENABLE_CXX_0X) set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++0x") set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") set(CMAKE_CXX_FLAGS "-std=c++0x") + message(STATUS "Build with C++0x features") elseif(GLM_TEST_ENABLE_CXX_98) set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++98") set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") set(CMAKE_CXX_FLAGS "-std=c++98") + message(STATUS "Build with C++98 features") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") add_definitions(-Wno-long-long) endif() @@ -76,6 +82,10 @@ if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" endif() endif() +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + add_definitions(-Weverything -Wpedantic -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded -Wno-documentation -Wno-gnu-anonymous-struct -Wno-nested-anon-types -Wno-sign-conversion -Wno-unused-variable -Wno-missing-prototypes) +endif() + option(GLM_TEST_ENABLE_LANG_EXTENSIONS "Enable language extensions" OFF) if(GLM_TEST_ENABLE_LANG_EXTENSIONS) diff --git a/glm/detail/compute_vector_relational.hpp b/glm/detail/compute_vector_relational.hpp new file mode 100644 index 00000000..e5610ef1 --- /dev/null +++ b/glm/detail/compute_vector_relational.hpp @@ -0,0 +1,28 @@ +#pragma once + +#include "setup.hpp" +#include +#include + +namespace glm{ +namespace detail +{ + template ::is_iec559> + struct compute_equal + { + GLM_FUNC_QUALIFIER static bool call(T a, T b) + { + return a == b; + } + }; + + template + struct compute_equal + { + GLM_FUNC_QUALIFIER static bool call(T a, T b) + { + return std::memcmp(&a, &b, sizeof(T)) == 0; + } + }; +}//namespace detail +}//namespace glm diff --git a/glm/detail/func_common.hpp b/glm/detail/func_common.hpp index 50a16655..d3c98fb4 100644 --- a/glm/detail/func_common.hpp +++ b/glm/detail/func_common.hpp @@ -29,36 +29,39 @@ namespace glm template GLM_FUNC_DECL genType abs(genType x); - template class vecType> - GLM_FUNC_DECL vecType abs(vecType const & x); + template + GLM_FUNC_DECL vec abs(vec 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. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Floating-point scalar types. /// /// @see GLSL sign man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template class vecType> - GLM_FUNC_DECL vecType sign(vecType const & x); + template + GLM_FUNC_DECL vec sign(vec const& 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. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Floating-point scalar types. /// /// @see GLSL floor man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template class vecType> - GLM_FUNC_DECL vecType floor(vecType const & x); + template + GLM_FUNC_DECL vec floor(vec const& x); /// Returns a value equal to the nearest integer to x /// whose absolute value is not larger than the absolute value of x. /// - /// @tparam genType Floating-point scalar or vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Floating-point scalar types. /// /// @see GLSL trunc man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template class vecType> - GLM_FUNC_DECL vecType trunc(vecType const & x); + template + GLM_FUNC_DECL vec trunc(vec const& x); /// Returns a value equal to the nearest integer to x. /// The fraction 0.5 will round in a direction chosen by the @@ -66,34 +69,37 @@ namespace glm /// This includes the possibility that round(x) returns the /// same value as roundEven(x) for all values of x. /// - /// @tparam genType Floating-point scalar or vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Floating-point scalar types. /// /// @see GLSL round man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template class vecType> - GLM_FUNC_DECL vecType round(vecType const & x); + template + GLM_FUNC_DECL vec round(vec const& x); /// Returns a value equal to the nearest integer to x. /// A fractional part of 0.5 will round toward the nearest even /// integer. (Both 3.5 and 4.5 for x will return 4.0.) - /// - /// @tparam genType Floating-point scalar or vector types. + /// + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Floating-point scalar types. /// /// @see GLSL roundEven man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions /// @see New round to even technique - template class vecType> - GLM_FUNC_DECL vecType roundEven(vecType const & x); + template + GLM_FUNC_DECL vec roundEven(vec 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. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Floating-point scalar types. /// /// @see GLSL ceil man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template class vecType> - GLM_FUNC_DECL vecType ceil(vecType const & x); + template + GLM_FUNC_DECL vec ceil(vec const& x); /// Return x - floor(x). /// @@ -104,8 +110,8 @@ namespace glm template GLM_FUNC_DECL genType fract(genType x); - template class vecType> - GLM_FUNC_DECL vecType fract(vecType const & x); + template + GLM_FUNC_DECL vec fract(vec const& x); /// Modulus. Returns x - y * floor(x / y) /// for each component in x using the floating point value y. @@ -117,11 +123,11 @@ namespace glm template GLM_FUNC_DECL genType mod(genType x, genType y); - template class vecType> - GLM_FUNC_DECL vecType mod(vecType const & x, T y); + template + GLM_FUNC_DECL vec mod(vec const & x, T y); - template class vecType> - GLM_FUNC_DECL vecType mod(vecType const & x, vecType const & y); + template + GLM_FUNC_DECL vec mod(vec const & x, vec const & y); /// Returns the fractional part of x and sets i to the integer /// part (as a whole number floating point value). Both the @@ -144,11 +150,11 @@ namespace glm template GLM_FUNC_DECL genType min(genType x, genType y); - template class vecType> - GLM_FUNC_DECL vecType min(vecType const & x, T y); + template + GLM_FUNC_DECL vec min(vec const& x, T y); - template class vecType> - GLM_FUNC_DECL vecType min(vecType const & x, vecType const & y); + template + GLM_FUNC_DECL vec min(vec const& x, vec const& y); /// Returns y if x < y; otherwise, it returns x. /// @@ -159,11 +165,11 @@ namespace glm template GLM_FUNC_DECL genType max(genType x, genType y); - template class vecType> - GLM_FUNC_DECL vecType max(vecType const & x, T y); + template + GLM_FUNC_DECL vec max(vec const& x, T y); - template class vecType> - GLM_FUNC_DECL vecType max(vecType const & x, vecType const & y); + template + GLM_FUNC_DECL vec max(vec const& x, vec const& y); /// Returns min(max(x, minVal), maxVal) for each component in x /// using the floating-point values minVal and maxVal. @@ -175,11 +181,11 @@ namespace glm template GLM_FUNC_DECL genType clamp(genType x, genType minVal, genType maxVal); - template class vecType> - GLM_FUNC_DECL vecType clamp(vecType const & x, T minVal, T maxVal); + template + GLM_FUNC_DECL vec clamp(vec const & x, T minVal, T maxVal); - template class vecType> - GLM_FUNC_DECL vecType clamp(vecType const & x, vecType const & minVal, vecType const & maxVal); + template + GLM_FUNC_DECL vec clamp(vec const& x, vec const& minVal, vec const& maxVal); /// If genTypeU is a floating scalar or vector: /// Returns x * (1.0 - a) + y * a, i.e., the linear blend of @@ -188,10 +194,10 @@ namespace glm /// /// If genTypeU is a boolean scalar or vector: /// Selects which vector each returned component comes - /// from. For a component of that is false, the - /// corresponding component of x is returned. For a - /// component of a that is true, the corresponding - /// component of y is returned. Components of x and y that + /// from. For a component of 'a' that is false, the + /// corresponding component of 'x' is returned. For a + /// component of 'a' that is true, the corresponding + /// component of 'y' is returned. Components of 'x' and 'y' that /// are not selected are allowed to be invalid floating point /// values and will have no effect on the results. Thus, this /// provides different functionality than @@ -223,15 +229,15 @@ namespace glm /// glm::dvec3 t = glm::mix(e, f, a); // Types of the third parameter is not required to match with the first and the second. /// glm::vec4 u = glm::mix(g, h, r); // Interpolations can be perform per component with a vector for the last parameter. /// @endcode - template class vecType> - GLM_FUNC_DECL vecType mix(vecType const & x, vecType const & y, vecType const & a); - - template class vecType> - GLM_FUNC_DECL vecType mix(vecType const & x, vecType const & y, U a); - template GLM_FUNC_DECL genTypeT mix(genTypeT x, genTypeT y, genTypeU a); + template + GLM_FUNC_DECL vec mix(vec const& x, vec const& y, vec const& a); + + template + GLM_FUNC_DECL vec mix(vec const& x, vec const& y, U a); + /// Returns 0.0 if x < edge, otherwise it returns 1.0 for each component of a genType. /// /// @see GLSL step man page @@ -241,17 +247,23 @@ namespace glm /// Returns 0.0 if x < edge, otherwise it returns 1.0. /// - /// @see GLSL step man page - /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template class vecType, length_t L, typename T, precision P> - GLM_FUNC_DECL vecType step(T edge, vecType const & x); - - /// Returns 0.0 if x < edge, otherwise it returns 1.0. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Floating-point scalar types. /// /// @see GLSL step man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template class vecType, length_t L, typename T, precision P> - GLM_FUNC_DECL vecType step(vecType const & edge, vecType const & x); + template + GLM_FUNC_DECL vec step(T edge, vec const& x); + + /// Returns 0.0 if x < edge, otherwise it returns 1.0. + /// + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Floating-point scalar types. + /// + /// @see GLSL step man page + /// @see GLSL 4.20.8 specification, section 8.3 Common Functions + template + GLM_FUNC_DECL vec step(vec const& edge, vec const& x); /// Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and /// performs smooth Hermite interpolation between 0 and 1 @@ -270,11 +282,11 @@ namespace glm template GLM_FUNC_DECL genType smoothstep(genType edge0, genType edge1, genType x); - template class vecType> - GLM_FUNC_DECL vecType smoothstep(T edge0, T edge1, vecType const & x); + template + GLM_FUNC_DECL vec smoothstep(T edge0, T edge1, vec const& x); - template class vecType> - GLM_FUNC_DECL vecType smoothstep(vecType const & edge0, vecType const & edge1, vecType const & x); + template + GLM_FUNC_DECL vec smoothstep(vec const& edge0, vec const& edge1, vec const& x); /// Returns true if x holds a NaN (not a number) /// representation in the underlying implementation's set of @@ -284,12 +296,13 @@ namespace glm /// /// /!\ When using compiler fast math, this function may fail. /// - /// @tparam genType Floating-point scalar or vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Floating-point scalar types. /// /// @see GLSL isnan man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template class vecType> - GLM_FUNC_DECL vecType isnan(vecType const & x); + template + GLM_FUNC_DECL vec isnan(vec const& x); /// Returns true if x holds a positive infinity or negative /// infinity representation in the underlying implementation's @@ -297,12 +310,13 @@ namespace glm /// otherwise, including for implementations with no infinity /// representations. /// - /// @tparam genType Floating-point scalar or vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Floating-point scalar types. /// /// @see GLSL isinf man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template class vecType> - GLM_FUNC_DECL vecType isinf(vecType const & x); + template + GLM_FUNC_DECL vec isinf(vec const& x); /// Returns a signed integer value representing /// the encoding of a floating-point value. The floating-point @@ -318,8 +332,8 @@ namespace glm /// /// @see GLSL floatBitsToInt man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template class vecType, length_t L, precision P> - GLM_FUNC_DECL vecType floatBitsToInt(vecType const & v); + template + GLM_FUNC_DECL vec floatBitsToInt(vec const & v); /// Returns a unsigned integer value representing /// the encoding of a floating-point value. The floatingpoint @@ -335,8 +349,8 @@ namespace glm /// /// @see GLSL floatBitsToUint man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template class vecType, length_t L, precision P> - GLM_FUNC_DECL vecType floatBitsToUint(vecType const & v); + template + GLM_FUNC_DECL vec floatBitsToUint(vec const& v); /// Returns a floating-point value corresponding to a signed /// integer encoding of a floating-point value. @@ -356,8 +370,8 @@ namespace glm /// /// @see GLSL intBitsToFloat man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template class vecType, length_t L, precision P> - GLM_FUNC_DECL vecType intBitsToFloat(vecType const & v); + template + GLM_FUNC_DECL vec intBitsToFloat(vec const & v); /// Returns a floating-point value corresponding to a /// unsigned integer encoding of a floating-point value. @@ -377,8 +391,8 @@ namespace glm /// /// @see GLSL uintBitsToFloat man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template class vecType, length_t L, precision P> - GLM_FUNC_DECL vecType uintBitsToFloat(vecType const & v); + template + GLM_FUNC_DECL vec uintBitsToFloat(vec const & v); /// Computes and returns a * b + c. /// @@ -387,7 +401,7 @@ namespace glm /// @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); + 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: @@ -404,7 +418,7 @@ namespace glm /// @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); + 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: @@ -418,7 +432,7 @@ namespace glm /// @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); + GLM_FUNC_DECL genType ldexp(genType const& x, genIType const& exp); /// @} }//namespace glm diff --git a/glm/detail/func_common.inl b/glm/detail/func_common.inl index 17bbdfa9..928d03b3 100644 --- a/glm/detail/func_common.inl +++ b/glm/detail/func_common.inl @@ -107,53 +107,53 @@ namespace detail } }; - template class vecType, bool Aligned> + template struct compute_abs_vector { - GLM_FUNC_QUALIFIER static vecType call(vecType const & x) + GLM_FUNC_QUALIFIER static vec call(vec const & x) { return detail::functor1::call(abs, x); } }; - template class vecType, bool Aligned> + template struct compute_mix_vector { - GLM_FUNC_QUALIFIER static vecType call(vecType const & x, vecType const & y, vecType const & a) + GLM_FUNC_QUALIFIER static vec call(vec const& x, vec const& y, vec const& a) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'mix' only accept floating-point inputs for the interpolator a"); - return vecType(vecType(x) + a * vecType(y - x)); + return vec(vec(x) + a * vec(y - x)); } }; - template class vecType, bool Aligned> - struct compute_mix_vector + template + struct compute_mix_vector { - GLM_FUNC_QUALIFIER static vecType call(vecType const & x, vecType const & y, vecType const & a) + GLM_FUNC_QUALIFIER static vec call(vec const& x, vec const& y, vec const& a) { - vecType Result; + vec Result; for(length_t i = 0; i < x.length(); ++i) Result[i] = a[i] ? y[i] : x[i]; return Result; } }; - template class vecType, bool Aligned> + template struct compute_mix_scalar { - GLM_FUNC_QUALIFIER static vecType call(vecType const & x, vecType const & y, U const & a) + GLM_FUNC_QUALIFIER static vec call(vec const& x, vec const& y, U const& a) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'mix' only accept floating-point inputs for the interpolator a"); - return vecType(vecType(x) + a * vecType(y - x)); + return vec(vec(x) + a * vec(y - x)); } }; - template class vecType, bool Aligned> - struct compute_mix_scalar + template + struct compute_mix_scalar { - GLM_FUNC_QUALIFIER static vecType call(vecType const & x, vecType const & y, bool const & a) + GLM_FUNC_QUALIFIER static vec call(vec const& x, vec const& y, bool const& a) { return a ? y : x; } @@ -162,7 +162,7 @@ namespace detail template struct compute_mix { - GLM_FUNC_QUALIFIER static T call(T const & x, T const & y, U const & a) + GLM_FUNC_QUALIFIER static T call(T const& x, T const& y, U const& a) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'mix' only accept floating-point inputs for the interpolator a"); @@ -173,133 +173,133 @@ namespace detail template struct compute_mix { - GLM_FUNC_QUALIFIER static T call(T const & x, T const & y, bool const & a) + GLM_FUNC_QUALIFIER static T call(T const& x, T const& y, bool const& a) { return a ? y : x; } }; - template class vecType, bool isFloat, bool Aligned> + template struct compute_sign { - GLM_FUNC_QUALIFIER static vecType call(vecType const & x) + GLM_FUNC_QUALIFIER static vec call(vec const& x) { - return vecType(glm::lessThan(vecType(0), x)) - vecType(glm::lessThan(x, vecType(0))); + return vec(glm::lessThan(vec(0), x)) - vec(glm::lessThan(x, vec(0))); } }; # if GLM_ARCH == GLM_ARCH_X86 - template class vecType, bool Aligned> - struct compute_sign + template + struct compute_sign { - GLM_FUNC_QUALIFIER static vecType call(vecType const & x) + GLM_FUNC_QUALIFIER static vec call(vec const& x) { T const Shift(static_cast(sizeof(T) * 8 - 1)); - vecType const y(vecType::type, P>(-x) >> typename make_unsigned::type(Shift)); + vec const y(vec::type, P>(-x) >> typename make_unsigned::type(Shift)); return (x >> Shift) | y; } }; # endif - template class vecType, bool Aligned> + template struct compute_floor { - GLM_FUNC_QUALIFIER static vecType call(vecType const & x) + GLM_FUNC_QUALIFIER static vec call(vec const& x) { return detail::functor1::call(std::floor, x); } }; - template class vecType, bool Aligned> + template struct compute_ceil { - GLM_FUNC_QUALIFIER static vecType call(vecType const & x) + GLM_FUNC_QUALIFIER static vec call(vec const& x) { return detail::functor1::call(std::ceil, x); } }; - template class vecType, bool Aligned> + template struct compute_fract { - GLM_FUNC_QUALIFIER static vecType call(vecType const & x) + GLM_FUNC_QUALIFIER static vec call(vec const& x) { return x - floor(x); } }; - template class vecType, bool Aligned> + template struct compute_trunc { - GLM_FUNC_QUALIFIER static vecType call(vecType const & x) + GLM_FUNC_QUALIFIER static vec call(vec const& x) { return detail::functor1::call(trunc, x); } }; - template class vecType, bool Aligned> + template struct compute_round { - GLM_FUNC_QUALIFIER static vecType call(vecType const & x) + GLM_FUNC_QUALIFIER static vec call(vec const& x) { return detail::functor1::call(round, x); } }; - template class vecType, bool Aligned> + template struct compute_mod { - GLM_FUNC_QUALIFIER static vecType call(vecType const & a, vecType const & b) + GLM_FUNC_QUALIFIER static vec call(vec const& a, vec const& b) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'mod' only accept floating-point inputs. Include for integer inputs."); return a - b * floor(a / b); } }; - template class vecType, bool Aligned> + template struct compute_min_vector { - GLM_FUNC_QUALIFIER static vecType call(vecType const & x, vecType const & y) + GLM_FUNC_QUALIFIER static vec call(vec const& x, vec const& y) { return detail::functor2::call(min, x, y); } }; - template class vecType, bool Aligned> + template struct compute_max_vector { - GLM_FUNC_QUALIFIER static vecType call(vecType const & x, vecType const & y) + GLM_FUNC_QUALIFIER static vec call(vec const& x, vec const& y) { return detail::functor2::call(max, x, y); } }; - template class vecType, bool Aligned> + template struct compute_clamp_vector { - GLM_FUNC_QUALIFIER static vecType call(vecType const & x, vecType const & minVal, vecType const & maxVal) + GLM_FUNC_QUALIFIER static vec call(vec const& x, vec const& minVal, vec const& maxVal) { return min(max(x, minVal), maxVal); } }; - template class vecType, bool Aligned> + template struct compute_step_vector { - GLM_FUNC_QUALIFIER static vecType call(vecType const & edge, vecType const & x) + GLM_FUNC_QUALIFIER static vec call(vec const& edge, vec const& x) { - return mix(vecType(1), vecType(0), glm::lessThan(x, edge)); + return mix(vec(1), vec(0), glm::lessThan(x, edge)); } }; - template class vecType, bool Aligned> + template struct compute_smoothstep_vector { - GLM_FUNC_QUALIFIER static vecType call(vecType const & edge0, vecType const & edge1, vecType const & x) + GLM_FUNC_QUALIFIER static vec call(vec const& edge0, vec const& edge1, vec const& x) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'step' only accept floating-point inputs"); - vecType const tmp(clamp((x - edge0) / (edge1 - edge0), static_cast(0), static_cast(1))); + vec const tmp(clamp((x - edge0) / (edge1 - edge0), static_cast(0), static_cast(1))); return tmp * tmp * (static_cast(3) - static_cast(2) * tmp); } }; @@ -311,10 +311,10 @@ namespace detail return detail::compute_abs::is_signed>::call(x); } - template class vecType> - GLM_FUNC_QUALIFIER vecType abs(vecType const & x) + template + GLM_FUNC_QUALIFIER vec abs(vec const & x) { - return detail::compute_abs_vector::value>::call(x); + return detail::compute_abs_vector::value>::call(x); } // sign @@ -326,40 +326,40 @@ namespace detail std::numeric_limits::is_iec559 || (std::numeric_limits::is_signed && std::numeric_limits::is_integer), "'sign' only accept signed inputs"); - return detail::compute_sign<1, genFIType, defaultp, vec, std::numeric_limits::is_iec559, highp>::call(vec<1, genFIType>(x)).x; + return detail::compute_sign<1, genFIType, defaultp, std::numeric_limits::is_iec559, highp>::call(vec<1, genFIType>(x)).x; } - template class vecType> - GLM_FUNC_QUALIFIER vecType sign(vecType const & x) + template + GLM_FUNC_QUALIFIER vec sign(vec 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"); - return detail::compute_sign::is_iec559, detail::is_aligned

::value>::call(x); + return detail::compute_sign::is_iec559, detail::is_aligned

::value>::call(x); } // floor using ::std::floor; - template class vecType> - GLM_FUNC_QUALIFIER vecType floor(vecType const & x) + template + GLM_FUNC_QUALIFIER vec floor(vec const& x) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'floor' only accept floating-point inputs."); - return detail::compute_floor::value>::call(x); + return detail::compute_floor::value>::call(x); } - template class vecType> - GLM_FUNC_QUALIFIER vecType trunc(vecType const & x) + template + GLM_FUNC_QUALIFIER vec trunc(vec const& x) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'trunc' only accept floating-point inputs"); - return detail::compute_trunc::value>::call(x); + return detail::compute_trunc::value>::call(x); } - template class vecType> - GLM_FUNC_QUALIFIER vecType round(vecType const & x) + template + GLM_FUNC_QUALIFIER vec round(vec const& x) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'round' only accept floating-point inputs"); - return detail::compute_round::value>::call(x); + return detail::compute_round::value>::call(x); } /* @@ -405,8 +405,8 @@ namespace detail //} } - template class vecType> - GLM_FUNC_QUALIFIER vecType roundEven(vecType const & x) + template + GLM_FUNC_QUALIFIER vec roundEven(vec const & x) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'roundEven' only accept floating-point inputs"); return detail::functor1::call(roundEven, x); @@ -414,11 +414,11 @@ namespace detail // ceil using ::std::ceil; - template class vecType> - GLM_FUNC_QUALIFIER vecType ceil(vecType const & x) + template + GLM_FUNC_QUALIFIER vec ceil(vec const & x) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'ceil' only accept floating-point inputs"); - return detail::compute_ceil::value>::call(x); + return detail::compute_ceil::value>::call(x); } // fract @@ -428,11 +428,11 @@ namespace detail return fract(vec<1, genType>(x)).x; } - template class vecType> - GLM_FUNC_QUALIFIER vecType fract(vecType const & x) + template + GLM_FUNC_QUALIFIER vec fract(vec const & x) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'fract' only accept floating-point inputs"); - return detail::compute_fract::value>::call(x); + return detail::compute_fract::value>::call(x); } // mod @@ -448,16 +448,16 @@ namespace detail # endif } - template class vecType> - GLM_FUNC_QUALIFIER vecType mod(vecType const & x, T y) + template + GLM_FUNC_QUALIFIER vec mod(vec const & x, T y) { - return detail::compute_mod::value>::call(x, vecType(y)); + return detail::compute_mod::value>::call(x, vec(y)); } - template class vecType> - GLM_FUNC_QUALIFIER vecType mod(vecType const & x, vecType const & y) + template + GLM_FUNC_QUALIFIER vec mod(vec const& x, vec const& y) { - return detail::compute_mod::value>::call(x, y); + return detail::compute_mod::value>::call(x, y); } // modf @@ -511,31 +511,31 @@ namespace detail //CHAR_BIT - 1))); // min - template class vecType> - GLM_FUNC_QUALIFIER vecType min(vecType const & a, T b) + template + GLM_FUNC_QUALIFIER vec min(vec const & a, T b) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || std::numeric_limits::is_integer || GLM_UNRESTRICTED_GENTYPE, "'min' only accept floating-point or integer inputs"); - return detail::compute_min_vector::value>::call(a, vecType(b)); + return detail::compute_min_vector::value>::call(a, vec(b)); } - template class vecType> - GLM_FUNC_QUALIFIER vecType min(vecType const & a, vecType const & b) + template + GLM_FUNC_QUALIFIER vec min(vec const& a, vec const& b) { - return detail::compute_min_vector::value>::call(a, b); + return detail::compute_min_vector::value>::call(a, b); } // max - template class vecType> - GLM_FUNC_QUALIFIER vecType max(vecType const & a, T b) + template + GLM_FUNC_QUALIFIER vec max(vec const& a, T b) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || std::numeric_limits::is_integer || GLM_UNRESTRICTED_GENTYPE, "'max' only accept floating-point or integer inputs"); - return detail::compute_max_vector::value>::call(a, vecType(b)); + return detail::compute_max_vector::value>::call(a, vec(b)); } - template class vecType> - GLM_FUNC_QUALIFIER vecType max(vecType const & a, vecType const & b) + template + GLM_FUNC_QUALIFIER vec max(vec const& a, vec const & b) { - return detail::compute_max_vector::value>::call(a, b); + return detail::compute_max_vector::value>::call(a, b); } // clamp @@ -546,18 +546,18 @@ namespace detail return min(max(x, minVal), maxVal); } - template class vecType> - GLM_FUNC_QUALIFIER vecType clamp(vecType const & x, T minVal, T maxVal) + template + GLM_FUNC_QUALIFIER vec clamp(vec const & x, T minVal, T maxVal) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || std::numeric_limits::is_integer || GLM_UNRESTRICTED_GENTYPE, "'clamp' only accept floating-point or integer inputs"); - return detail::compute_clamp_vector::value>::call(x, vecType(minVal), vecType(maxVal)); + return detail::compute_clamp_vector::value>::call(x, vec(minVal), vec(maxVal)); } - template class vecType> - GLM_FUNC_QUALIFIER vecType clamp(vecType const & x, vecType const & minVal, vecType const & maxVal) + template + GLM_FUNC_QUALIFIER vec clamp(vec const& x, vec const& minVal, vec const& maxVal) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || std::numeric_limits::is_integer || GLM_UNRESTRICTED_GENTYPE, "'clamp' only accept floating-point or integer inputs"); - return detail::compute_clamp_vector::value>::call(x, minVal, maxVal); + return detail::compute_clamp_vector::value>::call(x, minVal, maxVal); } template @@ -566,16 +566,16 @@ namespace detail return detail::compute_mix::call(x, y, a); } - template class vecType> - GLM_FUNC_QUALIFIER vecType mix(vecType const & x, vecType const & y, U a) + template + GLM_FUNC_QUALIFIER vec mix(vec const& x, vec const& y, U a) { - return detail::compute_mix_scalar::value>::call(x, y, a); + return detail::compute_mix_scalar::value>::call(x, y, a); } - template class vecType> - GLM_FUNC_QUALIFIER vecType mix(vecType const & x, vecType const & y, vecType const & a) + template + GLM_FUNC_QUALIFIER vec mix(vec const& x, vec const& y, vec const& a) { - return detail::compute_mix_vector::value>::call(x, y, a); + return detail::compute_mix_vector::value>::call(x, y, a); } // step @@ -585,16 +585,16 @@ namespace detail return mix(static_cast(1), static_cast(0), glm::lessThan(x, edge)); } - template class vecType, length_t L, typename T, precision P> - GLM_FUNC_QUALIFIER vecType step(T edge, vecType const & x) + template + GLM_FUNC_QUALIFIER vec step(T edge, vec const& x) { - return detail::compute_step_vector::value>::call(vecType(edge), x); + return detail::compute_step_vector::value>::call(vec(edge), x); } - template class vecType, length_t L, typename T, precision P> - GLM_FUNC_QUALIFIER vecType step(vecType const & edge, vecType const & x) + template + GLM_FUNC_QUALIFIER vec step(vec const& edge, vec const& x) { - return detail::compute_step_vector::value>::call(edge, x); + return detail::compute_step_vector::value>::call(edge, x); } // smoothstep @@ -607,16 +607,16 @@ namespace detail return tmp * tmp * (genType(3) - genType(2) * tmp); } - template class vecType> - GLM_FUNC_QUALIFIER vecType smoothstep(T edge0, T edge1, vecType const & x) + template + GLM_FUNC_QUALIFIER vec smoothstep(T edge0, T edge1, vec const& x) { - return detail::compute_smoothstep_vector::value>::call(vecType(edge0), vecType(edge1), x); + return detail::compute_smoothstep_vector::value>::call(vec(edge0), vec(edge1), x); } - template class vecType> - GLM_FUNC_QUALIFIER vecType smoothstep(vecType const & edge0, vecType const & edge1, vecType const & x) + template + GLM_FUNC_QUALIFIER vec smoothstep(vec const& edge0, vec const& edge1, vec const& x) { - return detail::compute_smoothstep_vector::value>::call(edge0, edge1, x); + return detail::compute_smoothstep_vector::value>::call(edge0, edge1, x); } # if GLM_HAS_CXX11_STL @@ -647,8 +647,8 @@ namespace detail } # endif - template class vecType> - GLM_FUNC_QUALIFIER vecType isnan(vecType const & x) + template + GLM_FUNC_QUALIFIER vec isnan(vec const& x) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'isnan' only accept floating-point inputs"); @@ -686,15 +686,15 @@ namespace detail } # endif - template class vecType> - GLM_FUNC_QUALIFIER vecType isinf(vecType const & x) + template + GLM_FUNC_QUALIFIER vec isinf(vec const& x) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'isnan' only accept floating-point inputs"); return detail::functor1::call(isinf, x); } - GLM_FUNC_QUALIFIER int floatBitsToInt(float const & v) + GLM_FUNC_QUALIFIER int floatBitsToInt(float const& v) { union { @@ -707,13 +707,13 @@ namespace detail return u.out; } - template class vecType, length_t L, precision P> - GLM_FUNC_QUALIFIER vecType floatBitsToInt(vecType const & v) + template + GLM_FUNC_QUALIFIER vec floatBitsToInt(vec const& v) { - return reinterpret_cast&>(const_cast&>(v)); + return reinterpret_cast&>(const_cast&>(v)); } - GLM_FUNC_QUALIFIER uint floatBitsToUint(float const & v) + GLM_FUNC_QUALIFIER uint floatBitsToUint(float const& v) { union { @@ -726,10 +726,10 @@ namespace detail return u.out; } - template class vecType, length_t L, precision P> - GLM_FUNC_QUALIFIER vecType floatBitsToUint(vecType const & v) + template + GLM_FUNC_QUALIFIER vec floatBitsToUint(vec const& v) { - return reinterpret_cast&>(const_cast&>(v)); + return reinterpret_cast&>(const_cast&>(v)); } GLM_FUNC_QUALIFIER float intBitsToFloat(int const & v) @@ -745,13 +745,13 @@ namespace detail return u.out; } - template class vecType, length_t L, precision P> - GLM_FUNC_QUALIFIER vecType intBitsToFloat(vecType const & v) + template + GLM_FUNC_QUALIFIER vec intBitsToFloat(vec const& v) { - return reinterpret_cast&>(const_cast&>(v)); + return reinterpret_cast&>(const_cast&>(v)); } - GLM_FUNC_QUALIFIER float uintBitsToFloat(uint const & v) + GLM_FUNC_QUALIFIER float uintBitsToFloat(uint const& v) { union { @@ -764,14 +764,14 @@ namespace detail return u.out; } - template class vecType, length_t L, precision P> - GLM_FUNC_QUALIFIER vecType uintBitsToFloat(vecType const & v) + template + GLM_FUNC_QUALIFIER vec uintBitsToFloat(vec const& v) { - return reinterpret_cast&>(const_cast&>(v)); + return reinterpret_cast&>(const_cast&>(v)); } template - GLM_FUNC_QUALIFIER genType fma(genType const & a, genType const & b, genType const & c) + GLM_FUNC_QUALIFIER genType fma(genType const& a, genType const& b, genType const& c) { return a * b + c; } @@ -785,7 +785,7 @@ namespace detail } template - GLM_FUNC_QUALIFIER vec<1, T, P> frexp(vec<1, T, P> const & x, vec<1, int, P> & exp) + GLM_FUNC_QUALIFIER vec<1, T, P> frexp(vec<1, T, P> const& x, vec<1, int, P>& exp) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'frexp' only accept floating-point inputs"); @@ -793,7 +793,7 @@ namespace detail } template - GLM_FUNC_QUALIFIER vec<2, T, P> frexp(vec<2, T, P> const & x, vec<2, int, P> & exp) + GLM_FUNC_QUALIFIER vec<2, T, P> frexp(vec<2, T, P> const& x, vec<2, int, P>& exp) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'frexp' only accept floating-point inputs"); @@ -803,7 +803,7 @@ namespace detail } template - GLM_FUNC_QUALIFIER vec<3, T, P> frexp(vec<3, T, P> const & x, vec<3, int, P> & exp) + GLM_FUNC_QUALIFIER vec<3, T, P> frexp(vec<3, T, P> const& x, vec<3, int, P>& exp) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'frexp' only accept floating-point inputs"); @@ -814,7 +814,7 @@ namespace detail } template - GLM_FUNC_QUALIFIER vec<4, T, P> frexp(vec<4, T, P> const & x, vec<4, int, P> & exp) + GLM_FUNC_QUALIFIER vec<4, T, P> frexp(vec<4, T, P> const& x, vec<4, int, P>& exp) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'frexp' only accept floating-point inputs"); @@ -826,7 +826,7 @@ namespace detail } template - GLM_FUNC_QUALIFIER genType ldexp(genType const & x, int const & exp) + GLM_FUNC_QUALIFIER genType ldexp(genType const& x, int const& exp) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'ldexp' only accept floating-point inputs"); @@ -834,7 +834,7 @@ namespace detail } template - GLM_FUNC_QUALIFIER vec<1, T, P> ldexp(vec<1, T, P> const & x, vec<1, int, P> const & exp) + GLM_FUNC_QUALIFIER vec<1, T, P> ldexp(vec<1, T, P> const& x, vec<1, int, P> const& exp) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'ldexp' only accept floating-point inputs"); @@ -843,7 +843,7 @@ namespace detail } template - GLM_FUNC_QUALIFIER vec<2, T, P> ldexp(vec<2, T, P> const & x, vec<2, int, P> const & exp) + GLM_FUNC_QUALIFIER vec<2, T, P> ldexp(vec<2, T, P> const& x, vec<2, int, P> const& exp) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'ldexp' only accept floating-point inputs"); @@ -853,7 +853,7 @@ namespace detail } template - GLM_FUNC_QUALIFIER vec<3, T, P> ldexp(vec<3, T, P> const & x, vec<3, int, P> const & exp) + GLM_FUNC_QUALIFIER vec<3, T, P> ldexp(vec<3, T, P> const& x, vec<3, int, P> const& exp) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'ldexp' only accept floating-point inputs"); @@ -864,7 +864,7 @@ namespace detail } template - GLM_FUNC_QUALIFIER vec<4, T, P> ldexp(vec<4, T, P> const & x, vec<4, int, P> const & exp) + GLM_FUNC_QUALIFIER vec<4, T, P> ldexp(vec<4, T, P> const& x, vec<4, int, P> const& exp) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'ldexp' only accept floating-point inputs"); diff --git a/glm/detail/func_common_simd.inl b/glm/detail/func_common_simd.inl index daf6408e..c238e53b 100644 --- a/glm/detail/func_common_simd.inl +++ b/glm/detail/func_common_simd.inl @@ -11,7 +11,7 @@ namespace glm{ namespace detail { template - struct compute_abs_vector<4, float, P, vec, true> + struct compute_abs_vector<4, float, P, true> { GLM_FUNC_QUALIFIER static vec<4, float, P> call(vec<4, float, P> const & v) { @@ -22,7 +22,7 @@ namespace detail }; template - struct compute_abs_vector<4, int, P, vec, true> + struct compute_abs_vector<4, int, P, true> { GLM_FUNC_QUALIFIER static vec<4, int, P> call(vec<4, int, P> const & v) { @@ -33,7 +33,7 @@ namespace detail }; template - struct compute_floor<4, float, P, vec, true> + struct compute_floor<4, float, P, true> { GLM_FUNC_QUALIFIER static vec<4, float, P> call(vec<4, float, P> const & v) { @@ -44,7 +44,7 @@ namespace detail }; template - struct compute_ceil<4, float, P, vec, true> + struct compute_ceil<4, float, P, true> { GLM_FUNC_QUALIFIER static vec<4, float, P> call(vec<4, float, P> const & v) { @@ -55,7 +55,7 @@ namespace detail }; template - struct compute_fract<4, float, P, vec, true> + struct compute_fract<4, float, P, true> { GLM_FUNC_QUALIFIER static vec<4, float, P> call(vec<4, float, P> const & v) { @@ -66,7 +66,7 @@ namespace detail }; template - struct compute_round<4, float, P, vec, true> + struct compute_round<4, float, P, true> { GLM_FUNC_QUALIFIER static vec<4, float, P> call(vec<4, float, P> const & v) { @@ -77,7 +77,7 @@ namespace detail }; template - struct compute_mod<4, float, P, vec, true> + struct compute_mod<4, float, P, true> { GLM_FUNC_QUALIFIER static vec<4, float, P> call(vec<4, float, P> const & x, vec<4, float, P> const & y) { @@ -88,7 +88,7 @@ namespace detail }; template - struct compute_min_vector<4, float, P, vec, true> + struct compute_min_vector<4, float, P, true> { GLM_FUNC_QUALIFIER static vec<4, float, P> call(vec<4, float, P> const & v1, vec<4, float, P> const & v2) { @@ -99,7 +99,7 @@ namespace detail }; template - struct compute_min_vector<4, int32, P, vec, true> + struct compute_min_vector<4, int32, P, true> { GLM_FUNC_QUALIFIER static vec<4, int32, P> call(vec<4, int32, P> const & v1, vec<4, int32, P> const & v2) { @@ -110,7 +110,7 @@ namespace detail }; template - struct compute_min_vector<4, uint32, P, vec, true> + struct compute_min_vector<4, uint32, P, true> { GLM_FUNC_QUALIFIER static vec<4, int32, P> call(vec<4, uint32, P> const & v1, vec<4, uint32, P> const & v2) { @@ -121,7 +121,7 @@ namespace detail }; template - struct compute_max_vector<4, float, P, vec, true> + struct compute_max_vector<4, float, P, true> { GLM_FUNC_QUALIFIER static vec<4, float, P> call(vec<4, float, P> const & v1, vec<4, float, P> const & v2) { @@ -132,7 +132,7 @@ namespace detail }; template - struct compute_max_vector<4, int32, P, vec, true> + struct compute_max_vector<4, int32, P, true> { GLM_FUNC_QUALIFIER static vec<4, int32, P> call(vec<4, int32, P> const & v1, vec<4, int32, P> const & v2) { @@ -143,7 +143,7 @@ namespace detail }; template - struct compute_max_vector<4, uint32, P, vec, true> + struct compute_max_vector<4, uint32, P, true> { GLM_FUNC_QUALIFIER static vec<4, uint32, P> call(vec<4, uint32, P> const & v1, vec<4, uint32, P> const & v2) { @@ -154,7 +154,7 @@ namespace detail }; template - struct compute_clamp_vector<4, float, P, vec, true> + struct compute_clamp_vector<4, float, P, true> { GLM_FUNC_QUALIFIER static vec<4, float, P> call(vec<4, float, P> const & x, vec<4, float, P> const & minVal, vec<4, float, P> const & maxVal) { @@ -165,7 +165,7 @@ namespace detail }; template - struct compute_clamp_vector<4, int32, P, vec, true> + struct compute_clamp_vector<4, int32, P, true> { GLM_FUNC_QUALIFIER static vec<4, int32, P> call(vec<4, int32, P> const & x, vec<4, int32, P> const & minVal, vec<4, int32, P> const & maxVal) { @@ -176,7 +176,7 @@ namespace detail }; template - struct compute_clamp_vector<4, uint32, P, vec, true> + struct compute_clamp_vector<4, uint32, P, true> { GLM_FUNC_QUALIFIER static vec<4, uint32, P> call(vec<4, uint32, P> const & x, vec<4, uint32, P> const & minVal, vec<4, uint32, P> const & maxVal) { @@ -187,7 +187,7 @@ namespace detail }; template - struct compute_mix_vector<4, float, bool, P, vec, true> + struct compute_mix_vector<4, float, bool, P, true> { GLM_FUNC_QUALIFIER static vec<4, float, P> call(vec<4, float, P> const & x, vec<4, float, P> const & y, vec<4, bool, P> const & a) { @@ -216,7 +216,7 @@ namespace detail }; */ template - struct compute_smoothstep_vector<4, float, P, vec, true> + struct compute_smoothstep_vector<4, float, P, true> { GLM_FUNC_QUALIFIER static vec<4, float, P> call(vec<4, float, P> const& edge0, vec<4, float, P> const& edge1, vec<4, float, P> const& x) { diff --git a/glm/detail/func_exponential.hpp b/glm/detail/func_exponential.hpp index 89ba5806..21b3f735 100644 --- a/glm/detail/func_exponential.hpp +++ b/glm/detail/func_exponential.hpp @@ -25,77 +25,80 @@ namespace glm /// /// @param base Floating point value. pow function is defined for input values of 'base' 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 class vecType> - GLM_FUNC_DECL vecType pow(vecType const & base, vecType const & exponent); + template + GLM_FUNC_DECL vec pow(vec const & base, vec const& exponent); /// Returns the natural exponentiation of x, i.e., e^x. /// /// @param v exp function is defined for input values of v defined in the range (inf-, inf+) in the limit of the type precision. - /// @tparam genType Floating-point scalar or vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Floating-point scalar types. /// /// @see GLSL exp man page /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions - template class vecType> - GLM_FUNC_DECL vecType exp(vecType const & v); + template + GLM_FUNC_DECL vec exp(vec const& v); /// Returns the natural logarithm of v, i.e., /// returns the value y which satisfies the equation x = e^y. /// Results are undefined if v <= 0. /// /// @param v log function is defined for input values of v defined in the range (0, inf+) in the limit of the type precision. - /// @tparam genType Floating-point scalar or vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Floating-point scalar types. /// /// @see GLSL log man page /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions - template class vecType> - GLM_FUNC_DECL vecType log(vecType const & v); + template + GLM_FUNC_DECL vec log(vec const& v); /// Returns 2 raised to the v power. /// /// @param v exp2 function is defined for input values of v defined in the range (inf-, inf+) in the limit of the type precision. - /// @tparam genType Floating-point scalar or vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Floating-point scalar types. /// /// @see GLSL exp2 man page /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions - template class vecType> - GLM_FUNC_DECL vecType exp2(vecType const & v); + template + GLM_FUNC_DECL vec exp2(vec const& v); /// Returns the base 2 log of x, i.e., returns the value y, /// which satisfies the equation x = 2 ^ y. /// /// @param v log2 function is defined for input values of v defined in the range (0, inf+) in the limit of the type precision. - /// @tparam genType Floating-point scalar or vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Floating-point scalar types. /// /// @see GLSL log2 man page /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions - template class vecType> - GLM_FUNC_DECL vecType log2(vecType const & v); + template + GLM_FUNC_DECL vec log2(vec const& v); /// Returns the positive square root of v. /// /// @param v sqrt function is defined for input values of v defined in the range [0, inf+) in the limit of the type precision. - /// @tparam genType Floating-point scalar or vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Floating-point scalar 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 & v); + template + GLM_FUNC_DECL vec sqrt(vec const & v); /// Returns the reciprocal of the positive square root of v. /// /// @param v inversesqrt function is defined for input values of v defined in the range [0, inf+) in the limit of the type precision. - /// @tparam genType Floating-point scalar or vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Floating-point scalar types. /// /// @see GLSL inversesqrt man page /// @see GLSL 4.20.8 specification, section 8.2 Exponential Functions - template class vecType> - GLM_FUNC_DECL vecType inversesqrt(vecType const & v); + template + GLM_FUNC_DECL vec inversesqrt(vec const & v); /// @} }//namespace glm diff --git a/glm/detail/func_exponential.inl b/glm/detail/func_exponential.inl index a1e49a3e..0d5fab7b 100644 --- a/glm/detail/func_exponential.inl +++ b/glm/detail/func_exponential.inl @@ -20,7 +20,7 @@ namespace detail } # endif - template class vecType, bool isFloat, bool Aligned> + template struct compute_log2 { GLM_FUNC_QUALIFIER static vec call(vec const& v) @@ -66,24 +66,24 @@ namespace detail // pow using std::pow; - template class vecType> - GLM_FUNC_QUALIFIER vecType pow(vecType const & base, vecType const& exponent) + template + GLM_FUNC_QUALIFIER vec pow(vec const & base, vec const& exponent) { return detail::functor2::call(pow, base, exponent); } // exp using std::exp; - template class vecType> - GLM_FUNC_QUALIFIER vecType exp(vecType const& x) + template + GLM_FUNC_QUALIFIER vec exp(vec const& x) { return detail::functor1::call(exp, x); } // log using std::log; - template class vecType> - GLM_FUNC_QUALIFIER vecType log(vecType const& x) + template + GLM_FUNC_QUALIFIER vec log(vec const& x) { return detail::functor1::call(log, x); } @@ -97,8 +97,8 @@ namespace detail return std::exp(static_cast(0.69314718055994530941723212145818) * x); } - template class vecType> - GLM_FUNC_QUALIFIER vecType exp2(vecType const& x) + template + GLM_FUNC_QUALIFIER vec exp2(vec const& x) { return detail::functor1::call(exp2, x); } @@ -110,16 +110,16 @@ namespace detail return log2(vec<1, genType>(x)).x; } - template class vecType> - GLM_FUNC_QUALIFIER vecType log2(vecType const& x) + template + GLM_FUNC_QUALIFIER vec log2(vec const& x) { - return detail::compute_log2::is_iec559, detail::is_aligned

::value>::call(x); + return detail::compute_log2::is_iec559, detail::is_aligned

::value>::call(x); } // sqrt using std::sqrt; - template class vecType> - GLM_FUNC_QUALIFIER vecType sqrt(vecType const& x) + template + GLM_FUNC_QUALIFIER vec sqrt(vec const& x) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'sqrt' only accept floating-point inputs"); return detail::compute_sqrt::value>::call(x); @@ -132,8 +132,8 @@ namespace detail return static_cast(1) / sqrt(x); } - template class vecType> - GLM_FUNC_QUALIFIER vecType inversesqrt(vecType const& x) + template + GLM_FUNC_QUALIFIER vec inversesqrt(vec const& x) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'inversesqrt' only accept floating-point inputs"); return detail::compute_inversesqrt::value>::call(x); diff --git a/glm/detail/func_geometric.hpp b/glm/detail/func_geometric.hpp index d5a737b5..c10541e0 100644 --- a/glm/detail/func_geometric.hpp +++ b/glm/detail/func_geometric.hpp @@ -19,92 +19,93 @@ namespace glm /// Returns the length of x, i.e., sqrt(x * x). /// - /// @tparam genType Floating-point vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Floating-point scalar types. /// /// @see GLSL length man page /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions - template class vecType> - GLM_FUNC_DECL T length( - vecType const& x); + template + GLM_FUNC_DECL T length(vec const& x); /// Returns the distance betwwen p0 and p1, i.e., length(p0 - p1). /// - /// @tparam genType Floating-point vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Floating-point scalar types. /// /// @see GLSL distance man page /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions - template class vecType> - GLM_FUNC_DECL T distance( - vecType const& p0, - vecType const& p1); + template + GLM_FUNC_DECL T distance(vec const& p0, vec const& p1); /// Returns the dot product of x and y, i.e., result = x * y. /// - /// @tparam genType Floating-point vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Floating-point scalar types. /// /// @see GLSL dot man page /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions template - GLM_FUNC_DECL T dot( - vec const & x, - vec const & y); + GLM_FUNC_DECL T dot(vec const & x, vec const & y); /// Returns the cross product of x and y. /// - /// @tparam valType Floating-point scalar types. + /// @tparam T Floating-point scalar types. /// /// @see GLSL cross man page /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions template - GLM_FUNC_DECL vec<3, T, P> cross( - vec<3, T, P> const & x, - vec<3, T, P> const & y); + GLM_FUNC_DECL vec<3, T, P> cross(vec<3, T, P> const & x, vec<3, T, P> const & y); /// Returns a vector in the same direction as x but with length of 1. /// According to issue 10 GLSL 1.10 specification, if length(x) == 0 then result is undefined and generate an error. + /// + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Floating-point scalar types. /// /// @see GLSL normalize man page /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions - template class vecType> - GLM_FUNC_DECL vecType normalize( - vecType const& x); + template + GLM_FUNC_DECL vec normalize(vec const& x); /// If dot(Nref, I) < 0.0, return N, otherwise, return -N. /// - /// @tparam genType Floating-point vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Floating-point scalar types. /// /// @see GLSL faceforward man page /// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions - template class vecType> - GLM_FUNC_DECL vecType faceforward( - vecType const& N, - vecType const& I, - vecType const& Nref); + template + GLM_FUNC_DECL vec faceforward( + vec const& N, + vec const& I, + vec 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. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Floating-point scalar 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); + template + GLM_FUNC_DECL vec reflect( + vec const& I, + vec 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. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Floating-point scalar 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, + template + GLM_FUNC_DECL vec refract( + vec const& I, + vec const& N, T eta); /// @} diff --git a/glm/detail/func_geometric.inl b/glm/detail/func_geometric.inl index dd891d63..3dd31dfe 100644 --- a/glm/detail/func_geometric.inl +++ b/glm/detail/func_geometric.inl @@ -10,19 +10,19 @@ namespace glm{ namespace detail { - template class vecType, length_t L, typename T, precision P, bool Aligned> + template struct compute_length { - GLM_FUNC_QUALIFIER static T call(vecType const & v) + GLM_FUNC_QUALIFIER static T call(vec const& v) { return sqrt(dot(v, v)); } }; - template class vecType, length_t L, typename T, precision P, bool Aligned> + template struct compute_distance { - GLM_FUNC_QUALIFIER static T call(vecType const & p0, vecType const & p1) + GLM_FUNC_QUALIFIER static T call(vec const& p0, vec const& p1) { return length(p1 - p0); } @@ -34,7 +34,7 @@ namespace detail template struct compute_dot, T, Aligned> { - GLM_FUNC_QUALIFIER static T call(vec<1, T, P> const & a, vec<1, T, P> const & b) + GLM_FUNC_QUALIFIER static T call(vec<1, T, P> const& a, vec<1, T, P> const& b) { return a.x * b.x; } @@ -43,7 +43,7 @@ namespace detail template struct compute_dot, T, Aligned> { - GLM_FUNC_QUALIFIER static T call(vec<2, T, P> const & a, vec<2, T, P> const & b) + GLM_FUNC_QUALIFIER static T call(vec<2, T, P> const& a, vec<2, T, P> const& b) { vec<2, T, P> tmp(a * b); return tmp.x + tmp.y; @@ -53,7 +53,7 @@ namespace detail template struct compute_dot, T, Aligned> { - GLM_FUNC_QUALIFIER static T call(vec<3, T, P> const & a, vec<3, T, P> const & b) + GLM_FUNC_QUALIFIER static T call(vec<3, T, P> const& a, vec<3, T, P> const& b) { vec<3, T, P> tmp(a * b); return tmp.x + tmp.y + tmp.z; @@ -63,7 +63,7 @@ namespace detail template struct compute_dot, T, Aligned> { - GLM_FUNC_QUALIFIER static T call(vec<4, T, P> const & a, vec<4, T, P> const & b) + GLM_FUNC_QUALIFIER static T call(vec<4, T, P> const& a, vec<4, T, P> const& b) { vec<4, T, P> tmp(a * b); return (tmp.x + tmp.y) + (tmp.z + tmp.w); @@ -73,7 +73,7 @@ namespace detail template struct compute_cross { - GLM_FUNC_QUALIFIER static vec<3, T, P> call(vec<3, T, P> const & x, vec<3, T, P> const & y) + GLM_FUNC_QUALIFIER static vec<3, T, P> call(vec<3, T, P> const& x, vec<3, T, P> const& y) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'cross' accepts only floating-point inputs"); @@ -84,10 +84,10 @@ namespace detail } }; - template class vecType, bool Aligned> + template struct compute_normalize { - GLM_FUNC_QUALIFIER static vecType call(vecType const & v) + GLM_FUNC_QUALIFIER static vec call(vec const& v) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'normalize' accepts only floating-point inputs"); @@ -95,10 +95,10 @@ namespace detail } }; - template class vecType, bool Aligned> + template struct compute_faceforward { - GLM_FUNC_QUALIFIER static vecType call(vecType const & N, vecType const & I, vecType const & Nref) + GLM_FUNC_QUALIFIER static vec call(vec const& N, vec const& I, vec const& Nref) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'normalize' accepts only floating-point inputs"); @@ -106,19 +106,19 @@ namespace detail } }; - template class vecType, bool Aligned> + template struct compute_reflect { - GLM_FUNC_QUALIFIER static vecType call(vecType const & I, vecType const & N) + GLM_FUNC_QUALIFIER static vec call(vec const& I, vec const& N) { return I - N * dot(N, I) * static_cast(2); } }; - template class vecType, bool Aligned> + template struct compute_refract { - GLM_FUNC_QUALIFIER static vecType call(vecType const & I, vecType const & N, T eta) + GLM_FUNC_QUALIFIER static vec call(vec const& I, vec const& N, T eta) { T const dotValue(dot(N, I)); T const k(static_cast(1) - eta * eta * (static_cast(1) - dotValue * dotValue)); @@ -136,27 +136,27 @@ namespace detail return abs(x); } - template class vecType> - GLM_FUNC_QUALIFIER T length(vecType const & v) + template + GLM_FUNC_QUALIFIER T length(vec const& v) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'length' accepts only floating-point inputs"); - return detail::compute_length::value>::call(v); + return detail::compute_length::value>::call(v); } // distance template - GLM_FUNC_QUALIFIER genType distance(genType const & p0, genType const & p1) + GLM_FUNC_QUALIFIER genType distance(genType const& p0, genType const& p1) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'distance' accepts only floating-point inputs"); return length(p1 - p0); } - template class vecType> - GLM_FUNC_QUALIFIER T distance(vecType const & p0, vecType const & p1) + template + GLM_FUNC_QUALIFIER T distance(vec const& p0, vec const& p1) { - return detail::compute_distance::value>::call(p0, p1); + return detail::compute_distance::value>::call(p0, p1); } // dot @@ -168,14 +168,14 @@ namespace detail } template - GLM_FUNC_QUALIFIER T dot(vec const & x, vec const & y) + GLM_FUNC_QUALIFIER T dot(vec const& x, vec const& y) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'dot' accepts only floating-point inputs"); return detail::compute_dot, T, detail::is_aligned

::value>::call(x, y); } template - GLM_FUNC_QUALIFIER T dot(tquat const & x, tquat const & y) + GLM_FUNC_QUALIFIER T dot(tquat const& x, tquat const& y) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'dot' accepts only floating-point inputs"); return detail::compute_dot, T, detail::is_aligned

::value>::call(x, y); @@ -183,57 +183,57 @@ namespace detail // cross template - GLM_FUNC_QUALIFIER vec<3, T, P> cross(vec<3, T, P> const & x, vec<3, T, P> const & y) + GLM_FUNC_QUALIFIER vec<3, T, P> cross(vec<3, T, P> const& x, vec<3, T, P> const& y) { return detail::compute_cross::value>::call(x, y); } // normalize template - GLM_FUNC_QUALIFIER genType normalize(genType const & x) + GLM_FUNC_QUALIFIER genType normalize(genType const& x) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'normalize' accepts only floating-point inputs"); return x < genType(0) ? genType(-1) : genType(1); } - template class vecType> - GLM_FUNC_QUALIFIER vecType normalize(vecType const & x) + template + GLM_FUNC_QUALIFIER vec normalize(vec const& x) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'normalize' accepts only floating-point inputs"); - return detail::compute_normalize::value>::call(x); + return detail::compute_normalize::value>::call(x); } // faceforward template - GLM_FUNC_QUALIFIER genType faceforward(genType const & N, genType const & I, genType const & Nref) + GLM_FUNC_QUALIFIER genType faceforward(genType const& N, genType const& I, genType const& Nref) { return dot(Nref, I) < static_cast(0) ? N : -N; } - template class vecType> - GLM_FUNC_QUALIFIER vecType faceforward(vecType const & N, vecType const & I, vecType const & Nref) + template + GLM_FUNC_QUALIFIER vec faceforward(vec const& N, vec const& I, vec const& Nref) { - return detail::compute_faceforward::value>::call(N, I, Nref); + return detail::compute_faceforward::value>::call(N, I, Nref); } // reflect template - GLM_FUNC_QUALIFIER genType reflect(genType const & I, genType const & N) + GLM_FUNC_QUALIFIER genType reflect(genType const& I, genType const& N) { return I - N * dot(N, I) * genType(2); } - template class vecType> - GLM_FUNC_QUALIFIER vecType reflect(vecType const & I, vecType const & N) + template + GLM_FUNC_QUALIFIER vec reflect(vec const& I, vec const& N) { - return detail::compute_reflect::value>::call(I, N); + return detail::compute_reflect::value>::call(I, N); } // refract template - GLM_FUNC_QUALIFIER genType refract(genType const & I, genType const & N, genType eta) + GLM_FUNC_QUALIFIER genType refract(genType const& I, genType const& N, genType eta) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'refract' accepts only floating-point inputs"); genType const dotValue(dot(N, I)); @@ -241,11 +241,11 @@ namespace detail return (eta * I - (eta * dotValue + sqrt(k)) * N) * static_cast(k >= static_cast(0)); } - template class vecType> - GLM_FUNC_QUALIFIER vecType refract(vecType const & I, vecType const & N, T eta) + template + GLM_FUNC_QUALIFIER vec refract(vec const& I, vec const& N, T eta) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'refract' accepts only floating-point inputs"); - return detail::compute_refract::value>::call(I, N, eta); + return detail::compute_refract::value>::call(I, N, eta); } }//namespace glm diff --git a/glm/detail/func_geometric_simd.inl b/glm/detail/func_geometric_simd.inl index 3819c6a2..55a0f2d4 100644 --- a/glm/detail/func_geometric_simd.inl +++ b/glm/detail/func_geometric_simd.inl @@ -9,7 +9,7 @@ namespace glm{ namespace detail { template - struct compute_length + struct compute_length<4, float, P, true> { GLM_FUNC_QUALIFIER static float call(vec<4, float, P> const & v) { @@ -18,7 +18,7 @@ namespace detail }; template - struct compute_distance + struct compute_distance<4, float, P, true> { GLM_FUNC_QUALIFIER static float call(vec<4, float, P> const & p0, vec<4, float, P> const & p1) { @@ -51,7 +51,7 @@ namespace detail }; template - struct compute_normalize<4, float, P, vec, true> + struct compute_normalize<4, float, P, true> { GLM_FUNC_QUALIFIER static vec<4, float, P> call(vec<4, float, P> const & v) { @@ -62,7 +62,7 @@ namespace detail }; template - struct compute_faceforward<4, float, P, vec, true> + struct compute_faceforward<4, float, P, true> { GLM_FUNC_QUALIFIER static vec<4, float, P> call(vec<4, float, P> const& N, vec<4, float, P> const& I, vec<4, float, P> const& Nref) { @@ -73,7 +73,7 @@ namespace detail }; template - struct compute_reflect<4, float, P, vec, true> + struct compute_reflect<4, float, P, true> { GLM_FUNC_QUALIFIER static vec<4, float, P> call(vec<4, float, P> const& I, vec<4, float, P> const& N) { @@ -84,7 +84,7 @@ namespace detail }; template - struct compute_refract<4, float, P, vec, true> + struct compute_refract<4, float, P, true> { GLM_FUNC_QUALIFIER static vec<4, float, P> call(vec<4, float, P> const& I, vec<4, float, P> const& N, float eta) { diff --git a/glm/detail/func_integer.hpp b/glm/detail/func_integer.hpp index 375d6014..1886e2f4 100644 --- a/glm/detail/func_integer.hpp +++ b/glm/detail/func_integer.hpp @@ -26,59 +26,59 @@ namespace glm /// modulo pow(2, 32). The value carry is set to 0 if the sum was /// less than pow(2, 32), or to 1 otherwise. /// - /// @tparam genUType Unsigned integer scalar or vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. /// /// @see GLSL uaddCarry man page /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions - template class vecType> - GLM_FUNC_DECL vecType uaddCarry( - vecType const & x, - vecType const & y, - vecType & carry); + template + GLM_FUNC_DECL vec uaddCarry( + vec const & x, + vec const & y, + vec & carry); /// Subtracts the 32-bit unsigned integer y from x, returning /// the difference if non-negative, or pow(2, 32) plus the difference /// otherwise. The value borrow is set to 0 if x >= y, or to 1 otherwise. /// - /// @tparam genUType Unsigned integer scalar or vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. /// /// @see GLSL usubBorrow man page /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions - template class vecType> - GLM_FUNC_DECL vecType usubBorrow( - vecType const & x, - vecType const & y, - vecType & borrow); + template + GLM_FUNC_DECL vec usubBorrow( + vec const & x, + vec const & y, + vec & borrow); /// Multiplies 32-bit integers x and y, producing a 64-bit /// result. The 32 least-significant bits are returned in lsb. /// The 32 most-significant bits are returned in msb. /// - /// @tparam genUType Unsigned integer scalar or vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. /// /// @see GLSL umulExtended man page /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions - template class vecType> + template GLM_FUNC_DECL void umulExtended( - vecType const & x, - vecType const & y, - vecType & msb, - vecType & lsb); + vec const & x, + vec const & y, + vec & msb, + vec & lsb); /// Multiplies 32-bit integers x and y, producing a 64-bit /// result. The 32 least-significant bits are returned in lsb. /// The 32 most-significant bits are returned in msb. /// - /// @tparam genIType Signed integer scalar or vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. /// /// @see GLSL imulExtended man page /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions - template class vecType> + template GLM_FUNC_DECL void imulExtended( - vecType const & x, - vecType const & y, - vecType & msb, - vecType & lsb); + vec const & x, + vec const & y, + vec & msb, + vec & lsb); /// Extracts bits [offset, offset + bits - 1] from value, /// returning them in the least significant bits of the result. @@ -91,13 +91,14 @@ namespace glm /// offset and bits is greater than the number of bits used /// to store the operand. /// - /// @tparam T Signed or unsigned integer scalar or vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T Signed or unsigned integer scalar types. /// /// @see GLSL bitfieldExtract man page /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions - template class vecType> - GLM_FUNC_DECL vecType bitfieldExtract( - vecType const& Value, + template + GLM_FUNC_DECL vec bitfieldExtract( + vec const& Value, int Offset, int Bits); @@ -111,14 +112,15 @@ namespace glm /// offset and bits is greater than the number of bits used to /// store the operand. /// + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. /// @tparam T Signed or unsigned integer scalar or vector types. /// /// @see GLSL bitfieldInsert man page /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions - template class vecType> - GLM_FUNC_DECL vecType bitfieldInsert( - vecType const& Base, - vecType const& Insert, + template + GLM_FUNC_DECL vec bitfieldInsert( + vec const& Base, + vec const& Insert, int Offset, int Bits); @@ -126,16 +128,17 @@ namespace glm /// The bit numbered n of the result will be taken from bit (bits - 1) - n of value, /// where bits is the total number of bits used to represent value. /// + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. /// @tparam T Signed or unsigned integer scalar or vector types. /// /// @see GLSL bitfieldReverse man page /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions - template class vecType> - GLM_FUNC_DECL vecType bitfieldReverse(vecType const & v); + template + GLM_FUNC_DECL vec bitfieldReverse(vec const & v); /// Returns the number of bits set to 1 in the binary representation of value. /// - /// @tparam T Signed or unsigned integer scalar or vector types. + /// @tparam genType Signed or unsigned integer scalar or vector types. /// /// @see GLSL bitCount man page /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions @@ -144,18 +147,19 @@ namespace glm /// Returns the number of bits set to 1 in the binary representation of value. /// + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. /// @tparam T Signed or unsigned integer scalar or vector types. /// /// @see GLSL bitCount man page /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions - template class vecType> - GLM_FUNC_DECL vecType bitCount(vecType const & v); + template + GLM_FUNC_DECL vec bitCount(vec const & v); /// Returns the bit number of the least significant bit set to /// 1 in the binary representation of value. /// If value is zero, -1 will be returned. /// - /// @tparam T Signed or unsigned integer scalar types. + /// @tparam genIUType Signed or unsigned integer scalar types. /// /// @see GLSL findLSB man page /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions @@ -166,19 +170,20 @@ namespace glm /// 1 in the binary representation of value. /// If value is zero, -1 will be returned. /// + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. /// @tparam T Signed or unsigned integer scalar types. /// /// @see GLSL findLSB man page /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions - template class vecType> - GLM_FUNC_DECL vecType findLSB(vecType const & v); + template + GLM_FUNC_DECL vec findLSB(vec const & v); /// Returns the bit number of the most significant bit in the binary representation of value. /// For positive integers, the result will be the bit number of the most significant bit set to 1. /// For negative integers, the result will be the bit number of the most significant /// bit set to 0. For a value of zero or negative one, -1 will be returned. /// - /// @tparam T Signed or unsigned integer scalar types. + /// @tparam genIUType Signed or unsigned integer scalar types. /// /// @see GLSL findMSB man page /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions @@ -190,12 +195,13 @@ namespace glm /// For negative integers, the result will be the bit number of the most significant /// bit set to 0. For a value of zero or negative one, -1 will be returned. /// + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. /// @tparam T Signed or unsigned integer scalar types. /// /// @see GLSL findMSB man page /// @see GLSL 4.20.8 specification, section 8.8 Integer Functions - template class vecType> - GLM_FUNC_DECL vecType findMSB(vecType const & v); + template + GLM_FUNC_DECL vec findMSB(vec const & v); /// @} }//namespace glm diff --git a/glm/detail/func_integer.inl b/glm/detail/func_integer.inl index 8c3b1dd0..6421f689 100644 --- a/glm/detail/func_integer.inl +++ b/glm/detail/func_integer.inl @@ -27,40 +27,40 @@ namespace detail template GLM_FUNC_QUALIFIER T mask(T Bits) { - return Bits >= sizeof(T) * 8 ? ~static_cast(0) : (static_cast(1) << Bits) - static_cast(1); + return Bits >= static_cast(sizeof(T) * 8) ? ~static_cast(0) : (static_cast(1) << Bits) - static_cast(1); } - template class vecType, bool Aligned, bool EXEC> + template struct compute_bitfieldReverseStep { - GLM_FUNC_QUALIFIER static vecType call(vecType const& v, T, T) + GLM_FUNC_QUALIFIER static vec call(vec const& v, T, T) { return v; } }; - template class vecType, bool Aligned> - struct compute_bitfieldReverseStep + template + struct compute_bitfieldReverseStep { - GLM_FUNC_QUALIFIER static vecType call(vecType const& v, T Mask, T Shift) + GLM_FUNC_QUALIFIER static vec call(vec const& v, T Mask, T Shift) { return (v & Mask) << Shift | (v & (~Mask)) >> Shift; } }; - template class vecType, bool Aligned, bool EXEC> + template struct compute_bitfieldBitCountStep { - GLM_FUNC_QUALIFIER static vecType call(vecType const& v, T, T) + GLM_FUNC_QUALIFIER static vec call(vec const& v, T, T) { return v; } }; - template class vecType, bool Aligned> - struct compute_bitfieldBitCountStep + template + struct compute_bitfieldBitCountStep { - GLM_FUNC_QUALIFIER static vecType call(vecType const& v, T Mask, T Shift) + GLM_FUNC_QUALIFIER static vec call(vec const& v, T Mask, T Shift) { return (v & Mask) + ((v >> Shift) & Mask); } @@ -104,37 +104,37 @@ namespace detail # endif # endif//GLM_HAS_BITSCAN_WINDOWS - template class vecType, bool EXEC = true> + template struct compute_findMSB_step_vec { - GLM_FUNC_QUALIFIER static vecType call(vecType const & x, T Shift) + GLM_FUNC_QUALIFIER static vec call(vec const& x, T Shift) { return x | (x >> Shift); } }; - template class vecType> - struct compute_findMSB_step_vec + template + struct compute_findMSB_step_vec { - GLM_FUNC_QUALIFIER static vecType call(vecType const& x, T) + GLM_FUNC_QUALIFIER static vec call(vec const& x, T) { return x; } }; - template class vecType, int> + template struct compute_findMSB_vec { - GLM_FUNC_QUALIFIER static vecType call(vecType const& v) + GLM_FUNC_QUALIFIER static vec call(vec const& v) { - vecType x(v); - x = compute_findMSB_step_vec= 8>::call(x, static_cast( 1)); - x = compute_findMSB_step_vec= 8>::call(x, static_cast( 2)); - x = compute_findMSB_step_vec= 8>::call(x, static_cast( 4)); - x = compute_findMSB_step_vec= 16>::call(x, static_cast( 8)); - x = compute_findMSB_step_vec= 32>::call(x, static_cast(16)); - x = compute_findMSB_step_vec= 64>::call(x, static_cast(32)); - return vecType(sizeof(T) * 8 - 1) - glm::bitCount(~x); + vec x(v); + x = compute_findMSB_step_vec= 8>::call(x, static_cast( 1)); + x = compute_findMSB_step_vec= 8>::call(x, static_cast( 2)); + x = compute_findMSB_step_vec= 8>::call(x, static_cast( 4)); + x = compute_findMSB_step_vec= 16>::call(x, static_cast( 8)); + x = compute_findMSB_step_vec= 32>::call(x, static_cast(16)); + x = compute_findMSB_step_vec= 64>::call(x, static_cast(32)); + return vec(sizeof(T) * 8 - 1) - glm::bitCount(~x); } }; @@ -147,10 +147,10 @@ namespace detail return IsNotNull ? int(Result) : -1; } - template class vecType> - struct compute_findMSB_vec + template + struct compute_findMSB_vec { - GLM_FUNC_QUALIFIER static vecType call(vecType const& x) + GLM_FUNC_QUALIFIER static vec call(vec const& x) { return detail::functor1::call(compute_findMSB_32, x); } @@ -165,10 +165,10 @@ namespace detail return IsNotNull ? int(Result) : -1; } - template class vecType> - struct compute_findMSB_vec + template + struct compute_findMSB_vec { - GLM_FUNC_QUALIFIER static vecType call(vecType const& x) + GLM_FUNC_QUALIFIER static vec call(vec const& x) { return detail::functor1::call(compute_findMSB_64, x); } @@ -186,13 +186,13 @@ namespace detail return static_cast(Value64 % (Max32 + static_cast(1))); } - template class vecType> - GLM_FUNC_QUALIFIER vecType uaddCarry(vecType const& x, vecType const& y, vecType& Carry) + template + GLM_FUNC_QUALIFIER vec uaddCarry(vec const& x, vec const& y, vec& Carry) { - vecType Value64(vecType(x) + vecType(y)); - vecType Max32((static_cast(1) << static_cast(32)) - static_cast(1)); - Carry = mix(vecType(0), vecType(1), greaterThan(Value64, Max32)); - return vecType(Value64 % (Max32 + static_cast(1))); + vec Value64(vec(x) + vec(y)); + vec Max32((static_cast(1) << static_cast(32)) - static_cast(1)); + Carry = mix(vec(0), vec(1), greaterThan(Value64, Max32)); + return vec(Value64 % (Max32 + static_cast(1))); } // usubBorrow @@ -207,12 +207,12 @@ namespace detail return static_cast((static_cast(1) << static_cast(32)) + (static_cast(y) - static_cast(x))); } - template class vecType> - GLM_FUNC_QUALIFIER vecType usubBorrow(vecType const& x, vecType const& y, vecType& Borrow) + template + GLM_FUNC_QUALIFIER vec usubBorrow(vec const& x, vec const& y, vec& Borrow) { - Borrow = mix(vecType(1), vecType(0), greaterThanEqual(x, y)); - vecType const YgeX(y - x); - vecType const XgeY(vecType((static_cast(1) << static_cast(32)) + (vecType(y) - vecType(x)))); + Borrow = mix(vec(1), vec(0), greaterThanEqual(x, y)); + vec const YgeX(y - x); + vec const XgeY(vec((static_cast(1) << static_cast(32)) + (vec(y) - vec(x)))); return mix(XgeY, YgeX, greaterThanEqual(y, x)); } @@ -226,14 +226,14 @@ namespace detail lsb = static_cast(Value64); } - template class vecType> - GLM_FUNC_QUALIFIER void umulExtended(vecType const& x, vecType const& y, vecType& msb, vecType& lsb) + template + GLM_FUNC_QUALIFIER void umulExtended(vec const& x, vec const& y, vec& msb, vec& lsb) { GLM_STATIC_ASSERT(sizeof(uint) == sizeof(uint32), "uint and uint32 size mismatch"); - vecType Value64(vecType(x) * vecType(y)); - msb = vecType(Value64 >> static_cast(32)); - lsb = vecType(Value64); + vec Value64(vec(x) * vec(y)); + msb = vec(Value64 >> static_cast(32)); + lsb = vec(Value64); } // imulExtended @@ -246,14 +246,14 @@ namespace detail lsb = static_cast(Value64); } - template class vecType> - GLM_FUNC_QUALIFIER void imulExtended(vecType const& x, vecType const& y, vecType& msb, vecType& lsb) + template + GLM_FUNC_QUALIFIER void imulExtended(vec const& x, vec const& y, vec& msb, vec& lsb) { GLM_STATIC_ASSERT(sizeof(int) == sizeof(int32), "int and int32 size mismatch"); - vecType Value64(vecType(x) * vecType(y)); - lsb = vecType(Value64 & static_cast(0xFFFFFFFF)); - msb = vecType((Value64 >> static_cast(32)) & static_cast(0xFFFFFFFF)); + vec Value64(vec(x) * vec(y)); + lsb = vec(Value64 & static_cast(0xFFFFFFFF)); + msb = vec((Value64 >> static_cast(32)) & static_cast(0xFFFFFFFF)); } // bitfieldExtract @@ -263,8 +263,8 @@ namespace detail return bitfieldExtract(vec<1, genIUType>(Value), Offset, Bits).x; } - template class vecType> - GLM_FUNC_QUALIFIER vecType bitfieldExtract(vecType const& Value, int Offset, int Bits) + template + GLM_FUNC_QUALIFIER vec bitfieldExtract(vec const& Value, int Offset, int Bits) { GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitfieldExtract' only accept integer inputs"); @@ -278,8 +278,8 @@ namespace detail return bitfieldInsert(vec<1, genIUType>(Base), vec<1, genIUType>(Insert), Offset, Bits).x; } - template class vecType> - GLM_FUNC_QUALIFIER vecType bitfieldInsert(vecType const& Base, vecType const& Insert, int Offset, int Bits) + template + GLM_FUNC_QUALIFIER vec bitfieldInsert(vec const& Base, vec const& Insert, int Offset, int Bits) { GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitfieldInsert' only accept integer values"); @@ -294,16 +294,16 @@ namespace detail return bitfieldReverse(glm::vec<1, genType, glm::defaultp>(x)).x; } - template class vecType> - GLM_FUNC_QUALIFIER vecType bitfieldReverse(vecType const& v) + template + GLM_FUNC_QUALIFIER vec bitfieldReverse(vec const& v) { - vecType x(v); - x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 2>::call(x, static_cast(0x5555555555555555ull), static_cast( 1)); - x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 4>::call(x, static_cast(0x3333333333333333ull), static_cast( 2)); - x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 8>::call(x, static_cast(0x0F0F0F0F0F0F0F0Full), static_cast( 4)); - x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 16>::call(x, static_cast(0x00FF00FF00FF00FFull), static_cast( 8)); - x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 32>::call(x, static_cast(0x0000FFFF0000FFFFull), static_cast(16)); - x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 64>::call(x, static_cast(0x00000000FFFFFFFFull), static_cast(32)); + vec x(v); + x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 2>::call(x, static_cast(0x5555555555555555ull), static_cast( 1)); + x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 4>::call(x, static_cast(0x3333333333333333ull), static_cast( 2)); + x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 8>::call(x, static_cast(0x0F0F0F0F0F0F0F0Full), static_cast( 4)); + x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 16>::call(x, static_cast(0x00FF00FF00FF00FFull), static_cast( 8)); + x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 32>::call(x, static_cast(0x0000FFFF0000FFFFull), static_cast(16)); + x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 64>::call(x, static_cast(0x00000000FFFFFFFFull), static_cast(32)); return x; } @@ -314,24 +314,26 @@ namespace detail return bitCount(glm::vec<1, genType, glm::defaultp>(x)).x; } - template class vecType> - GLM_FUNC_QUALIFIER vecType bitCount(vecType const& v) + template + GLM_FUNC_QUALIFIER vec bitCount(vec const& v) { - #if GLM_COMPILER & GLM_COMPILER_VC - #pragma warning(push) - #pragma warning(disable : 4310) //cast truncates constant value - #endif - vecType::type, P> x(*reinterpret_cast::type, P> const *>(&v)); - x = detail::compute_bitfieldBitCountStep::type, P, vecType, detail::is_aligned

::value, sizeof(T) * 8>= 2>::call(x, typename detail::make_unsigned::type(0x5555555555555555ull), typename detail::make_unsigned::type( 1)); - x = detail::compute_bitfieldBitCountStep::type, P, vecType, detail::is_aligned

::value, sizeof(T) * 8>= 4>::call(x, typename detail::make_unsigned::type(0x3333333333333333ull), typename detail::make_unsigned::type( 2)); - x = detail::compute_bitfieldBitCountStep::type, P, vecType, detail::is_aligned

::value, sizeof(T) * 8>= 8>::call(x, typename detail::make_unsigned::type(0x0F0F0F0F0F0F0F0Full), typename detail::make_unsigned::type( 4)); - x = detail::compute_bitfieldBitCountStep::type, P, vecType, detail::is_aligned

::value, sizeof(T) * 8>= 16>::call(x, typename detail::make_unsigned::type(0x00FF00FF00FF00FFull), typename detail::make_unsigned::type( 8)); - x = detail::compute_bitfieldBitCountStep::type, P, vecType, detail::is_aligned

::value, sizeof(T) * 8>= 32>::call(x, typename detail::make_unsigned::type(0x0000FFFF0000FFFFull), typename detail::make_unsigned::type(16)); - x = detail::compute_bitfieldBitCountStep::type, P, vecType, detail::is_aligned

::value, sizeof(T) * 8>= 64>::call(x, typename detail::make_unsigned::type(0x00000000FFFFFFFFull), typename detail::make_unsigned::type(32)); - return vecType(x); - #if GLM_COMPILER & GLM_COMPILER_VC - #pragma warning(pop) - #endif +# if GLM_COMPILER & GLM_COMPILER_VC +# pragma warning(push) +# pragma warning(disable : 4310) //cast truncates constant value +# endif + + vec::type, P> x(*reinterpret_cast::type, P> const *>(&v)); + x = detail::compute_bitfieldBitCountStep::type, P, detail::is_aligned

::value, sizeof(T) * 8>= 2>::call(x, typename detail::make_unsigned::type(0x5555555555555555ull), typename detail::make_unsigned::type( 1)); + x = detail::compute_bitfieldBitCountStep::type, P, detail::is_aligned

::value, sizeof(T) * 8>= 4>::call(x, typename detail::make_unsigned::type(0x3333333333333333ull), typename detail::make_unsigned::type( 2)); + x = detail::compute_bitfieldBitCountStep::type, P, detail::is_aligned

::value, sizeof(T) * 8>= 8>::call(x, typename detail::make_unsigned::type(0x0F0F0F0F0F0F0F0Full), typename detail::make_unsigned::type( 4)); + x = detail::compute_bitfieldBitCountStep::type, P, detail::is_aligned

::value, sizeof(T) * 8>= 16>::call(x, typename detail::make_unsigned::type(0x00FF00FF00FF00FFull), typename detail::make_unsigned::type( 8)); + x = detail::compute_bitfieldBitCountStep::type, P, detail::is_aligned

::value, sizeof(T) * 8>= 32>::call(x, typename detail::make_unsigned::type(0x0000FFFF0000FFFFull), typename detail::make_unsigned::type(16)); + x = detail::compute_bitfieldBitCountStep::type, P, detail::is_aligned

::value, sizeof(T) * 8>= 64>::call(x, typename detail::make_unsigned::type(0x00000000FFFFFFFFull), typename detail::make_unsigned::type(32)); + return vec(x); + +# if GLM_COMPILER & GLM_COMPILER_VC +# pragma warning(pop) +# endif } // findLSB @@ -343,8 +345,8 @@ namespace detail return detail::compute_findLSB::call(Value); } - template class vecType> - GLM_FUNC_QUALIFIER vecType findLSB(vecType const& x) + template + GLM_FUNC_QUALIFIER vec findLSB(vec const& x) { GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findLSB' only accept integer values"); @@ -360,12 +362,12 @@ namespace detail return findMSB(vec<1, genIUType>(v)).x; } - template class vecType> - GLM_FUNC_QUALIFIER vecType findMSB(vecType const& v) + template + GLM_FUNC_QUALIFIER vec findMSB(vec const& v) { GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findMSB' only accept integer values"); - return detail::compute_findMSB_vec::call(v); + return detail::compute_findMSB_vec::call(v); } }//namespace glm diff --git a/glm/detail/func_integer_simd.inl b/glm/detail/func_integer_simd.inl index 095adfb9..addff798 100644 --- a/glm/detail/func_integer_simd.inl +++ b/glm/detail/func_integer_simd.inl @@ -9,7 +9,7 @@ namespace glm{ namespace detail { template - struct compute_bitfieldReverseStep<4, uint32, P, vec, true, true> + struct compute_bitfieldReverseStep<4, uint32, P, true, true> { GLM_FUNC_QUALIFIER static vec<4, uint32, P> call(vec<4, uint32, P> const& v, uint32 Mask, uint32 Shift) { @@ -30,7 +30,7 @@ namespace detail }; template - struct compute_bitfieldBitCountStep<4, uint32, P, vec, true, true> + struct compute_bitfieldBitCountStep<4, uint32, P, true, true> { GLM_FUNC_QUALIFIER static vec<4, uint32, P> call(vec<4, uint32, P> const& v, uint32 Mask, uint32 Shift) { diff --git a/glm/detail/func_matrix.hpp b/glm/detail/func_matrix.hpp index 6909613a..faae29f7 100644 --- a/glm/detail/func_matrix.hpp +++ b/glm/detail/func_matrix.hpp @@ -35,55 +35,55 @@ namespace glm{ namespace detail { template - struct outerProduct_trait<2, 2, T, P, vec, vec> + struct outerProduct_trait<2, 2, T, P> { typedef mat<2, 2, T, P> type; }; template - struct outerProduct_trait<2, 3, T, P, vec, vec> + struct outerProduct_trait<2, 3, T, P> { typedef mat<3, 2, T, P> type; }; template - struct outerProduct_trait<2, 4, T, P, vec, vec> + struct outerProduct_trait<2, 4, T, P> { typedef mat<4, 2, T, P> type; }; template - struct outerProduct_trait<3, 2, T, P, vec, vec> + struct outerProduct_trait<3, 2, T, P> { typedef mat<2, 3, T, P> type; }; template - struct outerProduct_trait<3, 3, T, P, vec, vec> + struct outerProduct_trait<3, 3, T, P> { typedef mat<3, 3, T, P> type; }; template - struct outerProduct_trait<3, 4, T, P, vec, vec> + struct outerProduct_trait<3, 4, T, P> { typedef mat<4, 3, T, P> type; }; template - struct outerProduct_trait<4, 2, T, P, vec, vec> + struct outerProduct_trait<4, 2, T, P> { typedef mat<2, 4, T, P> type; }; template - struct outerProduct_trait<4, 3, T, P, vec, vec> + struct outerProduct_trait<4, 3, T, P> { typedef mat<3, 4, T, P> type; }; template - struct outerProduct_trait<4, 4, T, P, vec, vec> + struct outerProduct_trait<4, 4, T, P> { typedef mat<4, 4, T, P> type; }; @@ -107,12 +107,10 @@ namespace detail /// and the second parameter r as a row vector /// 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 - template class vecTypeA, template class vecTypeB> - GLM_FUNC_DECL typename detail::outerProduct_trait::type outerProduct(vecTypeA const & c, vecTypeB const & r); + template + GLM_FUNC_DECL typename detail::outerProduct_trait::type outerProduct(vec const & c, vec const & r); /// Returns the transposed matrix of x /// @@ -125,7 +123,7 @@ namespace detail /// Return the determinant of a squared matrix. /// - /// @tparam valType Floating-point scalar types. + /// @tparam T Floating-point scalar types. /// /// @see GLSL determinant man page /// @see GLSL 4.20.8 specification, section 8.6 Matrix Functions @@ -134,7 +132,7 @@ namespace detail /// Return the inverse of a squared matrix. /// - /// @tparam valType Floating-point scalar types. + /// @tparam T Floating-point scalar types. /// /// @see GLSL inverse man page /// @see GLSL 4.20.8 specification, section 8.6 Matrix Functions diff --git a/glm/detail/func_matrix.inl b/glm/detail/func_matrix.inl index 8f068bc2..bb93d02d 100644 --- a/glm/detail/func_matrix.inl +++ b/glm/detail/func_matrix.inl @@ -362,12 +362,12 @@ namespace detail return detail::compute_matrixCompMult::value>::call(x, y); } - template class vecTypeA, template class vecTypeB> - GLM_FUNC_QUALIFIER typename detail::outerProduct_trait::type outerProduct(vecTypeA const & c, vecTypeB const & r) + template + GLM_FUNC_QUALIFIER typename detail::outerProduct_trait::type outerProduct(vec const & c, vec const & r) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'outerProduct' only accept floating-point inputs"); - typename detail::outerProduct_trait::type m; + typename detail::outerProduct_trait::type m; for(length_t i = 0; i < m.length(); ++i) m[i] = c * r[i]; return m; diff --git a/glm/detail/func_matrix_simd.inl b/glm/detail/func_matrix_simd.inl index beadc87f..2e20b80a 100644 --- a/glm/detail/func_matrix_simd.inl +++ b/glm/detail/func_matrix_simd.inl @@ -6,6 +6,7 @@ #include "type_mat4x4.hpp" #include "func_geometric.hpp" #include "../simd/matrix.h" +#include namespace glm{ namespace detail @@ -61,26 +62,32 @@ namespace detail }//namespace detail template<> - GLM_FUNC_QUALIFIER mat<4, 4, float, aligned_lowp> outerProduct<4, 4, float, aligned_lowp, vec, vec>(vec<4, float, aligned_lowp> const & c, vec<4, float, aligned_lowp> const & r) + GLM_FUNC_QUALIFIER mat<4, 4, float, aligned_lowp> outerProduct<4, 4, float, aligned_lowp>(vec<4, float, aligned_lowp> const& c, vec<4, float, aligned_lowp> const& r) { + __m128 NativeResult[4]; + glm_mat4_outerProduct(c.data, r.data, NativeResult); mat<4, 4, float, aligned_lowp> Result; - glm_mat4_outerProduct(c.data, r.data, *reinterpret_cast<__m128(*)[4]>(&Result[0].data)); + std::memcpy(&Result[0], &NativeResult[0], sizeof(Result)); return Result; } template<> - GLM_FUNC_QUALIFIER mat<4, 4, float, aligned_mediump> outerProduct<4, 4, float, aligned_mediump, vec, vec>(vec<4, float, aligned_mediump> const & c, vec<4, float, aligned_mediump> const & r) + GLM_FUNC_QUALIFIER mat<4, 4, float, aligned_mediump> outerProduct<4, 4, float, aligned_mediump>(vec<4, float, aligned_mediump> const& c, vec<4, float, aligned_mediump> const& r) { + __m128 NativeResult[4]; + glm_mat4_outerProduct(c.data, r.data, NativeResult); mat<4, 4, float, aligned_mediump> Result; - glm_mat4_outerProduct(c.data, r.data, *reinterpret_cast<__m128(*)[4]>(&Result[0].data)); + std::memcpy(&Result[0], &NativeResult[0], sizeof(Result)); return Result; } template<> - GLM_FUNC_QUALIFIER mat<4, 4, float, aligned_highp> outerProduct<4, 4, float, aligned_highp, vec, vec>(vec<4, float, aligned_highp> const & c, vec<4, float, aligned_highp> const & r) + GLM_FUNC_QUALIFIER mat<4, 4, float, aligned_highp> outerProduct<4, 4, float, aligned_highp>(vec<4, float, aligned_highp> const& c, vec<4, float, aligned_highp> const& r) { + __m128 NativeResult[4]; + glm_mat4_outerProduct(c.data, r.data, NativeResult); mat<4, 4, float, aligned_highp> Result; - glm_mat4_outerProduct(c.data, r.data, *reinterpret_cast<__m128(*)[4]>(&Result[0].data)); + std::memcpy(&Result[0], &NativeResult[0], sizeof(Result)); return Result; } }//namespace glm diff --git a/glm/detail/func_trigonometric.hpp b/glm/detail/func_trigonometric.hpp index f17ba6d1..91d86f90 100644 --- a/glm/detail/func_trigonometric.hpp +++ b/glm/detail/func_trigonometric.hpp @@ -24,7 +24,7 @@ namespace glm /// Converts degrees to radians and returns the result. /// - /// @tparam genType Floating-point scalar or vector types. + /// @tparam vecType Floating-point scalar or vector types. /// /// @see GLSL radians man page /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions @@ -33,7 +33,7 @@ namespace glm /// Converts radians to degrees and returns the result. /// - /// @tparam genType Floating-point scalar or vector types. + /// @tparam vecType Floating-point scalar or vector types. /// /// @see GLSL degrees man page /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions @@ -43,7 +43,7 @@ namespace glm /// The standard trigonometric sine function. /// The values returned by this function will range from [-1, 1]. /// - /// @tparam genType Floating-point scalar or vector types. + /// @tparam vecType Floating-point scalar or vector types. /// /// @see GLSL sin man page /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions @@ -53,7 +53,7 @@ namespace glm /// The standard trigonometric cosine function. /// The values returned by this function will range from [-1, 1]. /// - /// @tparam genType Floating-point scalar or vector types. + /// @tparam vecType Floating-point scalar or vector types. /// /// @see GLSL cos man page /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions @@ -62,7 +62,7 @@ namespace glm /// The standard trigonometric tangent function. /// - /// @tparam genType Floating-point scalar or vector types. + /// @tparam vecType Floating-point scalar or vector types. /// /// @see GLSL tan man page /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions @@ -73,7 +73,7 @@ namespace glm /// 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. + /// @tparam vecType Floating-point scalar or vector types. /// /// @see GLSL asin man page /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions @@ -84,7 +84,7 @@ namespace glm /// 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. + /// @tparam vecType Floating-point scalar or vector types. /// /// @see GLSL acos man page /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions @@ -97,7 +97,7 @@ namespace glm /// by this function is [-PI, PI]. Results are undefined /// if x and y are both 0. /// - /// @tparam genType Floating-point scalar or vector types. + /// @tparam vecType Floating-point scalar or vector types. /// /// @see GLSL atan man page /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions @@ -107,7 +107,7 @@ namespace glm /// 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. + /// @tparam vecType Floating-point scalar or vector types. /// /// @see GLSL atan man page /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions @@ -116,7 +116,7 @@ namespace glm /// Returns the hyperbolic sine function, (exp(x) - exp(-x)) / 2 /// - /// @tparam genType Floating-point scalar or vector types. + /// @tparam vecType Floating-point scalar or vector types. /// /// @see GLSL sinh man page /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions @@ -125,7 +125,7 @@ namespace glm /// Returns the hyperbolic cosine function, (exp(x) + exp(-x)) / 2 /// - /// @tparam genType Floating-point scalar or vector types. + /// @tparam vecType Floating-point scalar or vector types. /// /// @see GLSL cosh man page /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions @@ -134,7 +134,7 @@ namespace glm /// Returns the hyperbolic tangent function, sinh(angle) / cosh(angle) /// - /// @tparam genType Floating-point scalar or vector types. + /// @tparam vecType Floating-point scalar or vector types. /// /// @see GLSL tanh man page /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions @@ -143,7 +143,7 @@ namespace glm /// Arc hyperbolic sine; returns the inverse of sinh. /// - /// @tparam genType Floating-point scalar or vector types. + /// @tparam vecType Floating-point scalar or vector types. /// /// @see GLSL asinh man page /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions @@ -153,7 +153,7 @@ namespace glm /// Arc hyperbolic cosine; returns the non-negative inverse /// of cosh. Results are undefined if x < 1. /// - /// @tparam genType Floating-point scalar or vector types. + /// @tparam vecType Floating-point scalar or vector types. /// /// @see GLSL acosh man page /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions @@ -163,7 +163,7 @@ namespace glm /// Arc hyperbolic tangent; returns the inverse of tanh. /// Results are undefined if abs(x) >= 1. /// - /// @tparam genType Floating-point scalar or vector types. + /// @tparam vecType Floating-point scalar or vector types. /// /// @see GLSL atanh man page /// @see GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions diff --git a/glm/detail/func_vector_relational.hpp b/glm/detail/func_vector_relational.hpp index f981bd7f..8afb6d23 100644 --- a/glm/detail/func_vector_relational.hpp +++ b/glm/detail/func_vector_relational.hpp @@ -25,85 +25,91 @@ namespace glm /// Returns the component-wise comparison result of x < y. /// - /// @tparam vecType Floating-point or integer vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T A floating-point or integer scalar type. /// /// @see GLSL lessThan man page /// @see GLSL 4.20.8 specification, section 8.7 Vector Relational Functions - template class vecType> - GLM_FUNC_DECL vecType lessThan(vecType const & x, vecType const & y); + template + GLM_FUNC_DECL vec lessThan(vec const& x, vec const& y); /// Returns the component-wise comparison of result x <= y. /// - /// @tparam vecType Floating-point or integer vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T A floating-point or integer scalar type. /// /// @see GLSL lessThanEqual man page /// @see GLSL 4.20.8 specification, section 8.7 Vector Relational Functions - template class vecType> - GLM_FUNC_DECL vecType lessThanEqual(vecType const & x, vecType const & y); + template + GLM_FUNC_DECL vec lessThanEqual(vec const& x, vec const& y); /// Returns the component-wise comparison of result x > y. /// - /// @tparam vecType Floating-point or integer vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T A floating-point or integer scalar type. /// /// @see GLSL greaterThan man page /// @see GLSL 4.20.8 specification, section 8.7 Vector Relational Functions - template class vecType> - GLM_FUNC_DECL vecType greaterThan(vecType const & x, vecType const & y); + template + GLM_FUNC_DECL vec greaterThan(vec const& x, vec const& y); /// Returns the component-wise comparison of result x >= y. /// - /// @tparam vecType Floating-point or integer vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T A floating-point or integer scalar type. /// /// @see GLSL greaterThanEqual man page /// @see GLSL 4.20.8 specification, section 8.7 Vector Relational Functions - template class vecType> - GLM_FUNC_DECL vecType greaterThanEqual(vecType const & x, vecType const & y); + template + GLM_FUNC_DECL vec greaterThanEqual(vec const& x, vec const& y); /// Returns the component-wise comparison of result x == y. /// - /// @tparam vecType Floating-point, integer or boolean vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T A floating-point, integer or bool scalar type. /// /// @see GLSL equal man page /// @see GLSL 4.20.8 specification, section 8.7 Vector Relational Functions - template class vecType> - GLM_FUNC_DECL vecType equal(vecType const & x, vecType const & y); + template + GLM_FUNC_DECL vec equal(vec const& x, vec const& y); /// Returns the component-wise comparison of result x != y. /// - /// @tparam vecType Floating-point, integer or boolean vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. + /// @tparam T A floating-point, integer or bool scalar type. /// /// @see GLSL notEqual man page /// @see GLSL 4.20.8 specification, section 8.7 Vector Relational Functions - template class vecType> - GLM_FUNC_DECL vecType notEqual(vecType const & x, vecType const & y); + template + GLM_FUNC_DECL vec notEqual(vec const& x, vec const& y); /// Returns true if any component of x is true. /// - /// @tparam vecType Boolean vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. /// /// @see GLSL any man page /// @see GLSL 4.20.8 specification, section 8.7 Vector Relational Functions - template class vecType> - GLM_FUNC_DECL bool any(vecType const & v); + template + GLM_FUNC_DECL bool any(vec const& v); /// Returns true if all components of x are true. /// - /// @tparam vecType Boolean vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. /// /// @see GLSL all man page /// @see GLSL 4.20.8 specification, section 8.7 Vector Relational Functions - template class vecType> - GLM_FUNC_DECL bool all(vecType const & v); + template + GLM_FUNC_DECL bool all(vec const& v); /// Returns the component-wise logical complement of x. /// /!\ Because of language incompatibilities between C++ and GLSL, GLM defines the function not but not_ instead. /// - /// @tparam vecType Boolean vector types. + /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector. /// /// @see GLSL not man page /// @see GLSL 4.20.8 specification, section 8.7 Vector Relational Functions - template class vecType> - GLM_FUNC_DECL vecType not_(vecType const & v); + template + GLM_FUNC_DECL vec not_(vec const& v); /// @} }//namespace glm diff --git a/glm/detail/func_vector_relational.inl b/glm/detail/func_vector_relational.inl index 0dbf2af8..d3a30590 100644 --- a/glm/detail/func_vector_relational.inl +++ b/glm/detail/func_vector_relational.inl @@ -1,79 +1,79 @@ /// @ref core /// @file glm/detail/func_vector_relational.inl -#include +#include "compute_vector_relational.hpp" namespace glm { - template class vecType> - GLM_FUNC_QUALIFIER vecType lessThan(vecType const & x, vecType const & y) + template + GLM_FUNC_QUALIFIER vec lessThan(vec const& x, vec const& y) { assert(x.length() == y.length()); - vecType Result; + vec Result; for(length_t i = 0; i < x.length(); ++i) Result[i] = x[i] < y[i]; return Result; } - template class vecType> - GLM_FUNC_QUALIFIER vecType lessThanEqual(vecType const & x, vecType const & y) + template + GLM_FUNC_QUALIFIER vec lessThanEqual(vec const& x, vec const& y) { assert(x.length() == y.length()); - vecType Result; + vec Result; for(length_t i = 0; i < x.length(); ++i) Result[i] = x[i] <= y[i]; return Result; } - template class vecType> - GLM_FUNC_QUALIFIER vecType greaterThan(vecType const & x, vecType const & y) + template + GLM_FUNC_QUALIFIER vec greaterThan(vec const& x, vec const& y) { assert(x.length() == y.length()); - vecType Result; + vec Result; for(length_t i = 0; i < x.length(); ++i) Result[i] = x[i] > y[i]; return Result; } - template class vecType> - GLM_FUNC_QUALIFIER vecType greaterThanEqual(vecType const & x, vecType const & y) + template + GLM_FUNC_QUALIFIER vec greaterThanEqual(vec const& x, vec const& y) { assert(x.length() == y.length()); - vecType Result; + vec Result; for(length_t i = 0; i < x.length(); ++i) Result[i] = x[i] >= y[i]; return Result; } - template class vecType> - GLM_FUNC_QUALIFIER vecType equal(vecType const & x, vecType const & y) + template + GLM_FUNC_QUALIFIER vec equal(vec const& x, vec const& y) { assert(x.length() == y.length()); - vecType Result; + vec Result; for(length_t i = 0; i < x.length(); ++i) - Result[i] = x[i] == y[i]; + Result[i] = detail::compute_equal::call(x[i], y[i]); return Result; } - template class vecType> - GLM_FUNC_QUALIFIER vecType notEqual(vecType const & x, vecType const & y) + template + GLM_FUNC_QUALIFIER vec notEqual(vec const& x, vec const& y) { assert(x.length() == y.length()); - vecType Result; + vec Result; for(length_t i = 0; i < x.length(); ++i) - Result[i] = x[i] != y[i]; + Result[i] = !detail::compute_equal::call(x[i], y[i]); return Result; } - template class vecType> - GLM_FUNC_QUALIFIER bool any(vecType const & v) + template + GLM_FUNC_QUALIFIER bool any(vec const& v) { bool Result = false; for(length_t i = 0; i < v.length(); ++i) @@ -81,8 +81,8 @@ namespace glm return Result; } - template class vecType> - GLM_FUNC_QUALIFIER bool all(vecType const & v) + template + GLM_FUNC_QUALIFIER bool all(vec const& v) { bool Result = true; for(length_t i = 0; i < v.length(); ++i) @@ -90,10 +90,10 @@ namespace glm return Result; } - template class vecType> - GLM_FUNC_QUALIFIER vecType not_(vecType const & v) + template + GLM_FUNC_QUALIFIER vec not_(vec const& v) { - vecType Result; + vec Result; for(length_t i = 0; i < v.length(); ++i) Result[i] = !v[i]; return Result; diff --git a/glm/detail/type_mat.hpp b/glm/detail/type_mat.hpp index 3c418dae..8cb2afbb 100644 --- a/glm/detail/type_mat.hpp +++ b/glm/detail/type_mat.hpp @@ -8,7 +8,7 @@ namespace glm{ namespace detail { - template class colType, template class rowType> + template struct outerProduct_trait{}; }//namespace detail diff --git a/glm/detail/type_vec.hpp b/glm/detail/type_vec.hpp index 4fe69c18..2e90cd55 100644 --- a/glm/detail/type_vec.hpp +++ b/glm/detail/type_vec.hpp @@ -5,6 +5,7 @@ #include "precision.hpp" #include "type_int.hpp" +#include "compute_vector_relational.hpp" namespace glm{ namespace detail diff --git a/glm/detail/type_vec1.inl b/glm/detail/type_vec1.inl index 10ef44f4..0e701c97 100644 --- a/glm/detail/type_vec1.inl +++ b/glm/detail/type_vec1.inl @@ -528,13 +528,13 @@ namespace glm template GLM_FUNC_QUALIFIER bool operator==(vec<1, T, P> const & v1, vec<1, T, P> const & v2) { - return (v1.x == v2.x); + return detail::compute_equal::call(v1.x, v2.x); } template GLM_FUNC_QUALIFIER bool operator!=(vec<1, T, P> const & v1, vec<1, T, P> const & v2) { - return (v1.x != v2.x); + return !(v1 == v2); } template diff --git a/glm/detail/type_vec2.inl b/glm/detail/type_vec2.inl index 24afe5c2..7b950042 100644 --- a/glm/detail/type_vec2.inl +++ b/glm/detail/type_vec2.inl @@ -851,13 +851,15 @@ namespace glm template GLM_FUNC_QUALIFIER bool operator==(vec<2, T, P> const & v1, vec<2, T, P> const & v2) { - return (v1.x == v2.x) && (v1.y == v2.y); + return + detail::compute_equal::call(v1.x, v2.x) && + detail::compute_equal::call(v1.y, v2.y); } template GLM_FUNC_QUALIFIER bool operator!=(vec<2, T, P> const & v1, vec<2, T, P> const & v2) { - return (v1.x != v2.x) || (v1.y != v2.y); + return !(v1 == v2); } template diff --git a/glm/detail/type_vec3.inl b/glm/detail/type_vec3.inl index 830fe91d..06879644 100644 --- a/glm/detail/type_vec3.inl +++ b/glm/detail/type_vec3.inl @@ -966,13 +966,16 @@ namespace glm template GLM_FUNC_QUALIFIER bool operator==(vec<3, T, P> const & v1, vec<3, T, P> const & v2) { - return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z); + return + detail::compute_equal::call(v1.x, v2.x) && + detail::compute_equal::call(v1.y, v2.y) && + detail::compute_equal::call(v1.z, v2.z); } template GLM_FUNC_QUALIFIER bool operator!=(vec<3, T, P> const & v1, vec<3, T, P> const & v2) { - return (v1.x != v2.x) || (v1.y != v2.y) || (v1.z != v2.z); + return !(v1 == v2); } template diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index 8ff34cfe..fd214545 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -129,7 +129,11 @@ namespace detail { GLM_FUNC_QUALIFIER static bool call(vec<4, T, P> const & v1, vec<4, T, P> const & v2) { - return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z) && (v1.w == v2.w); + return + detail::compute_equal::call(v1.x, v2.x) && + detail::compute_equal::call(v1.y, v2.y) && + detail::compute_equal::call(v1.z, v2.z) && + detail::compute_equal::call(v1.w, v2.w); } }; @@ -138,7 +142,7 @@ namespace detail { GLM_FUNC_QUALIFIER static bool call(vec<4, T, P> const & v1, vec<4, T, P> const & v2) { - return (v1.x != v2.x) || (v1.y != v2.y) || (v1.z != v2.z) || (v1.w != v2.w); + return !compute_vec4_equal::value, sizeof(T) * 8, detail::is_aligned

::value>::call(v1, v2); } }; diff --git a/glm/gtc/bitfield.inl b/glm/gtc/bitfield.inl index 4331eec5..6be01e7e 100644 --- a/glm/gtc/bitfield.inl +++ b/glm/gtc/bitfield.inl @@ -30,7 +30,7 @@ namespace detail REG1 = ((REG1 << 1) | REG1) & glm::uint16(0x5555); REG2 = ((REG2 << 1) | REG2) & glm::uint16(0x5555); - return REG1 | (REG2 << 1); + return REG1 | static_cast(REG2 << 1); } template<> diff --git a/glm/gtc/integer.hpp b/glm/gtc/integer.hpp index 894500c5..d4810b52 100644 --- a/glm/gtc/integer.hpp +++ b/glm/gtc/integer.hpp @@ -50,25 +50,23 @@ namespace glm /// for each component in x using the floating point value y. /// /// @tparam T Integer scalar types. - /// @tparam vecType vector types. /// /// @see gtc_integer /// @see GLSL mod man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template class vecType> - GLM_FUNC_DECL vecType mod(vecType const & x, T y); + template + GLM_FUNC_DECL vec mod(vec const& x, T y); /// Modulus. Returns x % y /// for each component in x using the floating point value y. /// /// @tparam T Integer scalar types. - /// @tparam vecType vector types. /// /// @see gtc_integer /// @see GLSL mod man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template class vecType> - GLM_FUNC_DECL vecType mod(vecType const & x, vecType const & y); + template + GLM_FUNC_DECL vec mod(vec const& x, vec const& y); /// Returns a value equal to the nearest integer to x. /// The fraction 0.5 will round in a direction chosen by the @@ -76,12 +74,11 @@ namespace glm /// /// @param x The values of the argument must be greater or equal to zero. /// @tparam T floating point scalar types. - /// @tparam vecType vector types. /// /// @see GLSL round man page /// @see gtc_integer - template class vecType> - GLM_FUNC_DECL vecType iround(vecType const & x); + template + GLM_FUNC_DECL vec iround(vec const& x); /// Returns a value equal to the nearest integer to x. /// The fraction 0.5 will round in a direction chosen by the @@ -89,12 +86,11 @@ namespace glm /// /// @param x The values of the argument must be greater or equal to zero. /// @tparam T floating point scalar types. - /// @tparam vecType vector types. /// /// @see GLSL round man page /// @see gtc_integer - template class vecType> - GLM_FUNC_DECL vecType uround(vecType const & x); + template + GLM_FUNC_DECL vec uround(vec const& x); /// @} } //namespace glm diff --git a/glm/gtc/integer.inl b/glm/gtc/integer.inl index 0bedc467..8b44e171 100644 --- a/glm/gtc/integer.inl +++ b/glm/gtc/integer.inl @@ -4,20 +4,20 @@ namespace glm{ namespace detail { - template class vecType, bool Aligned> - struct compute_log2 + template + struct compute_log2 { - GLM_FUNC_QUALIFIER static vecType call(vecType const& v) + GLM_FUNC_QUALIFIER static vec call(vec const& v) { //Equivalent to return findMSB(vec); but save one function call in ASM with VC //return findMSB(vec); - return vecType(detail::compute_findMSB_vec::call(v)); + return vec(detail::compute_findMSB_vec::call(v)); } }; # if GLM_HAS_BITSCAN_WINDOWS template - struct compute_log2<4, int, P, vec, false, Aligned> + struct compute_log2<4, int, P, false, Aligned> { GLM_FUNC_QUALIFIER static vec<4, int, P> call(vec<4, int, P> const& v) { @@ -40,13 +40,13 @@ namespace detail return static_cast(x + static_cast(0.5)); } - template class vecType> - GLM_FUNC_QUALIFIER vecType iround(vecType const& x) + template + GLM_FUNC_QUALIFIER vec iround(vec const& x) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'iround' only accept floating-point inputs"); - assert(all(lessThanEqual(vecType(0), x))); + assert(all(lessThanEqual(vec(0), x))); - return vecType(x + static_cast(0.5)); + return vec(x + static_cast(0.5)); } template @@ -58,12 +58,12 @@ namespace detail return static_cast(x + static_cast(0.5)); } - template class vecType> - GLM_FUNC_QUALIFIER vecType uround(vecType const& x) + template + GLM_FUNC_QUALIFIER vec uround(vec const& x) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'uround' only accept floating-point inputs"); - assert(all(lessThanEqual(vecType(0), x))); + assert(all(lessThanEqual(vec(0), x))); - return vecType(x + static_cast(0.5)); + return vec(x + static_cast(0.5)); } }//namespace glm diff --git a/glm/gtc/packing.inl b/glm/gtc/packing.inl index 40387e30..1a4e649a 100644 --- a/glm/gtc/packing.inl +++ b/glm/gtc/packing.inl @@ -2,6 +2,7 @@ /// @file glm/gtc/packing.inl #include "../common.hpp" +#include "../vector_relational.hpp" #include "../vec2.hpp" #include "../vec3.hpp" #include "../vec4.hpp" @@ -619,7 +620,7 @@ namespace detail float const ExpSharedP = max(-15.f - 1.f, floor(log2(MaxColor))) + 1.0f + 15.f; float const MaxShared = floor(MaxColor / pow(2.0f, (ExpSharedP - 15.f - 9.f)) + 0.5f); - float const ExpShared = MaxShared == pow(2.0f, 9.0f) ? ExpSharedP + 1.0f : ExpSharedP; + float const ExpShared = detail::compute_equal::call(MaxShared, pow(2.0f, 9.0f)) ? ExpSharedP + 1.0f : ExpSharedP; uvec3 const ColorComp(floor(Color / pow(2.f, (ExpShared - 15.f - 9.f)) + 0.5f)); diff --git a/glm/gtc/quaternion.hpp b/glm/gtc/quaternion.hpp index 3f1041e1..30e4275e 100644 --- a/glm/gtc/quaternion.hpp +++ b/glm/gtc/quaternion.hpp @@ -176,18 +176,24 @@ namespace glm /// Returns the length of the quaternion. /// + /// @tparam T Floating-point scalar types. + /// /// @see gtc_quaternion template GLM_FUNC_DECL T length(tquat const & q); /// Returns the normalized quaternion. /// + /// @tparam T Floating-point scalar types. + /// /// @see gtc_quaternion template GLM_FUNC_DECL tquat normalize(tquat const & q); /// Returns dot product of q1 and q2, i.e., q1[0] * q2[0] + q1[1] * q2[1] + ... /// + /// @tparam T Floating-point scalar types. + /// /// @see gtc_quaternion template GLM_FUNC_DECL T dot(tquat const & x, tquat const & y); @@ -199,9 +205,10 @@ namespace glm /// @param x A quaternion /// @param y A quaternion /// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1]. - /// @tparam T Value type used to build the quaternion. Supported: half, float or double. - /// @see gtc_quaternion + /// @tparam T Floating-point scalar types. + /// /// @see - slerp(tquat const & x, tquat const & y, T const & a) + /// @see gtc_quaternion template GLM_FUNC_DECL tquat mix(tquat const & x, tquat const & y, T a); @@ -211,7 +218,8 @@ namespace glm /// @param x A quaternion /// @param y A quaternion /// @param a Interpolation factor. The interpolation is defined in the range [0, 1]. - /// @tparam T Value type used to build the quaternion. Supported: half, float or double. + /// @tparam T Floating-point scalar types. + /// /// @see gtc_quaternion template GLM_FUNC_DECL tquat lerp(tquat const & x, tquat const & y, T a); @@ -222,19 +230,24 @@ namespace glm /// @param x A quaternion /// @param y A quaternion /// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1]. - /// @tparam T Value type used to build the quaternion. Supported: half, float or double. + /// @tparam T Floating-point scalar types. + /// /// @see gtc_quaternion template GLM_FUNC_DECL tquat slerp(tquat const & x, tquat const & y, T a); /// Returns the q conjugate. /// + /// @tparam T Floating-point scalar types. + /// /// @see gtc_quaternion template GLM_FUNC_DECL tquat conjugate(tquat const & q); /// Returns the q inverse. /// + /// @tparam T Floating-point scalar types. + /// /// @see gtc_quaternion template GLM_FUNC_DECL tquat inverse(tquat const & q); @@ -244,128 +257,150 @@ namespace glm /// @param q Source orientation /// @param angle Angle expressed in radians. /// @param axis Axis of the rotation - /// + /// @tparam T Floating-point scalar types. + /// /// @see gtc_quaternion template GLM_FUNC_DECL tquat rotate(tquat const & q, T const & angle, vec<3, T, P> const & axis); /// Returns euler angles, pitch as x, yaw as y, roll as z. /// The result is expressed in radians. - /// + /// + /// @tparam T Floating-point scalar types. + /// /// @see gtc_quaternion template GLM_FUNC_DECL vec<3, T, P> eulerAngles(tquat const & x); /// Returns roll value of euler angles expressed in radians. /// - /// @see gtx_quaternion + /// @tparam T Floating-point scalar types. + /// + /// @see gtc_quaternion template - GLM_FUNC_DECL T roll(tquat const & x); + GLM_FUNC_DECL T roll(tquat const& x); /// Returns pitch value of euler angles expressed in radians. /// - /// @see gtx_quaternion + /// @tparam T Floating-point scalar types. + /// + /// @see gtc_quaternion template - GLM_FUNC_DECL T pitch(tquat const & x); + GLM_FUNC_DECL T pitch(tquat const& x); /// Returns yaw value of euler angles expressed in radians. /// - /// @see gtx_quaternion + /// @tparam T Floating-point scalar types. + /// + /// @see gtc_quaternion template - GLM_FUNC_DECL T yaw(tquat const & x); + GLM_FUNC_DECL T yaw(tquat const& x); /// Converts a quaternion to a 3 * 3 matrix. /// + /// @tparam T Floating-point scalar types. + /// /// @see gtc_quaternion template - GLM_FUNC_DECL mat<3, 3, T, P> mat3_cast(tquat const & x); + GLM_FUNC_DECL mat<3, 3, T, P> mat3_cast(tquat const& x); /// Converts a quaternion to a 4 * 4 matrix. /// + /// @tparam T Floating-point scalar types. + /// /// @see gtc_quaternion template - GLM_FUNC_DECL mat<4, 4, T, P> mat4_cast(tquat const & x); + GLM_FUNC_DECL mat<4, 4, T, P> mat4_cast(tquat const& x); /// Converts a 3 * 3 matrix to a quaternion. /// + /// @tparam T Floating-point scalar types. + /// /// @see gtc_quaternion template - GLM_FUNC_DECL tquat quat_cast(mat<3, 3, T, P> const & x); + GLM_FUNC_DECL tquat quat_cast(mat<3, 3, T, P> const& x); /// Converts a 4 * 4 matrix to a quaternion. /// + /// @tparam T Floating-point scalar types. + /// /// @see gtc_quaternion template - GLM_FUNC_DECL tquat quat_cast(mat<4, 4, T, P> const & x); + GLM_FUNC_DECL tquat quat_cast(mat<4, 4, T, P> const& x); /// Returns the quaternion rotation angle. /// - /// @see gtc_quaternion - template - GLM_FUNC_DECL T angle(tquat const & x); - - /// Returns the q rotation axis. + /// @tparam T Floating-point scalar types. /// /// @see gtc_quaternion template - GLM_FUNC_DECL vec<3, T, P> axis(tquat const & x); + GLM_FUNC_DECL T angle(tquat const& x); + + /// Returns the q rotation axis. + /// + /// @tparam T Floating-point scalar types. + /// + /// @see gtc_quaternion + template + GLM_FUNC_DECL vec<3, T, P> axis(tquat const& x); /// Build a quaternion from an angle and a normalized axis. /// /// @param angle Angle expressed in radians. /// @param axis Axis of the quaternion, must be normalized. + /// @tparam T Floating-point scalar types. /// /// @see gtc_quaternion template - GLM_FUNC_DECL tquat angleAxis(T const & angle, vec<3, T, P> const & axis); + GLM_FUNC_DECL tquat angleAxis(T const& angle, vec<3, T, P> const& axis); /// Returns the component-wise comparison result of x < y. /// - /// @tparam quatType Floating-point quaternion types. + /// @tparam T Floating-point scalar types. /// /// @see gtc_quaternion template - GLM_FUNC_DECL vec<4, bool, P> lessThan(tquat const & x, tquat const & y); + GLM_FUNC_DECL vec<4, bool, P> lessThan(tquat const& x, tquat const& y); /// Returns the component-wise comparison of result x <= y. /// - /// @tparam quatType Floating-point quaternion types. + /// @tparam T Floating-point scalar types. /// /// @see gtc_quaternion template - GLM_FUNC_DECL vec<4, bool, P> lessThanEqual(tquat const & x, tquat const & y); + GLM_FUNC_DECL vec<4, bool, P> lessThanEqual(tquat const& x, tquat const& y); /// Returns the component-wise comparison of result x > y. /// - /// @tparam quatType Floating-point quaternion types. + /// @tparam T Floating-point scalar types. /// /// @see gtc_quaternion template - GLM_FUNC_DECL vec<4, bool, P> greaterThan(tquat const & x, tquat const & y); + GLM_FUNC_DECL vec<4, bool, P> greaterThan(tquat const& x, tquat const& y); /// Returns the component-wise comparison of result x >= y. /// - /// @tparam quatType Floating-point quaternion types. + /// @tparam T Floating-point scalar types. /// /// @see gtc_quaternion template - GLM_FUNC_DECL vec<4, bool, P> greaterThanEqual(tquat const & x, tquat const & y); + GLM_FUNC_DECL vec<4, bool, P> greaterThanEqual(tquat const& x, tquat const& y); /// Returns the component-wise comparison of result x == y. /// - /// @tparam quatType Floating-point quaternion types. + /// @tparam T Floating-point scalar types. /// /// @see gtc_quaternion template - GLM_FUNC_DECL vec<4, bool, P> equal(tquat const & x, tquat const & y); + GLM_FUNC_DECL vec<4, bool, P> equal(tquat const& x, tquat const& y); /// Returns the component-wise comparison of result x != y. /// - /// @tparam quatType Floating-point quaternion types. + /// @tparam T Floating-point scalar types. /// /// @see gtc_quaternion template - GLM_FUNC_DECL vec<4, bool, P> notEqual(tquat const & x, tquat const & y); + GLM_FUNC_DECL vec<4, bool, P> notEqual(tquat const& x, tquat const& y); /// Returns true if x holds a NaN (not a number) /// representation in the underlying implementation's set of @@ -375,9 +410,11 @@ namespace glm /// /// /!\ When using compiler fast math, this function may fail. /// - /// @tparam genType Floating-point scalar or vector types. + /// @tparam T Floating-point scalar types. + /// + /// @see gtc_quaternion template - GLM_FUNC_DECL vec<4, bool, P> isnan(tquat const & x); + GLM_FUNC_DECL vec<4, bool, P> isnan(tquat const& x); /// Returns true if x holds a positive infinity or negative /// infinity representation in the underlying implementation's @@ -385,9 +422,11 @@ namespace glm /// otherwise, including for implementations with no infinity /// representations. /// - /// @tparam genType Floating-point scalar or vector types. + /// @tparam T Floating-point scalar types. + /// + /// @see gtc_quaternion template - GLM_FUNC_DECL vec<4, bool, P> isinf(tquat const & x); + GLM_FUNC_DECL vec<4, bool, P> isinf(tquat const& x); /// @} } //namespace glm diff --git a/glm/gtc/quaternion.inl b/glm/gtc/quaternion.inl index e0e4bd41..465cecc4 100644 --- a/glm/gtc/quaternion.inl +++ b/glm/gtc/quaternion.inl @@ -4,6 +4,7 @@ #include "../trigonometric.hpp" #include "../geometric.hpp" #include "../exponential.hpp" +#include "../detail/compute_vector_relational.hpp" #include namespace glm{ @@ -754,20 +755,20 @@ namespace detail } template - GLM_FUNC_QUALIFIER vec<4, bool, P> equal(tquat const & x, tquat const & y) + GLM_FUNC_QUALIFIER vec<4, bool, P> equal(tquat const& x, tquat const& y) { vec<4, bool, P> Result; for(length_t i = 0; i < x.length(); ++i) - Result[i] = x[i] == y[i]; + Result[i] = detail::compute_equal::call(x[i], y[i]); return Result; } template - GLM_FUNC_QUALIFIER vec<4, bool, P> notEqual(tquat const & x, tquat const & y) + GLM_FUNC_QUALIFIER vec<4, bool, P> notEqual(tquat const& x, tquat const& y) { vec<4, bool, P> Result; for(length_t i = 0; i < x.length(); ++i) - Result[i] = x[i] != y[i]; + Result[i] = !detail::compute_equal::call(x[i], y[i]); return Result; } diff --git a/glm/gtc/random.hpp b/glm/gtc/random.hpp index 549cc50e..4080f430 100644 --- a/glm/gtc/random.hpp +++ b/glm/gtc/random.hpp @@ -28,69 +28,53 @@ namespace glm /// Generate random numbers in the interval [Min, Max], according a linear distribution /// - /// @param Min - /// @param Max + /// @param Min Minimum value included in the sampling + /// @param Max Maximum value included in the sampling /// @tparam genType Value type. Currently supported: float or double scalars. /// @see gtc_random template - GLM_FUNC_DECL genType linearRand( - genType Min, - genType Max); + GLM_FUNC_DECL genType linearRand(genType Min, genType Max); /// Generate random numbers in the interval [Min, Max], according a linear distribution /// - /// @param Min - /// @param Max + /// @param Min Minimum value included in the sampling + /// @param Max Maximum value included in the sampling /// @tparam T Value type. Currently supported: float or double. /// @tparam vecType A vertor type: tvec1, tvec2, tvec3, tvec4 or compatible /// @see gtc_random - template class vecType> - GLM_FUNC_DECL vecType linearRand( - vecType const& Min, - vecType const& Max); + template + GLM_FUNC_DECL vec linearRand(vec const& Min, vec const& Max); /// Generate random numbers in the interval [Min, Max], according a gaussian distribution /// - /// @param Mean - /// @param Deviation /// @see gtc_random template - GLM_FUNC_DECL genType gaussRand( - genType Mean, - genType Deviation); - + GLM_FUNC_DECL genType gaussRand(genType Mean, genType Deviation); + /// Generate a random 2D vector which coordinates are regulary distributed on a circle of a given radius /// - /// @param Radius /// @see gtc_random template - GLM_FUNC_DECL vec<2, T, defaultp> circularRand( - T Radius); - + GLM_FUNC_DECL vec<2, T, defaultp> circularRand(T Radius); + /// Generate a random 3D vector which coordinates are regulary distributed on a sphere of a given radius /// - /// @param Radius /// @see gtc_random template - GLM_FUNC_DECL vec<3, T, defaultp> sphericalRand( - T Radius); - + GLM_FUNC_DECL vec<3, T, defaultp> sphericalRand(T Radius); + /// Generate a random 2D vector which coordinates are regulary distributed within the area of a disk of a given radius /// - /// @param Radius /// @see gtc_random template - GLM_FUNC_DECL vec<2, T, defaultp> diskRand( - T Radius); - + GLM_FUNC_DECL vec<2, T, defaultp> diskRand(T Radius); + /// Generate a random 3D vector which coordinates are regulary distributed within the volume of a ball of a given radius /// - /// @param Radius /// @see gtc_random template - GLM_FUNC_DECL vec<3, T, defaultp> ballRand( - T Radius); - + GLM_FUNC_DECL vec<3, T, defaultp> ballRand(T Radius); + /// @} }//namespace glm diff --git a/glm/gtc/random.inl b/glm/gtc/random.inl index 974da1f5..103f9fc1 100644 --- a/glm/gtc/random.inl +++ b/glm/gtc/random.inl @@ -10,14 +10,14 @@ namespace glm{ namespace detail { - template class vecType> + template struct compute_rand { - GLM_FUNC_QUALIFIER static vecType call(); + GLM_FUNC_QUALIFIER static vec call(); }; - template - struct compute_rand<1, uint8, P, vec> + template + struct compute_rand<1, uint8, P> { GLM_FUNC_QUALIFIER static vec<1, uint8, P> call() { @@ -26,8 +26,8 @@ namespace detail } }; - template - struct compute_rand<2, uint8, P, vec> + template + struct compute_rand<2, uint8, P> { GLM_FUNC_QUALIFIER static vec<2, uint8, P> call() { @@ -37,8 +37,8 @@ namespace detail } }; - template - struct compute_rand<3, uint8, P, vec> + template + struct compute_rand<3, uint8, P> { GLM_FUNC_QUALIFIER static vec<3, uint8, P> call() { @@ -49,8 +49,8 @@ namespace detail } }; - template - struct compute_rand<4, uint8, P, vec> + template + struct compute_rand<4, uint8, P> { GLM_FUNC_QUALIFIER static vec<4, uint8, P> call() { @@ -62,195 +62,195 @@ namespace detail } }; - template class vecType> - struct compute_rand + template + struct compute_rand { - GLM_FUNC_QUALIFIER static vecType call() + GLM_FUNC_QUALIFIER static vec call() { return - (vecType(compute_rand::call()) << static_cast(8)) | - (vecType(compute_rand::call()) << static_cast(0)); + (vec(compute_rand::call()) << static_cast(8)) | + (vec(compute_rand::call()) << static_cast(0)); } }; - template class vecType> - struct compute_rand + template + struct compute_rand { - GLM_FUNC_QUALIFIER static vecType call() + GLM_FUNC_QUALIFIER static vec call() { return - (vecType(compute_rand::call()) << static_cast(16)) | - (vecType(compute_rand::call()) << static_cast(0)); + (vec(compute_rand::call()) << static_cast(16)) | + (vec(compute_rand::call()) << static_cast(0)); } }; - template class vecType> - struct compute_rand + template + struct compute_rand { - GLM_FUNC_QUALIFIER static vecType call() + GLM_FUNC_QUALIFIER static vec call() { return - (vecType(compute_rand::call()) << static_cast(32)) | - (vecType(compute_rand::call()) << static_cast(0)); + (vec(compute_rand::call()) << static_cast(32)) | + (vec(compute_rand::call()) << static_cast(0)); } }; - template class vecType> + template struct compute_linearRand { - GLM_FUNC_QUALIFIER static vecType call(vecType const & Min, vecType const & Max); + GLM_FUNC_QUALIFIER static vec call(vec const& Min, vec const& Max); }; - template class vecType> - struct compute_linearRand + template + struct compute_linearRand { - GLM_FUNC_QUALIFIER static vecType call(vecType const & Min, vecType const & Max) + GLM_FUNC_QUALIFIER static vec call(vec const& Min, vec const& Max) { - return (vecType(compute_rand::call() % vecType(Max + static_cast(1) - Min))) + Min; + return (vec(compute_rand::call() % vec(Max + static_cast(1) - Min))) + Min; } }; - template class vecType> - struct compute_linearRand + template + struct compute_linearRand { - GLM_FUNC_QUALIFIER static vecType call(vecType const & Min, vecType const & Max) + GLM_FUNC_QUALIFIER static vec call(vec const& Min, vec const& Max) { - return (compute_rand::call() % (Max + static_cast(1) - Min)) + Min; + return (compute_rand::call() % (Max + static_cast(1) - Min)) + Min; } }; - template class vecType> - struct compute_linearRand + template + struct compute_linearRand { - GLM_FUNC_QUALIFIER static vecType call(vecType const & Min, vecType const & Max) + GLM_FUNC_QUALIFIER static vec call(vec const& Min, vec const& Max) { - return (vecType(compute_rand::call() % vecType(Max + static_cast(1) - Min))) + Min; + return (vec(compute_rand::call() % vec(Max + static_cast(1) - Min))) + Min; } }; - template class vecType> - struct compute_linearRand + template + struct compute_linearRand { - GLM_FUNC_QUALIFIER static vecType call(vecType const & Min, vecType const & Max) + GLM_FUNC_QUALIFIER static vec call(vec const& Min, vec const& Max) { - return (compute_rand::call() % (Max + static_cast(1) - Min)) + Min; + return (compute_rand::call() % (Max + static_cast(1) - Min)) + Min; } }; - template class vecType> - struct compute_linearRand + template + struct compute_linearRand { - GLM_FUNC_QUALIFIER static vecType call(vecType const & Min, vecType const & Max) + GLM_FUNC_QUALIFIER static vec call(vec const & Min, vec const& Max) { - return (vecType(compute_rand::call() % vecType(Max + static_cast(1) - Min))) + Min; + return (vec(compute_rand::call() % vec(Max + static_cast(1) - Min))) + Min; } }; - template class vecType> - struct compute_linearRand + template + struct compute_linearRand { - GLM_FUNC_QUALIFIER static vecType call(vecType const & Min, vecType const & Max) + GLM_FUNC_QUALIFIER static vec call(vec const& Min, vec const& Max) { - return (compute_rand::call() % (Max + static_cast(1) - Min)) + Min; + return (compute_rand::call() % (Max + static_cast(1) - Min)) + Min; } }; - template class vecType> - struct compute_linearRand + template + struct compute_linearRand { - GLM_FUNC_QUALIFIER static vecType call(vecType const & Min, vecType const & Max) + GLM_FUNC_QUALIFIER static vec call(vec const& Min, vec const& Max) { - return (vecType(compute_rand::call() % vecType(Max + static_cast(1) - Min))) + Min; + return (vec(compute_rand::call() % vec(Max + static_cast(1) - Min))) + Min; } }; - template class vecType> - struct compute_linearRand + template + struct compute_linearRand { - GLM_FUNC_QUALIFIER static vecType call(vecType const & Min, vecType const & Max) + GLM_FUNC_QUALIFIER static vec call(vec const& Min, vec const& Max) { - return (compute_rand::call() % (Max + static_cast(1) - Min)) + Min; + return (compute_rand::call() % (Max + static_cast(1) - Min)) + Min; } }; - template class vecType> - struct compute_linearRand + template + struct compute_linearRand { - GLM_FUNC_QUALIFIER static vecType call(vecType const & Min, vecType const & Max) + GLM_FUNC_QUALIFIER static vec call(vec const& Min, vec const& Max) { - return vecType(compute_rand::call()) / static_cast(std::numeric_limits::max()) * (Max - Min) + Min; + return vec(compute_rand::call()) / static_cast(std::numeric_limits::max()) * (Max - Min) + Min; } }; - template class vecType> - struct compute_linearRand + template + struct compute_linearRand { - GLM_FUNC_QUALIFIER static vecType call(vecType const & Min, vecType const & Max) + GLM_FUNC_QUALIFIER static vec call(vec const& Min, vec const& Max) { - return vecType(compute_rand::call()) / static_cast(std::numeric_limits::max()) * (Max - Min) + Min; + return vec(compute_rand::call()) / static_cast(std::numeric_limits::max()) * (Max - Min) + Min; } }; - template class vecType> - struct compute_linearRand + template + struct compute_linearRand { - GLM_FUNC_QUALIFIER static vecType call(vecType const & Min, vecType const & Max) + GLM_FUNC_QUALIFIER static vec call(vec const& Min, vec const& Max) { - return vecType(compute_rand::call()) / static_cast(std::numeric_limits::max()) * (Max - Min) + Min; + return vec(compute_rand::call()) / static_cast(std::numeric_limits::max()) * (Max - Min) + Min; } }; - template class vecType> - struct compute_linearRand + template + struct compute_linearRand { - GLM_FUNC_QUALIFIER static vecType call(vecType const & Min, vecType const & Max) + GLM_FUNC_QUALIFIER static vec call(vec const& Min, vec const& Max) { - return vecType(compute_rand::call()) / static_cast(std::numeric_limits::max()) * (Max - Min) + Min; + return vec(compute_rand::call()) / static_cast(std::numeric_limits::max()) * (Max - Min) + Min; } }; - template class vecType> - struct compute_linearRand + template + struct compute_linearRand { - GLM_FUNC_QUALIFIER static vecType call(vecType const & Min, vecType const & Max) + GLM_FUNC_QUALIFIER static vec call(vec const& Min, vec const& Max) { - return vecType(compute_rand::call()) / static_cast(std::numeric_limits::max()) * (Max - Min) + Min; + return vec(compute_rand::call()) / static_cast(std::numeric_limits::max()) * (Max - Min) + Min; } }; - template class vecType> - struct compute_linearRand + template + struct compute_linearRand { - GLM_FUNC_QUALIFIER static vecType call(vecType const & Min, vecType const & Max) + GLM_FUNC_QUALIFIER static vec call(vec const& Min, vec const& Max) { - return vecType(compute_rand::call()) / static_cast(std::numeric_limits::max()) * (Max - Min) + Min; + return vec(compute_rand::call()) / static_cast(std::numeric_limits::max()) * (Max - Min) + Min; } }; - template class vecType> - struct compute_linearRand + template + struct compute_linearRand { - GLM_FUNC_QUALIFIER static vecType call(vecType const & Min, vecType const & Max) + GLM_FUNC_QUALIFIER static vec call(vec const& Min, vec const& Max) { - return vecType(compute_rand::call()) / static_cast(std::numeric_limits::max()) * (Max - Min) + Min; + return vec(compute_rand::call()) / static_cast(std::numeric_limits::max()) * (Max - Min) + Min; } }; - template class vecType> - struct compute_linearRand + template + struct compute_linearRand { - GLM_FUNC_QUALIFIER static vecType call(vecType const & Min, vecType const & Max) + GLM_FUNC_QUALIFIER static vec call(vec const& Min, vec const& Max) { - return vecType(compute_rand::call()) / static_cast(std::numeric_limits::max()) * (Max - Min) + Min; + return vec(compute_rand::call()) / static_cast(std::numeric_limits::max()) * (Max - Min) + Min; } }; - template class vecType> - struct compute_linearRand + template + struct compute_linearRand { - GLM_FUNC_QUALIFIER static vecType call(vecType const & Min, vecType const & Max) + GLM_FUNC_QUALIFIER static vec call(vec const& Min, vec const& Max) { - return vecType(compute_rand::call()) / static_cast(std::numeric_limits::max()) * (Max - Min) + Min; + return vec(compute_rand::call()) / static_cast(std::numeric_limits::max()) * (Max - Min) + Min; } }; }//namespace detail @@ -258,22 +258,22 @@ namespace detail template GLM_FUNC_QUALIFIER genType linearRand(genType Min, genType Max) { - return detail::compute_linearRand<1, genType, highp, vec>::call( + return detail::compute_linearRand<1, genType, highp>::call( vec<1, genType, highp>(Min), vec<1, genType, highp>(Max)).x; } - template class vecType> - GLM_FUNC_QUALIFIER vecType linearRand(vecType const & Min, vecType const & Max) + template + GLM_FUNC_QUALIFIER vec linearRand(vec const & Min, vec const& Max) { - return detail::compute_linearRand::call(Min, Max); + return detail::compute_linearRand::call(Min, Max); } template GLM_FUNC_QUALIFIER genType gaussRand(genType Mean, genType Deviation) { genType w, x1, x2; - + do { x1 = linearRand(genType(-1), genType(1)); @@ -281,12 +281,12 @@ namespace detail w = x1 * x1 + x2 * x2; } while(w > genType(1)); - + return x2 * Deviation * Deviation * sqrt((genType(-2) * log(w)) / w) + Mean; } - template class vecType> - GLM_FUNC_QUALIFIER vecType gaussRand(vecType const & Mean, vecType const & Deviation) + template + GLM_FUNC_QUALIFIER vec gaussRand(vec const& Mean, vec const& Deviation) { return detail::functor2::call(gaussRand, Mean, Deviation); } @@ -296,7 +296,7 @@ namespace detail { vec<2, T, defaultp> Result(T(0)); T LenRadius(T(0)); - + do { Result = linearRand( @@ -305,10 +305,10 @@ namespace detail LenRadius = length(Result); } while(LenRadius > Radius); - + return Result; } - + template GLM_FUNC_QUALIFIER vec<3, T, defaultp> ballRand(T Radius) { @@ -326,25 +326,25 @@ namespace detail return Result; } - + template GLM_FUNC_QUALIFIER vec<2, T, defaultp> circularRand(T Radius) { T a = linearRand(T(0), T(6.283185307179586476925286766559f)); return vec<2, T, defaultp>(cos(a), sin(a)) * Radius; } - + template GLM_FUNC_QUALIFIER vec<3, T, defaultp> sphericalRand(T Radius) { T z = linearRand(T(-1), T(1)); T a = linearRand(T(0), T(6.283185307179586476925286766559f)); - + T r = sqrt(T(1) - z * z); - + T x = r * cos(a); T y = r * sin(a); - - return vec<3, T, defaultp>(x, y, z) * Radius; + + return vec<3, T, defaultp>(x, y, z) * Radius; } }//namespace glm diff --git a/glm/gtc/round.hpp b/glm/gtc/round.hpp index 3520e436..8ca22bfd 100644 --- a/glm/gtc/round.hpp +++ b/glm/gtc/round.hpp @@ -39,8 +39,8 @@ namespace glm /// Return true if the value is a power of two number. /// /// @see gtc_round - template class vecType> - GLM_FUNC_DECL vecType isPowerOfTwo(vecType const & value); + template + GLM_FUNC_DECL vec isPowerOfTwo(vec const& value); /// Return the power of two number which value is just higher the input value, /// round up to a power of two. @@ -53,8 +53,8 @@ namespace glm /// round up to a power of two. /// /// @see gtc_round - template class vecType> - GLM_FUNC_DECL vecType ceilPowerOfTwo(vecType const & value); + template + GLM_FUNC_DECL vec ceilPowerOfTwo(vec const& value); /// Return the power of two number which value is just lower the input value, /// round down to a power of two. @@ -67,8 +67,8 @@ namespace glm /// round down to a power of two. /// /// @see gtc_round - template class vecType> - GLM_FUNC_DECL vecType floorPowerOfTwo(vecType const & value); + template + GLM_FUNC_DECL vec floorPowerOfTwo(vec const& value); /// Return the power of two number which value is the closet to the input value. /// @@ -79,8 +79,8 @@ namespace glm /// Return the power of two number which value is the closet to the input value. /// /// @see gtc_round - template class vecType> - GLM_FUNC_DECL vecType roundPowerOfTwo(vecType const & value); + template + GLM_FUNC_DECL vec roundPowerOfTwo(vec const& value); /// Return true if the 'Value' is a multiple of 'Multiple'. /// @@ -91,19 +91,18 @@ namespace glm /// Return true if the 'Value' is a multiple of 'Multiple'. /// /// @see gtc_round - template class vecType> - GLM_FUNC_DECL vecType isMultiple(vecType const & Value, T Multiple); + template + GLM_FUNC_DECL vec isMultiple(vec const& Value, T Multiple); /// Return true if the 'Value' is a multiple of 'Multiple'. /// /// @see gtc_round - template class vecType> - GLM_FUNC_DECL vecType isMultiple(vecType const & Value, vecType const & Multiple); + template + GLM_FUNC_DECL vec isMultiple(vec const& Value, vec const& Multiple); /// Higher multiple number of Source. /// /// @tparam genType Floating-point or integer scalar or vector types. - /// @param Source /// @param Multiple Must be a null or positive value /// /// @see gtc_round @@ -113,60 +112,47 @@ namespace glm /// Higher multiple number of Source. /// /// @tparam genType Floating-point or integer scalar or vector types. - /// @param Source /// @param Multiple Must be a null or positive value /// /// @see gtc_round - template class vecType> - GLM_FUNC_DECL vecType ceilMultiple(vecType const & Source, vecType const & Multiple); + template + GLM_FUNC_DECL vec ceilMultiple(vec const & Source, vec const& Multiple); /// Lower multiple number of Source. /// /// @tparam genType Floating-point or integer scalar or vector types. - /// @param Source /// @param Multiple Must be a null or positive value /// /// @see gtc_round template - GLM_FUNC_DECL genType floorMultiple( - genType Source, - genType Multiple); + GLM_FUNC_DECL genType floorMultiple(genType Source, genType Multiple); /// Lower multiple number of Source. /// /// @tparam genType Floating-point or integer scalar or vector types. - /// @param Source /// @param Multiple Must be a null or positive value /// /// @see gtc_round - template class vecType> - GLM_FUNC_DECL vecType floorMultiple( - vecType const& Source, - vecType const& Multiple); + template + GLM_FUNC_DECL vec floorMultiple(vec const& Source, vec const& Multiple); /// Lower multiple number of Source. /// /// @tparam genType Floating-point or integer scalar or vector types. - /// @param Source /// @param Multiple Must be a null or positive value /// /// @see gtc_round template - GLM_FUNC_DECL genType roundMultiple( - genType Source, - genType Multiple); + GLM_FUNC_DECL genType roundMultiple(genType Source, genType Multiple); /// Lower multiple number of Source. /// /// @tparam genType Floating-point or integer scalar or vector types. - /// @param Source /// @param Multiple Must be a null or positive value /// /// @see gtc_round - template class vecType> - GLM_FUNC_DECL vecType roundMultiple( - vecType const& Source, - vecType const& Multiple); + template + GLM_FUNC_DECL vec roundMultiple(vec const& Source, vec const& Multiple); /// @} } //namespace glm diff --git a/glm/gtc/round.inl b/glm/gtc/round.inl index 9ddf50ea..5cfae57d 100644 --- a/glm/gtc/round.inl +++ b/glm/gtc/round.inl @@ -6,62 +6,62 @@ namespace glm{ namespace detail { - template class vecType, bool compute = false> + template struct compute_ceilShift { - GLM_FUNC_QUALIFIER static vecType call(vecType const & v, T) + GLM_FUNC_QUALIFIER static vec call(vec const& v, T) { return v; } }; - template class vecType> - struct compute_ceilShift + template + struct compute_ceilShift { - GLM_FUNC_QUALIFIER static vecType call(vecType const & v, T Shift) + GLM_FUNC_QUALIFIER static vec call(vec const& v, T Shift) { return v | (v >> Shift); } }; - template class vecType, bool isSigned = true> + template struct compute_ceilPowerOfTwo { - GLM_FUNC_QUALIFIER static vecType call(vecType const & x) + GLM_FUNC_QUALIFIER static vec call(vec const& x) { GLM_STATIC_ASSERT(!std::numeric_limits::is_iec559, "'ceilPowerOfTwo' only accept integer scalar or vector inputs"); - vecType const Sign(sign(x)); + vec const Sign(sign(x)); - vecType v(abs(x)); + vec v(abs(x)); v = v - static_cast(1); v = v | (v >> static_cast(1)); v = v | (v >> static_cast(2)); v = v | (v >> static_cast(4)); - v = compute_ceilShift= 2>::call(v, 8); - v = compute_ceilShift= 4>::call(v, 16); - v = compute_ceilShift= 8>::call(v, 32); + v = compute_ceilShift= 2>::call(v, 8); + v = compute_ceilShift= 4>::call(v, 16); + v = compute_ceilShift= 8>::call(v, 32); return (v + static_cast(1)) * Sign; } }; - template class vecType> - struct compute_ceilPowerOfTwo + template + struct compute_ceilPowerOfTwo { - GLM_FUNC_QUALIFIER static vecType call(vecType const & x) + GLM_FUNC_QUALIFIER static vec call(vec const& x) { GLM_STATIC_ASSERT(!std::numeric_limits::is_iec559, "'ceilPowerOfTwo' only accept integer scalar or vector inputs"); - vecType v(x); + vec v(x); v = v - static_cast(1); v = v | (v >> static_cast(1)); v = v | (v >> static_cast(2)); v = v | (v >> static_cast(4)); - v = compute_ceilShift= 2>::call(v, 8); - v = compute_ceilShift= 4>::call(v, 16); - v = compute_ceilShift= 8>::call(v, 32); + v = compute_ceilShift= 2>::call(v, 8); + v = compute_ceilShift= 4>::call(v, 16); + v = compute_ceilShift= 8>::call(v, 32); return v + static_cast(1); } }; @@ -219,11 +219,11 @@ namespace detail return !(Result & (Result - 1)); } - template class vecType> - GLM_FUNC_QUALIFIER vecType isPowerOfTwo(vecType const & Value) + template + GLM_FUNC_QUALIFIER vec isPowerOfTwo(vec const & Value) { - vecType const Result(abs(Value)); - return equal(Result & (Result - 1), vecType(0)); + vec const Result(abs(Value)); + return equal(Result & (Result - 1), vec(0)); } ////////////////// @@ -232,13 +232,13 @@ namespace detail template GLM_FUNC_QUALIFIER genType ceilPowerOfTwo(genType value) { - return detail::compute_ceilPowerOfTwo<1, genType, defaultp, vec, std::numeric_limits::is_signed>::call(vec<1, genType, defaultp>(value)).x; + return detail::compute_ceilPowerOfTwo<1, genType, defaultp, std::numeric_limits::is_signed>::call(vec<1, genType, defaultp>(value)).x; } - template class vecType> - GLM_FUNC_QUALIFIER vecType ceilPowerOfTwo(vecType const & v) + template + GLM_FUNC_QUALIFIER vec ceilPowerOfTwo(vec const& v) { - return detail::compute_ceilPowerOfTwo::is_signed>::call(v); + return detail::compute_ceilPowerOfTwo::is_signed>::call(v); } /////////////////// @@ -250,8 +250,8 @@ namespace detail return isPowerOfTwo(value) ? value : static_cast(1) << findMSB(value); } - template class vecType> - GLM_FUNC_QUALIFIER vecType floorPowerOfTwo(vecType const & v) + template + GLM_FUNC_QUALIFIER vec floorPowerOfTwo(vec const & v) { return detail::functor1::call(floorPowerOfTwo, v); } @@ -270,8 +270,8 @@ namespace detail return (next - value) < (value - prev) ? next : prev; } - template class vecType> - GLM_FUNC_QUALIFIER vecType roundPowerOfTwo(vecType const & v) + template + GLM_FUNC_QUALIFIER vec roundPowerOfTwo(vec const & v) { return detail::functor1::call(roundPowerOfTwo, v); } @@ -285,16 +285,16 @@ namespace detail return isMultiple(vec<1, genType>(Value), vec<1, genType>(Multiple)).x; } - template class vecType> - GLM_FUNC_QUALIFIER vecType isMultiple(vecType const & Value, T Multiple) + template + GLM_FUNC_QUALIFIER vec isMultiple(vec const & Value, T Multiple) { - return (Value % Multiple) == vecType(0); + return (Value % Multiple) == vec(0); } - template class vecType> - GLM_FUNC_QUALIFIER vecType isMultiple(vecType const & Value, vecType const & Multiple) + template + GLM_FUNC_QUALIFIER vec isMultiple(vec const& Value, vec const& Multiple) { - return (Value % Multiple) == vecType(0); + return (Value % Multiple) == vec(0); } ////////////////////// @@ -306,8 +306,8 @@ namespace detail return detail::compute_ceilMultiple::is_iec559, std::numeric_limits::is_signed>::call(Source, Multiple); } - template class vecType> - GLM_FUNC_QUALIFIER vecType ceilMultiple(vecType const & Source, vecType const & Multiple) + template + GLM_FUNC_QUALIFIER vec ceilMultiple(vec const& Source, vec const& Multiple) { return detail::functor2::call(ceilMultiple, Source, Multiple); } @@ -321,8 +321,8 @@ namespace detail return detail::compute_floorMultiple::is_iec559, std::numeric_limits::is_signed>::call(Source, Multiple); } - template class vecType> - GLM_FUNC_QUALIFIER vecType floorMultiple(vecType const & Source, vecType const & Multiple) + template + GLM_FUNC_QUALIFIER vec floorMultiple(vec const& Source, vec const& Multiple) { return detail::functor2::call(floorMultiple, Source, Multiple); } @@ -336,8 +336,8 @@ namespace detail return detail::compute_roundMultiple::is_iec559, std::numeric_limits::is_signed>::call(Source, Multiple); } - template class vecType> - GLM_FUNC_QUALIFIER vecType roundMultiple(vecType const & Source, vecType const & Multiple) + template + GLM_FUNC_QUALIFIER vec roundMultiple(vec const& Source, vec const& Multiple) { return detail::functor2::call(roundMultiple, Source, Multiple); } diff --git a/glm/gtc/ulp.inl b/glm/gtc/ulp.inl index be7e385b..0ce0a40c 100644 --- a/glm/gtc/ulp.inl +++ b/glm/gtc/ulp.inl @@ -81,30 +81,39 @@ namespace detail if((ix>0x7f800000) || // x is nan (iy>0x7f800000)) // y is nan return x+y; - if(x==y) return y; // x=y, return y - if(ix==0) { // x == 0 + if(detail::compute_equal::call(x, y)) + return y; // x=y, return y + if(ix==0) + { // x == 0 GLM_SET_FLOAT_WORD(x,(hy&0x80000000)|1);// return +-minsubnormal t = x*x; - if(t==x) return t; else return x; // raise underflow flag + if(detail::compute_equal::call(t, x)) + return t; + else + return x; // raise underflow flag } - if(hx>=0) { // x > 0 - if(hx>hy) { // x > y, x -= ulp + if(hx>=0) + { // x > 0 + if(hx>hy) // x > y, x -= ulp hx -= 1; - } else { // x < y, x += ulp + else // x < y, x += ulp hx += 1; - } - } else { // x < 0 - if(hy>=0||hx>hy){ // x < y, x -= ulp + } + else + { // x < 0 + if(hy>=0||hx>hy) // x < y, x -= ulp hx -= 1; - } else { // x > y, x += ulp + else // x > y, x += ulp hx += 1; - } } hy = hx&0x7f800000; - if(hy>=0x7f800000) return x+x; // overflow - if(hy<0x00800000) { // underflow + if(hy>=0x7f800000) + return x+x; // overflow + if(hy<0x00800000) // underflow + { t = x*x; - if(t!=x) { // raise underflow flag + if(!detail::compute_equal::call(t, x)) + { // raise underflow flag GLM_SET_FLOAT_WORD(y,hx); return y; } @@ -121,17 +130,22 @@ namespace detail GLM_EXTRACT_WORDS(hx, lx, x); GLM_EXTRACT_WORDS(hy, ly, y); - ix = hx & 0x7fffffff; // |x| - iy = hy & 0x7fffffff; // |y| + ix = hx & 0x7fffffff; // |x| + iy = hy & 0x7fffffff; // |y| - if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) || // x is nan - ((iy>=0x7ff00000)&&((iy-0x7ff00000)|ly)!=0)) // y is nan + if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) || // x is nan + ((iy>=0x7ff00000)&&((iy-0x7ff00000)|ly)!=0)) // y is nan return x+y; - if(x==y) return y; // x=y, return y - if((ix|lx)==0) { // x == 0 - GLM_INSERT_WORDS(x, hy & 0x80000000, 1); // return +-minsubnormal + if(detail::compute_equal::call(x, y)) + return y; // x=y, return y + if((ix|lx)==0) + { // x == 0 + GLM_INSERT_WORDS(x, hy & 0x80000000, 1); // return +-minsubnormal t = x*x; - if(t==x) return t; else return x; // raise underflow flag + if(detail::compute_equal::call(t, x)) + return t; + else + return x; // raise underflow flag } if(hx>=0) { // x > 0 if(hx>hy||((hx==hy)&&(lx>ly))) { // x > y, x -= ulp @@ -151,10 +165,13 @@ namespace detail } } hy = hx&0x7ff00000; - if(hy>=0x7ff00000) return x+x; // overflow - if(hy<0x00100000) { // underflow + if(hy>=0x7ff00000) + return x+x; // overflow + if(hy<0x00100000) + { // underflow t = x*x; - if(t!=x) { // raise underflow flag + if(!detail::compute_equal::call(t, x)) + { // raise underflow flag GLM_INSERT_WORDS(y,hx,lx); return y; } diff --git a/glm/simd/common.h b/glm/simd/common.h index 143a941f..78ff4d23 100644 --- a/glm/simd/common.h +++ b/glm/simd/common.h @@ -63,7 +63,7 @@ GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_swizzle_xyzw(glm_vec4 a) GLM_FUNC_QUALIFIER glm_vec4 glm_vec1_fma(glm_vec4 a, glm_vec4 b, glm_vec4 c) { -# if GLM_ARCH & GLM_ARCH_AVX2_BIT +# if (GLM_ARCH & GLM_ARCH_AVX2_BIT) && !(GLM_COMPILER & GLM_COMPILER_CLANG) return _mm_fmadd_ss(a, b, c); # else return _mm_add_ss(_mm_mul_ss(a, b), c); @@ -72,7 +72,7 @@ GLM_FUNC_QUALIFIER glm_vec4 glm_vec1_fma(glm_vec4 a, glm_vec4 b, glm_vec4 c) GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_fma(glm_vec4 a, glm_vec4 b, glm_vec4 c) { -# if GLM_ARCH & GLM_ARCH_AVX2_BIT +# if (GLM_ARCH & GLM_ARCH_AVX2_BIT) && !(GLM_COMPILER & GLM_COMPILER_CLANG) return _mm_fmadd_ps(a, b, c); # else return glm_vec4_add(glm_vec4_mul(a, b), c); diff --git a/glm/simd/platform.h b/glm/simd/platform.h index 2181cf28..b92c9bb6 100644 --- a/glm/simd/platform.h +++ b/glm/simd/platform.h @@ -247,9 +247,9 @@ #define GLM_ARCH_SSE42_BIT 0x00000020 #define GLM_ARCH_AVX_BIT 0x00000040 #define GLM_ARCH_AVX2_BIT 0x00000080 -#define GLM_ARCH_AVX512_BIT 0x00000100 // Skylake subset -#define GLM_ARCH_ARM_BIT 0x00000100 -#define GLM_ARCH_NEON_BIT 0x00000200 +#define GLM_ARCH_AVX512_BIT 0x00000200 // Skylake subset +#define GLM_ARCH_ARM_BIT 0x00000400 +#define GLM_ARCH_NEON_BIT 0x00000800 #define GLM_ARCH_MIPS_BIT 0x00010000 #define GLM_ARCH_PPC_BIT 0x01000000 diff --git a/readme.md b/readme.md index 45b22e06..ae471f5d 100644 --- a/readme.md +++ b/readme.md @@ -78,6 +78,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate) - Added GLM_FORCE_IGNORE_VERSION to ignore error caused by including different version of GLM #619 - Reduced warnings when using very strict compilation flags #646 - length() member functions are constexpr #657 +- Added support of -Weverything with Clang #646 #### Fixes: - Removed doxygen references to GTC_half_float which was removed in 0.9.4 @@ -91,6 +92,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate) - Fixed integer pow from GTX_integer with null exponent #658 - Fixed quat normalize build error #656 - Fixed Visual C++ 2017.2 warning regarding __has_feature definision #655 +- Fixed documentation warnings #### Deprecation: - Requires Visual Studio 2013, GCC 4.7, Clang 3.4, Cuda 7, ICC 2013 or a C++11 compiler diff --git a/test/core/core_func_integer.cpp b/test/core/core_func_integer.cpp index 9b86981a..6ffe2267 100644 --- a/test/core/core_func_integer.cpp +++ b/test/core/core_func_integer.cpp @@ -15,17 +15,17 @@ enum result namespace bitfieldInsert { - template + template struct type { genType Base; genType Insert; - sizeType Offset; - sizeType Bits; + int Offset; + int Bits; genType Return; }; - typedef type typeU32; + typedef type typeU32; typeU32 const Data32[] = { @@ -37,7 +37,7 @@ namespace bitfieldInsert {0x0000ffff, 0xffff0000, 16, 16, 0xffffffff} }; - int test() + static int test() { int Error = 0; glm::uint count = sizeof(Data32) / sizeof(typeU32); @@ -59,17 +59,17 @@ namespace bitfieldInsert namespace bitfieldExtract { - template + template struct type { genType Value; - sizeType Offset; - sizeType Bits; + int Offset; + int Bits; genType Return; result Result; }; - typedef type typeU32; + typedef type typeU32; typeU32 const Data32[] = { @@ -95,7 +95,7 @@ namespace bitfieldExtract //{0xffffffff,16,16, 0x00000000, ASSERT}, // Throw an assert }; - int test() + static int test() { int Error = 0; @@ -265,7 +265,7 @@ namespace bitfieldReverse {0x0000000000000000, 0x0000000000000000, SUCCESS} }; - int test32_bitfieldReverse() + static int test32_bitfieldReverse() { int Error = 0; std::size_t const Count = sizeof(Data32) / sizeof(typeU32); @@ -285,7 +285,7 @@ namespace bitfieldReverse return Error; } - int test32_bitfieldReverseLoop() + static int test32_bitfieldReverseLoop() { int Error = 0; std::size_t const Count = sizeof(Data32) / sizeof(typeU32); @@ -305,7 +305,7 @@ namespace bitfieldReverse return Error; } - int test32_bitfieldReverseUint32() + static int test32_bitfieldReverseUint32() { int Error = 0; std::size_t const Count = sizeof(Data32) / sizeof(typeU32); @@ -325,7 +325,7 @@ namespace bitfieldReverse return Error; } - int test32_bitfieldReverseOps() + static int test32_bitfieldReverseOps() { int Error = 0; std::size_t const Count = sizeof(Data32) / sizeof(typeU32); @@ -345,7 +345,7 @@ namespace bitfieldReverse return Error; } - int test64_bitfieldReverse() + static int test64_bitfieldReverse() { int Error = 0; std::size_t const Count = sizeof(Data64) / sizeof(typeU64); @@ -365,7 +365,7 @@ namespace bitfieldReverse return Error; } - int test64_bitfieldReverseLoop() + static int test64_bitfieldReverseLoop() { int Error = 0; std::size_t const Count = sizeof(Data64) / sizeof(typeU64); @@ -385,7 +385,7 @@ namespace bitfieldReverse return Error; } - int test64_bitfieldReverseUint64() + static int test64_bitfieldReverseUint64() { int Error = 0; std::size_t const Count = sizeof(Data64) / sizeof(typeU64); @@ -405,7 +405,7 @@ namespace bitfieldReverse return Error; } - int test64_bitfieldReverseOps() + static int test64_bitfieldReverseOps() { int Error = 0; std::size_t const Count = sizeof(Data64) / sizeof(typeU64); @@ -425,7 +425,7 @@ namespace bitfieldReverse return Error; } - int test() + static int test() { int Error = 0; @@ -442,7 +442,7 @@ namespace bitfieldReverse return Error; } - int perf32(glm::uint32 Count) + static int perf32(glm::uint32 Count) { int Error = 0; @@ -479,7 +479,7 @@ namespace bitfieldReverse return Error; } - int perf64(glm::uint64 Count) + static int perf64(glm::uint64 Count) { int Error = 0; @@ -516,7 +516,7 @@ namespace bitfieldReverse return Error; } - int perf(std::size_t Samples) + static int perf(std::size_t Samples) { int Error = 0; @@ -538,7 +538,7 @@ namespace findMSB # if GLM_HAS_BITSCAN_WINDOWS template - GLM_FUNC_QUALIFIER int findMSB_intrinsic(genIUType Value) + static int findMSB_intrinsic(genIUType Value) { GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findMSB' only accept integer values"); @@ -553,7 +553,7 @@ namespace findMSB # if GLM_ARCH & GLM_ARCH_AVX && GLM_COMPILER & GLM_COMPILER_VC template - GLM_FUNC_QUALIFIER int findMSB_avx(genIUType Value) + static int findMSB_avx(genIUType Value) { GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findMSB' only accept integer values"); @@ -565,7 +565,7 @@ namespace findMSB # endif//GLM_ARCH & GLM_ARCH_AVX && GLM_PLATFORM & GLM_PLATFORM_WINDOWS template - GLM_FUNC_QUALIFIER int findMSB_095(genIUType Value) + static int findMSB_095(genIUType Value) { GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findMSB' only accept integer values"); @@ -575,7 +575,7 @@ namespace findMSB { genIUType Bit = genIUType(-1); for(genIUType tmp = Value; tmp > 0; tmp >>= 1, ++Bit){} - return Bit; + return static_cast(Bit); } else //if(Value < 0) { @@ -589,7 +589,7 @@ namespace findMSB } template - GLM_FUNC_QUALIFIER int findMSB_nlz1(genIUType x) + static int findMSB_nlz1(genIUType x) { GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findMSB' only accept integer values"); @@ -605,21 +605,20 @@ namespace findMSB return 31 - n; } - int findMSB_nlz2(unsigned int x) + static int findMSB_nlz2(unsigned int x) { - unsigned y; - int n; + unsigned int y; + int n = 32; - n = 32; y = x >>16; if (y != 0) {n = n -16; x = y;} y = x >> 8; if (y != 0) {n = n - 8; x = y;} y = x >> 4; if (y != 0) {n = n - 4; x = y;} y = x >> 2; if (y != 0) {n = n - 2; x = y;} y = x >> 1; if (y != 0) return n - 2; - return 32 - (n - x); + return 32 - (n - static_cast(x)); } - int findMSB_pop(unsigned int x) + static int findMSB_pop(unsigned int x) { x = x | (x >> 1); x = x | (x >> 2); @@ -629,7 +628,7 @@ namespace findMSB return 31 - glm::bitCount(~x); } - int perf_int(std::size_t Count) + static int perf_int(std::size_t Count) { type const Data[] = { @@ -695,7 +694,7 @@ namespace findMSB for(std::size_t k = 0; k < Count; ++k) for(std::size_t i = 0; i < sizeof(Data) / sizeof(type); ++i) { - int Result = findMSB_nlz2(Data[i].Value); + int Result = findMSB_nlz2(static_cast(Data[i].Value)); Error += Data[i].Return == Result ? 0 : 1; } @@ -704,7 +703,7 @@ namespace findMSB for(std::size_t k = 0; k < Count; ++k) for(std::size_t i = 0; i < sizeof(Data) / sizeof(type); ++i) { - int Result = findMSB_095(Data[i].Value); + int Result = findMSB_095(static_cast(Data[i].Value)); Error += Data[i].Return == Result ? 0 : 1; } @@ -724,7 +723,7 @@ namespace findMSB for(std::size_t k = 0; k < Count; ++k) for(std::size_t i = 0; i < sizeof(Data) / sizeof(type); ++i) { - int Result = findMSB_pop(Data[i].Value); + int Result = findMSB_pop(static_cast(Data[i].Value)); Error += Data[i].Return == Result ? 0 : 1; } @@ -737,9 +736,9 @@ namespace findMSB int Result = findMSB_avx(Data[i].Value); Error += Data[i].Return == Result ? 0 : 1; } -# endif - std::clock_t Timestamps7 = std::clock(); + std::clock_t Timestamps7 = std::clock(); +# endif std::printf("glm::findMSB: %d clocks\n", static_cast(Timestamps1 - Timestamps0)); std::printf("findMSB - nlz1: %d clocks\n", static_cast(Timestamps2 - Timestamps1)); @@ -758,7 +757,7 @@ namespace findMSB return Error; } - int test_ivec4() + static int test_ivec4() { type const Data[] = { @@ -810,7 +809,7 @@ namespace findMSB return Error; } - int test_int() + static int test_int() { typedef type entry; @@ -896,7 +895,7 @@ namespace findMSB return Error; } - int test() + static int test() { int Error(0); @@ -906,7 +905,7 @@ namespace findMSB return Error; } - int perf(std::size_t Samples) + static int perf(std::size_t Samples) { int Error(0); @@ -942,7 +941,7 @@ namespace findLSB # if GLM_HAS_BITSCAN_WINDOWS template - GLM_FUNC_QUALIFIER int findLSB_intrinsic(genIUType Value) + static int findLSB_intrinsic(genIUType Value) { GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findLSB' only accept integer values"); @@ -956,7 +955,7 @@ namespace findLSB # endif template - GLM_FUNC_QUALIFIER int findLSB_095(genIUType Value) + static int findLSB_095(genIUType Value) { GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findLSB' only accept integer values"); if(Value == 0) @@ -968,7 +967,7 @@ namespace findLSB } template - GLM_FUNC_QUALIFIER int findLSB_ntz2(genIUType x) + static int findLSB_ntz2(genIUType x) { if(x == 0) return -1; @@ -977,7 +976,7 @@ namespace findLSB } template - GLM_FUNC_QUALIFIER int findLSB_branchfree(genIUType x) + static int findLSB_branchfree(genIUType x) { bool IsNull(x == 0); int const Keep(!IsNull); @@ -986,7 +985,7 @@ namespace findLSB return static_cast(glm::bitCount(~x & (x - static_cast(1)))) * Keep + Discard * -1; } - int test_int() + static int test_int() { int Error(0); @@ -1025,7 +1024,7 @@ namespace findLSB return Error; } - int test() + static int test() { int Error(0); @@ -1034,7 +1033,7 @@ namespace findLSB return Error; } - int perf_int(std::size_t Count) + static int perf_int(std::size_t Count) { int Error(0); @@ -1100,7 +1099,7 @@ namespace findLSB return Error; } - int perf(std::size_t Samples) + static int perf(std::size_t Samples) { int Error(0); @@ -1112,7 +1111,7 @@ namespace findLSB namespace uaddCarry { - int test() + static int test() { int Error(0); @@ -1162,7 +1161,7 @@ namespace uaddCarry namespace usubBorrow { - int test() + static int test() { int Error(0); @@ -1222,7 +1221,7 @@ namespace usubBorrow namespace umulExtended { - int test() + static int test() { int Error(0); @@ -1287,7 +1286,7 @@ namespace umulExtended namespace imulExtended { - int test() + static int test() { int Error(0); @@ -1416,7 +1415,7 @@ namespace bitCount }; template class vecType> - GLM_FUNC_QUALIFIER vecType bitCount_bitfield(vecType const & v) + static vecType bitCount_bitfield(vecType const & v) { vecType::type, P> x(*reinterpret_cast::type, P> const *>(&v)); x = compute_bitfieldBitCountStep= 2>::call(x, typename glm::detail::make_unsigned::type(0x5555555555555555ull), typename glm::detail::make_unsigned::type( 1)); @@ -1429,12 +1428,12 @@ namespace bitCount } template - GLM_FUNC_QUALIFIER int bitCount_bitfield(genType x) + static int bitCount_bitfield(genType x) { return bitCount_bitfield(glm::vec<1, genType, glm::defaultp>(x)).x; } - int perf(std::size_t Size) + static int perf(std::size_t Size) { int Error(0); @@ -1495,7 +1494,7 @@ namespace bitCount return Error; } - int test() + static int test() { int Error(0); @@ -1535,11 +1534,14 @@ int main() # ifdef NDEBUG std::size_t const Samples = 1000; - ::bitCount::perf(Samples); - ::bitfieldReverse::perf(Samples); - ::findMSB::perf(Samples); - ::findLSB::perf(Samples); +# else + std::size_t const Samples = 1; # endif + ::bitCount::perf(Samples); + ::bitfieldReverse::perf(Samples); + ::findMSB::perf(Samples); + ::findLSB::perf(Samples); + return Error; } diff --git a/test/core/core_func_vector_relational.cpp b/test/core/core_func_vector_relational.cpp index c98f789b..55672b76 100644 --- a/test/core/core_func_vector_relational.cpp +++ b/test/core/core_func_vector_relational.cpp @@ -4,7 +4,7 @@ #include #include -int test_not() +static int test_not() { int Error(0); diff --git a/test/core/core_type_ctor.cpp b/test/core/core_type_ctor.cpp index 7ee8a3fb..5cc9fa09 100644 --- a/test/core/core_type_ctor.cpp +++ b/test/core/core_type_ctor.cpp @@ -2,7 +2,7 @@ #include #include -int test_vec1_ctor() +static int test_vec1_ctor() { int Error = 0; @@ -25,7 +25,7 @@ int test_vec1_ctor() return Error; } -int test_vec2_ctor() +static int test_vec2_ctor() { int Error = 0; @@ -48,7 +48,7 @@ int test_vec2_ctor() return Error; } -int test_vec3_ctor() +static int test_vec3_ctor() { int Error = 0; @@ -71,7 +71,7 @@ int test_vec3_ctor() return Error; } -int test_vec4_ctor() +static int test_vec4_ctor() { int Error = 0; @@ -94,7 +94,7 @@ int test_vec4_ctor() return Error; } -int test_mat2x2_ctor() +static int test_mat2x2_ctor() { int Error = 0; @@ -117,7 +117,7 @@ int test_mat2x2_ctor() return Error; } -int test_mat2x3_ctor() +static int test_mat2x3_ctor() { int Error = 0; @@ -140,7 +140,7 @@ int test_mat2x3_ctor() return Error; } -int test_mat2x4_ctor() +static int test_mat2x4_ctor() { int Error = 0; @@ -165,7 +165,7 @@ int test_mat2x4_ctor() return Error; } -int test_mat3x2_ctor() +static int test_mat3x2_ctor() { int Error = 0; @@ -188,7 +188,7 @@ int test_mat3x2_ctor() return Error; } -int test_mat3x3_ctor() +static int test_mat3x3_ctor() { int Error = 0; @@ -211,7 +211,7 @@ int test_mat3x3_ctor() return Error; } -int test_mat3x4_ctor() +static int test_mat3x4_ctor() { int Error = 0; @@ -234,7 +234,7 @@ int test_mat3x4_ctor() return Error; } -int test_mat4x2_ctor() +static int test_mat4x2_ctor() { int Error = 0; @@ -257,7 +257,7 @@ int test_mat4x2_ctor() return Error; } -int test_mat4x3_ctor() +static int test_mat4x3_ctor() { int Error = 0; @@ -280,7 +280,7 @@ int test_mat4x3_ctor() return Error; } -int test_mat4x4_ctor() +static int test_mat4x4_ctor() { int Error = 0; @@ -303,7 +303,7 @@ int test_mat4x4_ctor() return Error; } -int test_quat_ctor() +static int test_quat_ctor() { int Error = 0; diff --git a/test/core/core_type_length.cpp b/test/core/core_type_length.cpp index 17c2fa92..4bf76cf0 100644 --- a/test/core/core_type_length.cpp +++ b/test/core/core_type_length.cpp @@ -1,6 +1,6 @@ #include -int test_length_mat_non_squared() +static int test_length_mat_non_squared() { int Error = 0; @@ -21,7 +21,7 @@ int test_length_mat_non_squared() return Error; } -int test_length_mat() +static int test_length_mat() { int Error = 0; @@ -42,7 +42,7 @@ int test_length_mat() return Error; } -int test_length_vec() +static int test_length_vec() { int Error = 0;