Reduce the number of warnings with -Weverything #646

This commit is contained in:
Christophe Riccio 2017-08-06 23:00:05 +02:00
parent bb48c10275
commit 384dab02e4
43 changed files with 1116 additions and 1003 deletions

View File

@ -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)

View File

@ -0,0 +1,28 @@
#pragma once
#include "setup.hpp"
#include <cstring>
#include <limits>
namespace glm{
namespace detail
{
template <typename T, bool isFloat = std::numeric_limits<T>::is_iec559>
struct compute_equal
{
GLM_FUNC_QUALIFIER static bool call(T a, T b)
{
return a == b;
}
};
template <typename T>
struct compute_equal<T, true>
{
GLM_FUNC_QUALIFIER static bool call(T a, T b)
{
return std::memcmp(&a, &b, sizeof(T)) == 0;
}
};
}//namespace detail
}//namespace glm

View File

@ -29,36 +29,39 @@ namespace glm
template<typename genType>
GLM_FUNC_DECL genType abs(genType x);
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> abs(vecType<L, T, P> const & x);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> abs(vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/sign.xml">GLSL sign man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> sign(vecType<L, T, P> const & x);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> sign(vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/floor.xml">GLSL floor man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> floor(vecType<L, T, P> const & x);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> floor(vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/trunc.xml">GLSL trunc man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> trunc(vecType<L, T, P> const & x);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> trunc(vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/round.xml">GLSL round man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> round(vecType<L, T, P> const & x);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> round(vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/roundEven.xml">GLSL roundEven man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
/// @see <a href="http://developer.amd.com/documentation/articles/pages/New-Round-to-Even-Technique.aspx">New round to even technique</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> roundEven(vecType<L, T, P> const & x);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> roundEven(vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/ceil.xml">GLSL ceil man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> ceil(vecType<L, T, P> const & x);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> ceil(vec<L, T, P> const& x);
/// Return x - floor(x).
///
@ -104,8 +110,8 @@ namespace glm
template<typename genType>
GLM_FUNC_DECL genType fract(genType x);
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> fract(vecType<L, T, P> const & x);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> fract(vec<L, T, P> 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<typename genType>
GLM_FUNC_DECL genType mod(genType x, genType y);
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> mod(vecType<L, T, P> const & x, T y);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> mod(vec<L, T, P> const & x, T y);
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> mod(vecType<L, T, P> const & x, vecType<L, T, P> const & y);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> mod(vec<L, T, P> const & x, vec<L, T, P> 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<typename genType>
GLM_FUNC_DECL genType min(genType x, genType y);
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> min(vecType<L, T, P> const & x, T y);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> min(vec<L, T, P> const& x, T y);
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> min(vecType<L, T, P> const & x, vecType<L, T, P> const & y);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> min(vec<L, T, P> const& x, vec<L, T, P> const& y);
/// Returns y if x < y; otherwise, it returns x.
///
@ -159,11 +165,11 @@ namespace glm
template<typename genType>
GLM_FUNC_DECL genType max(genType x, genType y);
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> max(vecType<L, T, P> const & x, T y);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> max(vec<L, T, P> const& x, T y);
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> max(vecType<L, T, P> const & x, vecType<L, T, P> const & y);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> max(vec<L, T, P> const& x, vec<L, T, P> 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<typename genType>
GLM_FUNC_DECL genType clamp(genType x, genType minVal, genType maxVal);
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> clamp(vecType<L, T, P> const & x, T minVal, T maxVal);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> clamp(vec<L, T, P> const & x, T minVal, T maxVal);
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> clamp(vecType<L, T, P> const & x, vecType<L, T, P> const & minVal, vecType<L, T, P> const & maxVal);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> clamp(vec<L, T, P> const& x, vec<L, T, P> const& minVal, vec<L, T, P> 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 <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
/// 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<length_t L, typename T, typename U, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> mix(vecType<L, T, P> const & x, vecType<L, T, P> const & y, vecType<L, U, P> const & a);
template<length_t L, typename T, typename U, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> mix(vecType<L, T, P> const & x, vecType<L, T, P> const & y, U a);
template<typename genTypeT, typename genTypeU>
GLM_FUNC_DECL genTypeT mix(genTypeT x, genTypeT y, genTypeU a);
template<length_t L, typename T, typename U, precision P>
GLM_FUNC_DECL vec<L, T, P> mix(vec<L, T, P> const& x, vec<L, T, P> const& y, vec<L, U, P> const& a);
template<length_t L, typename T, typename U, precision P>
GLM_FUNC_DECL vec<L, T, P> mix(vec<L, T, P> const& x, vec<L, T, P> const& y, U a);
/// Returns 0.0 if x < edge, otherwise it returns 1.0 for each component of a genType.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/step.xml">GLSL step man page</a>
@ -241,17 +247,23 @@ namespace glm
/// Returns 0.0 if x < edge, otherwise it returns 1.0.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/step.xml">GLSL step man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<template<length_t, typename, precision> class vecType, length_t L, typename T, precision P>
GLM_FUNC_DECL vecType<L, T, P> step(T edge, vecType<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/step.xml">GLSL step man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<template<length_t, typename, precision> class vecType, length_t L, typename T, precision P>
GLM_FUNC_DECL vecType<L, T, P> step(vecType<L, T, P> const & edge, vecType<L, T, P> const & x);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> step(T edge, vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/step.xml">GLSL step man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> step(vec<L, T, P> const& edge, vec<L, T, P> 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<typename genType>
GLM_FUNC_DECL genType smoothstep(genType edge0, genType edge1, genType x);
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> smoothstep(T edge0, T edge1, vecType<L, T, P> const & x);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> smoothstep(T edge0, T edge1, vec<L, T, P> const& x);
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> smoothstep(vecType<L, T, P> const & edge0, vecType<L, T, P> const & edge1, vecType<L, T, P> const & x);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> smoothstep(vec<L, T, P> const& edge0, vec<L, T, P> const& edge1, vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/isnan.xml">GLSL isnan man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, bool, P> isnan(vecType<L, T, P> const & x);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, bool, P> isnan(vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/isinf.xml">GLSL isinf man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, bool, P> isinf(vecType<L, T, P> const & x);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, bool, P> isinf(vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/floatBitsToInt.xml">GLSL floatBitsToInt man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<template<length_t, typename, precision> class vecType, length_t L, precision P>
GLM_FUNC_DECL vecType<L, int, P> floatBitsToInt(vecType<L, float, P> const & v);
template<length_t L, precision P>
GLM_FUNC_DECL vec<L, int, P> floatBitsToInt(vec<L, float, P> const & v);
/// Returns a unsigned integer value representing
/// the encoding of a floating-point value. The floatingpoint
@ -335,8 +349,8 @@ namespace glm
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/floatBitsToUint.xml">GLSL floatBitsToUint man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<template<length_t, typename, precision> class vecType, length_t L, precision P>
GLM_FUNC_DECL vecType<L, uint, P> floatBitsToUint(vecType<L, float, P> const & v);
template<length_t L, precision P>
GLM_FUNC_DECL vec<L, uint, P> floatBitsToUint(vec<L, float, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/intBitsToFloat.xml">GLSL intBitsToFloat man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<template<length_t, typename, precision> class vecType, length_t L, precision P>
GLM_FUNC_DECL vecType<L, float, P> intBitsToFloat(vecType<L, int, P> const & v);
template<length_t L, precision P>
GLM_FUNC_DECL vec<L, float, P> intBitsToFloat(vec<L, int, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/uintBitsToFloat.xml">GLSL uintBitsToFloat man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<template<length_t, typename, precision> class vecType, length_t L, precision P>
GLM_FUNC_DECL vecType<L, float, P> uintBitsToFloat(vecType<L, uint, P> const & v);
template<length_t L, precision P>
GLM_FUNC_DECL vec<L, float, P> uintBitsToFloat(vec<L, uint, P> const & v);
/// Computes and returns a * b + c.
///
@ -387,7 +401,7 @@ namespace glm
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/fma.xml">GLSL fma man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<typename genType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/frexp.xml">GLSL frexp man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<typename genType, typename genIType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/ldexp.xml">GLSL ldexp man page</a>;
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<typename genType, typename genIType>
GLM_FUNC_DECL genType ldexp(genType const & x, genIType const & exp);
GLM_FUNC_DECL genType ldexp(genType const& x, genIType const& exp);
/// @}
}//namespace glm

View File

@ -107,53 +107,53 @@ namespace detail
}
};
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool Aligned>
template<length_t L, typename T, precision P, bool Aligned>
struct compute_abs_vector
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & x)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const & x)
{
return detail::functor1<L, T, T, P>::call(abs, x);
}
};
template<length_t L, typename T, typename U, precision P, template<length_t, typename, precision> class vecType, bool Aligned>
template<length_t L, typename T, typename U, precision P, bool Aligned>
struct compute_mix_vector
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & x, vecType<L, T, P> const & y, vecType<L, U, P> const & a)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& x, vec<L, T, P> const& y, vec<L, U, P> const& a)
{
GLM_STATIC_ASSERT(std::numeric_limits<U>::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'mix' only accept floating-point inputs for the interpolator a");
return vecType<L, T, P>(vecType<L, U, P>(x) + a * vecType<L, U, P>(y - x));
return vec<L, T, P>(vec<L, U, P>(x) + a * vec<L, U, P>(y - x));
}
};
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool Aligned>
struct compute_mix_vector<L, T, bool, P, vecType, Aligned>
template<length_t L, typename T, precision P, bool Aligned>
struct compute_mix_vector<L, T, bool, P, Aligned>
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & x, vecType<L, T, P> const & y, vecType<L, bool, P> const & a)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& x, vec<L, T, P> const& y, vec<L, bool, P> const& a)
{
vecType<L, T, P> Result;
vec<L, T, P> Result;
for(length_t i = 0; i < x.length(); ++i)
Result[i] = a[i] ? y[i] : x[i];
return Result;
}
};
template<length_t L, typename T, typename U, precision P, template<length_t, typename, precision> class vecType, bool Aligned>
template<length_t L, typename T, typename U, precision P, bool Aligned>
struct compute_mix_scalar
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & x, vecType<L, T, P> const & y, U const & a)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& x, vec<L, T, P> const& y, U const& a)
{
GLM_STATIC_ASSERT(std::numeric_limits<U>::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'mix' only accept floating-point inputs for the interpolator a");
return vecType<L, T, P>(vecType<L, U, P>(x) + a * vecType<L, U, P>(y - x));
return vec<L, T, P>(vec<L, U, P>(x) + a * vec<L, U, P>(y - x));
}
};
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool Aligned>
struct compute_mix_scalar<L, T, bool, P, vecType, Aligned>
template<length_t L, typename T, precision P, bool Aligned>
struct compute_mix_scalar<L, T, bool, P, Aligned>
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & x, vecType<L, T, P> const & y, bool const & a)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& x, vec<L, T, P> const& y, bool const& a)
{
return a ? y : x;
}
@ -162,7 +162,7 @@ namespace detail
template<typename T, typename U>
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<U>::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'mix' only accept floating-point inputs for the interpolator a");
@ -173,133 +173,133 @@ namespace detail
template<typename T>
struct compute_mix<T, bool>
{
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<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool isFloat, bool Aligned>
template<length_t L, typename T, precision P, bool isFloat, bool Aligned>
struct compute_sign
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & x)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& x)
{
return vecType<L, T, P>(glm::lessThan(vecType<L, T, P>(0), x)) - vecType<L, T, P>(glm::lessThan(x, vecType<L, T, P>(0)));
return vec<L, T, P>(glm::lessThan(vec<L, T, P>(0), x)) - vec<L, T, P>(glm::lessThan(x, vec<L, T, P>(0)));
}
};
# if GLM_ARCH == GLM_ARCH_X86
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool Aligned>
struct compute_sign<L, T, P, vecType, false, Aligned>
template<length_t L, typename T, precision P, bool Aligned>
struct compute_sign<L, T, P, false, Aligned>
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & x)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& x)
{
T const Shift(static_cast<T>(sizeof(T) * 8 - 1));
vecType<L, T, P> const y(vecType<L, typename make_unsigned<T>::type, P>(-x) >> typename make_unsigned<T>::type(Shift));
vec<L, T, P> const y(vec<L, typename make_unsigned<T>::type, P>(-x) >> typename make_unsigned<T>::type(Shift));
return (x >> Shift) | y;
}
};
# endif
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool Aligned>
template<length_t L, typename T, precision P, bool Aligned>
struct compute_floor
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & x)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& x)
{
return detail::functor1<L, T, T, P>::call(std::floor, x);
}
};
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool Aligned>
template<length_t L, typename T, precision P, bool Aligned>
struct compute_ceil
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & x)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& x)
{
return detail::functor1<L, T, T, P>::call(std::ceil, x);
}
};
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool Aligned>
template<length_t L, typename T, precision P, bool Aligned>
struct compute_fract
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & x)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& x)
{
return x - floor(x);
}
};
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool Aligned>
template<length_t L, typename T, precision P, bool Aligned>
struct compute_trunc
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & x)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& x)
{
return detail::functor1<L, T, T, P>::call(trunc, x);
}
};
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool Aligned>
template<length_t L, typename T, precision P, bool Aligned>
struct compute_round
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & x)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& x)
{
return detail::functor1<L, T, T, P>::call(round, x);
}
};
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool Aligned>
template<length_t L, typename T, precision P, bool Aligned>
struct compute_mod
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & a, vecType<L, T, P> const & b)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& a, vec<L, T, P> const& b)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'mod' only accept floating-point inputs. Include <glm/gtc/integer.hpp> for integer inputs.");
return a - b * floor(a / b);
}
};
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool Aligned>
template<length_t L, typename T, precision P, bool Aligned>
struct compute_min_vector
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & x, vecType<L, T, P> const & y)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& x, vec<L, T, P> const& y)
{
return detail::functor2<L, T, P>::call(min, x, y);
}
};
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool Aligned>
template<length_t L, typename T, precision P, bool Aligned>
struct compute_max_vector
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & x, vecType<L, T, P> const & y)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& x, vec<L, T, P> const& y)
{
return detail::functor2<L, T, P>::call(max, x, y);
}
};
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool Aligned>
template<length_t L, typename T, precision P, bool Aligned>
struct compute_clamp_vector
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & x, vecType<L, T, P> const & minVal, vecType<L, T, P> const & maxVal)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& x, vec<L, T, P> const& minVal, vec<L, T, P> const& maxVal)
{
return min(max(x, minVal), maxVal);
}
};
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool Aligned>
template<length_t L, typename T, precision P, bool Aligned>
struct compute_step_vector
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & edge, vecType<L, T, P> const & x)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& edge, vec<L, T, P> const& x)
{
return mix(vecType<L, T, P>(1), vecType<L, T, P>(0), glm::lessThan(x, edge));
return mix(vec<L, T, P>(1), vec<L, T, P>(0), glm::lessThan(x, edge));
}
};
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool Aligned>
template<length_t L, typename T, precision P, bool Aligned>
struct compute_smoothstep_vector
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & edge0, vecType<L, T, P> const & edge1, vecType<L, T, P> const & x)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& edge0, vec<L, T, P> const& edge1, vec<L, T, P> const& x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'step' only accept floating-point inputs");
vecType<L, T, P> const tmp(clamp((x - edge0) / (edge1 - edge0), static_cast<T>(0), static_cast<T>(1)));
vec<L, T, P> const tmp(clamp((x - edge0) / (edge1 - edge0), static_cast<T>(0), static_cast<T>(1)));
return tmp * tmp * (static_cast<T>(3) - static_cast<T>(2) * tmp);
}
};
@ -311,10 +311,10 @@ namespace detail
return detail::compute_abs<genFIType, std::numeric_limits<genFIType>::is_signed>::call(x);
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> abs(vecType<L, T, P> const & x)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> abs(vec<L, T, P> const & x)
{
return detail::compute_abs_vector<L, T, P, vecType, detail::is_aligned<P>::value>::call(x);
return detail::compute_abs_vector<L, T, P, detail::is_aligned<P>::value>::call(x);
}
// sign
@ -326,40 +326,40 @@ namespace detail
std::numeric_limits<genFIType>::is_iec559 || (std::numeric_limits<genFIType>::is_signed && std::numeric_limits<genFIType>::is_integer),
"'sign' only accept signed inputs");
return detail::compute_sign<1, genFIType, defaultp, vec, std::numeric_limits<genFIType>::is_iec559, highp>::call(vec<1, genFIType>(x)).x;
return detail::compute_sign<1, genFIType, defaultp, std::numeric_limits<genFIType>::is_iec559, highp>::call(vec<1, genFIType>(x)).x;
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> sign(vecType<L, T, P> const & x)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> sign(vec<L, T, P> const& x)
{
GLM_STATIC_ASSERT(
std::numeric_limits<T>::is_iec559 || (std::numeric_limits<T>::is_signed && std::numeric_limits<T>::is_integer),
"'sign' only accept signed inputs");
return detail::compute_sign<L, T, P, vecType, std::numeric_limits<T>::is_iec559, detail::is_aligned<P>::value>::call(x);
return detail::compute_sign<L, T, P, std::numeric_limits<T>::is_iec559, detail::is_aligned<P>::value>::call(x);
}
// floor
using ::std::floor;
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> floor(vecType<L, T, P> const & x)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> floor(vec<L, T, P> const& x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'floor' only accept floating-point inputs.");
return detail::compute_floor<L, T, P, vecType, detail::is_aligned<P>::value>::call(x);
return detail::compute_floor<L, T, P, detail::is_aligned<P>::value>::call(x);
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> trunc(vecType<L, T, P> const & x)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> trunc(vec<L, T, P> const& x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'trunc' only accept floating-point inputs");
return detail::compute_trunc<L, T, P, vecType, detail::is_aligned<P>::value>::call(x);
return detail::compute_trunc<L, T, P, detail::is_aligned<P>::value>::call(x);
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> round(vecType<L, T, P> const & x)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> round(vec<L, T, P> const& x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'round' only accept floating-point inputs");
return detail::compute_round<L, T, P, vecType, detail::is_aligned<P>::value>::call(x);
return detail::compute_round<L, T, P, detail::is_aligned<P>::value>::call(x);
}
/*
@ -405,8 +405,8 @@ namespace detail
//}
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> roundEven(vecType<L, T, P> const & x)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> roundEven(vec<L, T, P> const & x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'roundEven' only accept floating-point inputs");
return detail::functor1<L, T, T, P>::call(roundEven, x);
@ -414,11 +414,11 @@ namespace detail
// ceil
using ::std::ceil;
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> ceil(vecType<L, T, P> const & x)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> ceil(vec<L, T, P> const & x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'ceil' only accept floating-point inputs");
return detail::compute_ceil<L, T, P, vecType, detail::is_aligned<P>::value>::call(x);
return detail::compute_ceil<L, T, P, detail::is_aligned<P>::value>::call(x);
}
// fract
@ -428,11 +428,11 @@ namespace detail
return fract(vec<1, genType>(x)).x;
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> fract(vecType<L, T, P> const & x)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> fract(vec<L, T, P> const & x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'fract' only accept floating-point inputs");
return detail::compute_fract<L, T, P, vecType, detail::is_aligned<P>::value>::call(x);
return detail::compute_fract<L, T, P, detail::is_aligned<P>::value>::call(x);
}
// mod
@ -448,16 +448,16 @@ namespace detail
# endif
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> mod(vecType<L, T, P> const & x, T y)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> mod(vec<L, T, P> const & x, T y)
{
return detail::compute_mod<L, T, P, vecType, detail::is_aligned<P>::value>::call(x, vecType<L, T, P>(y));
return detail::compute_mod<L, T, P, detail::is_aligned<P>::value>::call(x, vec<L, T, P>(y));
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> mod(vecType<L, T, P> const & x, vecType<L, T, P> const & y)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> mod(vec<L, T, P> const& x, vec<L, T, P> const& y)
{
return detail::compute_mod<L, T, P, vecType, detail::is_aligned<P>::value>::call(x, y);
return detail::compute_mod<L, T, P, detail::is_aligned<P>::value>::call(x, y);
}
// modf
@ -511,31 +511,31 @@ namespace detail
//CHAR_BIT - 1)));
// min
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> min(vecType<L, T, P> const & a, T b)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> min(vec<L, T, P> const & a, T b)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer || GLM_UNRESTRICTED_GENTYPE, "'min' only accept floating-point or integer inputs");
return detail::compute_min_vector<L, T, P, vecType, detail::is_aligned<P>::value>::call(a, vecType<L, T, P>(b));
return detail::compute_min_vector<L, T, P, detail::is_aligned<P>::value>::call(a, vec<L, T, P>(b));
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> min(vecType<L, T, P> const & a, vecType<L, T, P> const & b)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> min(vec<L, T, P> const& a, vec<L, T, P> const& b)
{
return detail::compute_min_vector<L, T, P, vecType, detail::is_aligned<P>::value>::call(a, b);
return detail::compute_min_vector<L, T, P, detail::is_aligned<P>::value>::call(a, b);
}
// max
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> max(vecType<L, T, P> const & a, T b)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> max(vec<L, T, P> const& a, T b)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer || GLM_UNRESTRICTED_GENTYPE, "'max' only accept floating-point or integer inputs");
return detail::compute_max_vector<L, T, P, vecType, detail::is_aligned<P>::value>::call(a, vecType<L, T, P>(b));
return detail::compute_max_vector<L, T, P, detail::is_aligned<P>::value>::call(a, vec<L, T, P>(b));
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> max(vecType<L, T, P> const & a, vecType<L, T, P> const & b)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> max(vec<L, T, P> const& a, vec<L, T, P> const & b)
{
return detail::compute_max_vector<L, T, P, vecType, detail::is_aligned<P>::value>::call(a, b);
return detail::compute_max_vector<L, T, P, detail::is_aligned<P>::value>::call(a, b);
}
// clamp
@ -546,18 +546,18 @@ namespace detail
return min(max(x, minVal), maxVal);
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> clamp(vecType<L, T, P> const & x, T minVal, T maxVal)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> clamp(vec<L, T, P> const & x, T minVal, T maxVal)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer || GLM_UNRESTRICTED_GENTYPE, "'clamp' only accept floating-point or integer inputs");
return detail::compute_clamp_vector<L, T, P, vecType, detail::is_aligned<P>::value>::call(x, vecType<L, T, P>(minVal), vecType<L, T, P>(maxVal));
return detail::compute_clamp_vector<L, T, P, detail::is_aligned<P>::value>::call(x, vec<L, T, P>(minVal), vec<L, T, P>(maxVal));
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> clamp(vecType<L, T, P> const & x, vecType<L, T, P> const & minVal, vecType<L, T, P> const & maxVal)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> clamp(vec<L, T, P> const& x, vec<L, T, P> const& minVal, vec<L, T, P> const& maxVal)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer || GLM_UNRESTRICTED_GENTYPE, "'clamp' only accept floating-point or integer inputs");
return detail::compute_clamp_vector<L, T, P, vecType, detail::is_aligned<P>::value>::call(x, minVal, maxVal);
return detail::compute_clamp_vector<L, T, P, detail::is_aligned<P>::value>::call(x, minVal, maxVal);
}
template<typename genTypeT, typename genTypeU>
@ -566,16 +566,16 @@ namespace detail
return detail::compute_mix<genTypeT, genTypeU>::call(x, y, a);
}
template<length_t L, typename T, typename U, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> mix(vecType<L, T, P> const & x, vecType<L, T, P> const & y, U a)
template<length_t L, typename T, typename U, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> mix(vec<L, T, P> const& x, vec<L, T, P> const& y, U a)
{
return detail::compute_mix_scalar<L, T, U, P, vecType, detail::is_aligned<P>::value>::call(x, y, a);
return detail::compute_mix_scalar<L, T, U, P, detail::is_aligned<P>::value>::call(x, y, a);
}
template<length_t L, typename T, typename U, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> mix(vecType<L, T, P> const & x, vecType<L, T, P> const & y, vecType<L, U, P> const & a)
template<length_t L, typename T, typename U, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> mix(vec<L, T, P> const& x, vec<L, T, P> const& y, vec<L, U, P> const& a)
{
return detail::compute_mix_vector<L, T, U, P, vecType, detail::is_aligned<P>::value>::call(x, y, a);
return detail::compute_mix_vector<L, T, U, P, detail::is_aligned<P>::value>::call(x, y, a);
}
// step
@ -585,16 +585,16 @@ namespace detail
return mix(static_cast<genType>(1), static_cast<genType>(0), glm::lessThan(x, edge));
}
template<template<length_t, typename, precision> class vecType, length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vecType<L, T, P> step(T edge, vecType<L, T, P> const & x)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> step(T edge, vec<L, T, P> const& x)
{
return detail::compute_step_vector<L, T, P, vecType, detail::is_aligned<P>::value>::call(vecType<L, T, P>(edge), x);
return detail::compute_step_vector<L, T, P, detail::is_aligned<P>::value>::call(vec<L, T, P>(edge), x);
}
template<template<length_t, typename, precision> class vecType, length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vecType<L, T, P> step(vecType<L, T, P> const & edge, vecType<L, T, P> const & x)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> step(vec<L, T, P> const& edge, vec<L, T, P> const& x)
{
return detail::compute_step_vector<L, T, P, vecType, detail::is_aligned<P>::value>::call(edge, x);
return detail::compute_step_vector<L, T, P, detail::is_aligned<P>::value>::call(edge, x);
}
// smoothstep
@ -607,16 +607,16 @@ namespace detail
return tmp * tmp * (genType(3) - genType(2) * tmp);
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> smoothstep(T edge0, T edge1, vecType<L, T, P> const & x)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> smoothstep(T edge0, T edge1, vec<L, T, P> const& x)
{
return detail::compute_smoothstep_vector<L, T, P, vecType, detail::is_aligned<P>::value>::call(vecType<L, T, P>(edge0), vecType<L, T, P>(edge1), x);
return detail::compute_smoothstep_vector<L, T, P, detail::is_aligned<P>::value>::call(vec<L, T, P>(edge0), vec<L, T, P>(edge1), x);
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> smoothstep(vecType<L, T, P> const & edge0, vecType<L, T, P> const & edge1, vecType<L, T, P> const & x)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> smoothstep(vec<L, T, P> const& edge0, vec<L, T, P> const& edge1, vec<L, T, P> const& x)
{
return detail::compute_smoothstep_vector<L, T, P, vecType, detail::is_aligned<P>::value>::call(edge0, edge1, x);
return detail::compute_smoothstep_vector<L, T, P, detail::is_aligned<P>::value>::call(edge0, edge1, x);
}
# if GLM_HAS_CXX11_STL
@ -647,8 +647,8 @@ namespace detail
}
# endif
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, bool, P> isnan(vecType<L, T, P> const & x)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, bool, P> isnan(vec<L, T, P> const& x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isnan' only accept floating-point inputs");
@ -686,15 +686,15 @@ namespace detail
}
# endif
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, bool, P> isinf(vecType<L, T, P> const & x)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, bool, P> isinf(vec<L, T, P> const& x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isnan' only accept floating-point inputs");
return detail::functor1<L, bool, T, P>::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<template<length_t, typename, precision> class vecType, length_t L, precision P>
GLM_FUNC_QUALIFIER vecType<L, int, P> floatBitsToInt(vecType<L, float, P> const & v)
template<length_t L, precision P>
GLM_FUNC_QUALIFIER vec<L, int, P> floatBitsToInt(vec<L, float, P> const& v)
{
return reinterpret_cast<vecType<L, int, P>&>(const_cast<vecType<L, float, P>&>(v));
return reinterpret_cast<vec<L, int, P>&>(const_cast<vec<L, float, P>&>(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<template<length_t, typename, precision> class vecType, length_t L, precision P>
GLM_FUNC_QUALIFIER vecType<L, uint, P> floatBitsToUint(vecType<L, float, P> const & v)
template<length_t L, precision P>
GLM_FUNC_QUALIFIER vec<L, uint, P> floatBitsToUint(vec<L, float, P> const& v)
{
return reinterpret_cast<vecType<L, uint, P>&>(const_cast<vecType<L, float, P>&>(v));
return reinterpret_cast<vec<L, uint, P>&>(const_cast<vec<L, float, P>&>(v));
}
GLM_FUNC_QUALIFIER float intBitsToFloat(int const & v)
@ -745,13 +745,13 @@ namespace detail
return u.out;
}
template<template<length_t, typename, precision> class vecType, length_t L, precision P>
GLM_FUNC_QUALIFIER vecType<L, float, P> intBitsToFloat(vecType<L, int, P> const & v)
template<length_t L, precision P>
GLM_FUNC_QUALIFIER vec<L, float, P> intBitsToFloat(vec<L, int, P> const& v)
{
return reinterpret_cast<vecType<L, float, P>&>(const_cast<vecType<L, int, P>&>(v));
return reinterpret_cast<vec<L, float, P>&>(const_cast<vec<L, int, P>&>(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<template<length_t, typename, precision> class vecType, length_t L, precision P>
GLM_FUNC_QUALIFIER vecType<L, float, P> uintBitsToFloat(vecType<L, uint, P> const & v)
template<length_t L, precision P>
GLM_FUNC_QUALIFIER vec<L, float, P> uintBitsToFloat(vec<L, uint, P> const& v)
{
return reinterpret_cast<vecType<L, float, P>&>(const_cast<vecType<L, uint, P>&>(v));
return reinterpret_cast<vec<L, float, P>&>(const_cast<vec<L, uint, P>&>(v));
}
template<typename genType>
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<typename T, precision P>
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<T>::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'frexp' only accept floating-point inputs");
@ -793,7 +793,7 @@ namespace detail
}
template<typename T, precision P>
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<T>::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'frexp' only accept floating-point inputs");
@ -803,7 +803,7 @@ namespace detail
}
template<typename T, precision P>
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<T>::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'frexp' only accept floating-point inputs");
@ -814,7 +814,7 @@ namespace detail
}
template<typename T, precision P>
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<T>::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'frexp' only accept floating-point inputs");
@ -826,7 +826,7 @@ namespace detail
}
template<typename genType>
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<genType>::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'ldexp' only accept floating-point inputs");
@ -834,7 +834,7 @@ namespace detail
}
template<typename T, precision P>
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<T>::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'ldexp' only accept floating-point inputs");
@ -843,7 +843,7 @@ namespace detail
}
template<typename T, precision P>
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<T>::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'ldexp' only accept floating-point inputs");
@ -853,7 +853,7 @@ namespace detail
}
template<typename T, precision P>
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<T>::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'ldexp' only accept floating-point inputs");
@ -864,7 +864,7 @@ namespace detail
}
template<typename T, precision P>
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<T>::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'ldexp' only accept floating-point inputs");

View File

@ -11,7 +11,7 @@ namespace glm{
namespace detail
{
template<precision P>
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<precision P>
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<precision P>
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<precision P>
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<precision P>
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<precision P>
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<precision P>
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<precision P>
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<precision P>
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<precision P>
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<precision P>
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<precision P>
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<precision P>
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<precision P>
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<precision P>
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<precision P>
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<precision P>
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<precision P>
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)
{

View File

@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/pow.xml">GLSL pow man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.2 Exponential Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> pow(vecType<L, T, P> const & base, vecType<L, T, P> const & exponent);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> pow(vec<L, T, P> const & base, vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/exp.xml">GLSL exp man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.2 Exponential Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> exp(vecType<L, T, P> const & v);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> exp(vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/log.xml">GLSL log man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.2 Exponential Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> log(vecType<L, T, P> const & v);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> log(vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/exp2.xml">GLSL exp2 man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.2 Exponential Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> exp2(vecType<L, T, P> const & v);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> exp2(vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/log2.xml">GLSL log2 man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.2 Exponential Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> log2(vecType<L, T, P> const & v);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> log2(vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/sqrt.xml">GLSL sqrt man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.2 Exponential Functions</a>
//template<typename genType>
//GLM_FUNC_DECL genType sqrt(genType const & x);
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> sqrt(vecType<L, T, P> const & v);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> sqrt(vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/inversesqrt.xml">GLSL inversesqrt man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.2 Exponential Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> inversesqrt(vecType<L, T, P> const & v);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> inversesqrt(vec<L, T, P> const & v);
/// @}
}//namespace glm

View File

@ -20,7 +20,7 @@ namespace detail
}
# endif
template<length_t L, typename T, precision P, template<length_t, class, precision> class vecType, bool isFloat, bool Aligned>
template<length_t L, typename T, precision P, bool isFloat, bool Aligned>
struct compute_log2
{
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& v)
@ -66,24 +66,24 @@ namespace detail
// pow
using std::pow;
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> pow(vecType<L, T, P> const & base, vecType<L, T, P> const& exponent)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> pow(vec<L, T, P> const & base, vec<L, T, P> const& exponent)
{
return detail::functor2<L, T, P>::call(pow, base, exponent);
}
// exp
using std::exp;
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> exp(vecType<L, T, P> const& x)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> exp(vec<L, T, P> const& x)
{
return detail::functor1<L, T, T, P>::call(exp, x);
}
// log
using std::log;
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> log(vecType<L, T, P> const& x)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> log(vec<L, T, P> const& x)
{
return detail::functor1<L, T, T, P>::call(log, x);
}
@ -97,8 +97,8 @@ namespace detail
return std::exp(static_cast<genType>(0.69314718055994530941723212145818) * x);
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> exp2(vecType<L, T, P> const& x)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> exp2(vec<L, T, P> const& x)
{
return detail::functor1<L, T, T, P>::call(exp2, x);
}
@ -110,16 +110,16 @@ namespace detail
return log2(vec<1, genType>(x)).x;
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> log2(vecType<L, T, P> const& x)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> log2(vec<L, T, P> const& x)
{
return detail::compute_log2<L, T, P, vecType, std::numeric_limits<T>::is_iec559, detail::is_aligned<P>::value>::call(x);
return detail::compute_log2<L, T, P, std::numeric_limits<T>::is_iec559, detail::is_aligned<P>::value>::call(x);
}
// sqrt
using std::sqrt;
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> sqrt(vecType<L, T, P> const& x)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> sqrt(vec<L, T, P> const& x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'sqrt' only accept floating-point inputs");
return detail::compute_sqrt<L, T, P, detail::is_aligned<P>::value>::call(x);
@ -132,8 +132,8 @@ namespace detail
return static_cast<genType>(1) / sqrt(x);
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> inversesqrt(vecType<L, T, P> const& x)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> inversesqrt(vec<L, T, P> const& x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'inversesqrt' only accept floating-point inputs");
return detail::compute_inversesqrt<L, T, P, detail::is_aligned<P>::value>::call(x);

View File

@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/length.xml">GLSL length man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL T length(
vecType<L, T, P> const& x);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL T length(vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/distance.xml">GLSL distance man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL T distance(
vecType<L, T, P> const& p0,
vecType<L, T, P> const& p1);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL T distance(vec<L, T, P> const& p0, vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/dot.xml">GLSL dot man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
template<length_t L, typename T, precision P>
GLM_FUNC_DECL T dot(
vec<L, T, P> const & x,
vec<L, T, P> const & y);
GLM_FUNC_DECL T dot(vec<L, T, P> const & x, vec<L, T, P> const & y);
/// Returns the cross product of x and y.
///
/// @tparam valType Floating-point scalar types.
/// @tparam T Floating-point scalar types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/cross.xml">GLSL cross man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
template<typename T, precision P>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/normalize.xml">GLSL normalize man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> normalize(
vecType<L, T, P> const& x);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> normalize(vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/faceforward.xml">GLSL faceforward man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> faceforward(
vecType<L, T, P> const& N,
vecType<L, T, P> const& I,
vecType<L, T, P> const& Nref);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> faceforward(
vec<L, T, P> const& N,
vec<L, T, P> const& I,
vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/reflect.xml">GLSL reflect man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
template<typename genType>
GLM_FUNC_DECL genType reflect(
genType const & I,
genType const & N);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> reflect(
vec<L, T, P> const& I,
vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/refract.xml">GLSL refract man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> refract(
vecType<L, T, P> const& I,
vecType<L, T, P> const& N,
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> refract(
vec<L, T, P> const& I,
vec<L, T, P> const& N,
T eta);
/// @}

View File

@ -10,19 +10,19 @@
namespace glm{
namespace detail
{
template<template<length_t, typename, precision> class vecType, length_t L, typename T, precision P, bool Aligned>
template<length_t L, typename T, precision P, bool Aligned>
struct compute_length
{
GLM_FUNC_QUALIFIER static T call(vecType<L, T, P> const & v)
GLM_FUNC_QUALIFIER static T call(vec<L, T, P> const& v)
{
return sqrt(dot(v, v));
}
};
template<template<length_t, typename, precision> class vecType, length_t L, typename T, precision P, bool Aligned>
template<length_t L, typename T, precision P, bool Aligned>
struct compute_distance
{
GLM_FUNC_QUALIFIER static T call(vecType<L, T, P> const & p0, vecType<L, T, P> const & p1)
GLM_FUNC_QUALIFIER static T call(vec<L, T, P> const& p0, vec<L, T, P> const& p1)
{
return length(p1 - p0);
}
@ -34,7 +34,7 @@ namespace detail
template<typename T, precision P, bool Aligned>
struct compute_dot<vec<1, T, P>, 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<typename T, precision P, bool Aligned>
struct compute_dot<vec<2, T, P>, 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<typename T, precision P, bool Aligned>
struct compute_dot<vec<3, T, P>, 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<typename T, precision P, bool Aligned>
struct compute_dot<vec<4, T, P>, 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<typename T, precision P, bool Aligned>
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<T>::is_iec559, "'cross' accepts only floating-point inputs");
@ -84,10 +84,10 @@ namespace detail
}
};
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool Aligned>
template<length_t L, typename T, precision P, bool Aligned>
struct compute_normalize
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & v)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& v)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'normalize' accepts only floating-point inputs");
@ -95,10 +95,10 @@ namespace detail
}
};
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool Aligned>
template<length_t L, typename T, precision P, bool Aligned>
struct compute_faceforward
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & N, vecType<L, T, P> const & I, vecType<L, T, P> const & Nref)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& N, vec<L, T, P> const& I, vec<L, T, P> const& Nref)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'normalize' accepts only floating-point inputs");
@ -106,19 +106,19 @@ namespace detail
}
};
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool Aligned>
template<length_t L, typename T, precision P, bool Aligned>
struct compute_reflect
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & I, vecType<L, T, P> const & N)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& I, vec<L, T, P> const& N)
{
return I - N * dot(N, I) * static_cast<T>(2);
}
};
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool Aligned>
template<length_t L, typename T, precision P, bool Aligned>
struct compute_refract
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & I, vecType<L, T, P> const & N, T eta)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& I, vec<L, T, P> const& N, T eta)
{
T const dotValue(dot(N, I));
T const k(static_cast<T>(1) - eta * eta * (static_cast<T>(1) - dotValue * dotValue));
@ -136,27 +136,27 @@ namespace detail
return abs(x);
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER T length(vecType<L, T, P> const & v)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER T length(vec<L, T, P> const& v)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'length' accepts only floating-point inputs");
return detail::compute_length<vecType, L, T, P, detail::is_aligned<P>::value>::call(v);
return detail::compute_length<L, T, P, detail::is_aligned<P>::value>::call(v);
}
// distance
template<typename genType>
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<genType>::is_iec559, "'distance' accepts only floating-point inputs");
return length(p1 - p0);
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER T distance(vecType<L, T, P> const & p0, vecType<L, T, P> const & p1)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER T distance(vec<L, T, P> const& p0, vec<L, T, P> const& p1)
{
return detail::compute_distance<vecType, L, T, P, detail::is_aligned<P>::value>::call(p0, p1);
return detail::compute_distance<L, T, P, detail::is_aligned<P>::value>::call(p0, p1);
}
// dot
@ -168,14 +168,14 @@ namespace detail
}
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER T dot(vec<L, T, P> const & x, vec<L, T, P> const & y)
GLM_FUNC_QUALIFIER T dot(vec<L, T, P> const& x, vec<L, T, P> const& y)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'dot' accepts only floating-point inputs");
return detail::compute_dot<vec<L, T, P>, T, detail::is_aligned<P>::value>::call(x, y);
}
template<typename T, precision P>
GLM_FUNC_QUALIFIER T dot(tquat<T, P> const & x, tquat<T, P> const & y)
GLM_FUNC_QUALIFIER T dot(tquat<T, P> const& x, tquat<T, P> const& y)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'dot' accepts only floating-point inputs");
return detail::compute_dot<tquat<T, P>, T, detail::is_aligned<P>::value>::call(x, y);
@ -183,57 +183,57 @@ namespace detail
// cross
template<typename T, precision P>
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<T, P, detail::is_aligned<P>::value>::call(x, y);
}
// normalize
template<typename genType>
GLM_FUNC_QUALIFIER genType normalize(genType const & x)
GLM_FUNC_QUALIFIER genType normalize(genType const& x)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'normalize' accepts only floating-point inputs");
return x < genType(0) ? genType(-1) : genType(1);
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> normalize(vecType<L, T, P> const & x)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> normalize(vec<L, T, P> const& x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'normalize' accepts only floating-point inputs");
return detail::compute_normalize<L, T, P, vecType, detail::is_aligned<P>::value>::call(x);
return detail::compute_normalize<L, T, P, detail::is_aligned<P>::value>::call(x);
}
// faceforward
template<typename genType>
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<genType>(0) ? N : -N;
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> faceforward(vecType<L, T, P> const & N, vecType<L, T, P> const & I, vecType<L, T, P> const & Nref)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> faceforward(vec<L, T, P> const& N, vec<L, T, P> const& I, vec<L, T, P> const& Nref)
{
return detail::compute_faceforward<L, T, P, vecType, detail::is_aligned<P>::value>::call(N, I, Nref);
return detail::compute_faceforward<L, T, P, detail::is_aligned<P>::value>::call(N, I, Nref);
}
// reflect
template<typename genType>
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<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> reflect(vecType<L, T, P> const & I, vecType<L, T, P> const & N)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> reflect(vec<L, T, P> const& I, vec<L, T, P> const& N)
{
return detail::compute_reflect<L, T, P, vecType, detail::is_aligned<P>::value>::call(I, N);
return detail::compute_reflect<L, T, P, detail::is_aligned<P>::value>::call(I, N);
}
// refract
template<typename genType>
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<genType>::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<genType>(k >= static_cast<genType>(0));
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> refract(vecType<L, T, P> const & I, vecType<L, T, P> const & N, T eta)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> refract(vec<L, T, P> const& I, vec<L, T, P> const& N, T eta)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'refract' accepts only floating-point inputs");
return detail::compute_refract<L, T, P, vecType, detail::is_aligned<P>::value>::call(I, N, eta);
return detail::compute_refract<L, T, P, detail::is_aligned<P>::value>::call(I, N, eta);
}
}//namespace glm

View File

@ -9,7 +9,7 @@ namespace glm{
namespace detail
{
template<precision P>
struct compute_length<vec, 4, float, P, true>
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<precision P>
struct compute_distance<vec, 4, float, P, true>
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<precision P>
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<precision P>
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<precision P>
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<precision P>
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)
{

View File

@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/uaddCarry.xml">GLSL uaddCarry man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, uint, P> uaddCarry(
vecType<L, uint, P> const & x,
vecType<L, uint, P> const & y,
vecType<L, uint, P> & carry);
template<length_t L, precision P>
GLM_FUNC_DECL vec<L, uint, P> uaddCarry(
vec<L, uint, P> const & x,
vec<L, uint, P> const & y,
vec<L, uint, P> & 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/usubBorrow.xml">GLSL usubBorrow man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, uint, P> usubBorrow(
vecType<L, uint, P> const & x,
vecType<L, uint, P> const & y,
vecType<L, uint, P> & borrow);
template<length_t L, precision P>
GLM_FUNC_DECL vec<L, uint, P> usubBorrow(
vec<L, uint, P> const & x,
vec<L, uint, P> const & y,
vec<L, uint, P> & 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/umulExtended.xml">GLSL umulExtended man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
template<length_t L, precision P>
GLM_FUNC_DECL void umulExtended(
vecType<L, uint, P> const & x,
vecType<L, uint, P> const & y,
vecType<L, uint, P> & msb,
vecType<L, uint, P> & lsb);
vec<L, uint, P> const & x,
vec<L, uint, P> const & y,
vec<L, uint, P> & msb,
vec<L, uint, P> & 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/imulExtended.xml">GLSL imulExtended man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
template<length_t L, precision P>
GLM_FUNC_DECL void imulExtended(
vecType<L, int, P> const & x,
vecType<L, int, P> const & y,
vecType<L, int, P> & msb,
vecType<L, int, P> & lsb);
vec<L, int, P> const & x,
vec<L, int, P> const & y,
vec<L, int, P> & msb,
vec<L, int, P> & 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/bitfieldExtract.xml">GLSL bitfieldExtract man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> bitfieldExtract(
vecType<L, T, P> const& Value,
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> bitfieldExtract(
vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/bitfieldInsert.xml">GLSL bitfieldInsert man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> bitfieldInsert(
vecType<L, T, P> const& Base,
vecType<L, T, P> const& Insert,
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> bitfieldInsert(
vec<L, T, P> const& Base,
vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/bitfieldReverse.xml">GLSL bitfieldReverse man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> bitfieldReverse(vecType<L, T, P> const & v);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> bitfieldReverse(vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/bitCount.xml">GLSL bitCount man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/bitCount.xml">GLSL bitCount man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, int, P> bitCount(vecType<L, T, P> const & v);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, int, P> bitCount(vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/findLSB.xml">GLSL findLSB man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/findLSB.xml">GLSL findLSB man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, int, P> findLSB(vecType<L, T, P> const & v);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, int, P> findLSB(vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/findMSB.xml">GLSL findMSB man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/findMSB.xml">GLSL findMSB man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.8 Integer Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, int, P> findMSB(vecType<L, T, P> const & v);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, int, P> findMSB(vec<L, T, P> const & v);
/// @}
}//namespace glm

View File

@ -27,40 +27,40 @@ namespace detail
template<typename T>
GLM_FUNC_QUALIFIER T mask(T Bits)
{
return Bits >= sizeof(T) * 8 ? ~static_cast<T>(0) : (static_cast<T>(1) << Bits) - static_cast<T>(1);
return Bits >= static_cast<T>(sizeof(T) * 8) ? ~static_cast<T>(0) : (static_cast<T>(1) << Bits) - static_cast<T>(1);
}
template<length_t L, typename T, glm::precision P, template<length_t, typename, precision> class vecType, bool Aligned, bool EXEC>
template<length_t L, typename T, glm::precision P, bool Aligned, bool EXEC>
struct compute_bitfieldReverseStep
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const& v, T, T)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& v, T, T)
{
return v;
}
};
template<length_t L, typename T, glm::precision P, template<length_t, typename, precision> class vecType, bool Aligned>
struct compute_bitfieldReverseStep<L, T, P, vecType, Aligned, true>
template<length_t L, typename T, glm::precision P, bool Aligned>
struct compute_bitfieldReverseStep<L, T, P, Aligned, true>
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const& v, T Mask, T Shift)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& v, T Mask, T Shift)
{
return (v & Mask) << Shift | (v & (~Mask)) >> Shift;
}
};
template<length_t L, typename T, glm::precision P, template<length_t, typename, precision> class vecType, bool Aligned, bool EXEC>
template<length_t L, typename T, glm::precision P, bool Aligned, bool EXEC>
struct compute_bitfieldBitCountStep
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const& v, T, T)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& v, T, T)
{
return v;
}
};
template<length_t L, typename T, glm::precision P, template<length_t, typename, precision> class vecType, bool Aligned>
struct compute_bitfieldBitCountStep<L, T, P, vecType, Aligned, true>
template<length_t L, typename T, glm::precision P, bool Aligned>
struct compute_bitfieldBitCountStep<L, T, P, Aligned, true>
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const& v, T Mask, T Shift)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> 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<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool EXEC = true>
template<length_t L, typename T, precision P, bool EXEC = true>
struct compute_findMSB_step_vec
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & x, T Shift)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& x, T Shift)
{
return x | (x >> Shift);
}
};
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
struct compute_findMSB_step_vec<L, T, P, vecType, false>
template<length_t L, typename T, precision P>
struct compute_findMSB_step_vec<L, T, P, false>
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const& x, T)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& x, T)
{
return x;
}
};
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, int>
template<length_t L, typename T, precision P, int>
struct compute_findMSB_vec
{
GLM_FUNC_QUALIFIER static vecType<L, int, P> call(vecType<L, T, P> const& v)
GLM_FUNC_QUALIFIER static vec<L, int, P> call(vec<L, T, P> const& v)
{
vecType<L, T, P> x(v);
x = compute_findMSB_step_vec<L, T, P, vecType, sizeof(T) * 8 >= 8>::call(x, static_cast<T>( 1));
x = compute_findMSB_step_vec<L, T, P, vecType, sizeof(T) * 8 >= 8>::call(x, static_cast<T>( 2));
x = compute_findMSB_step_vec<L, T, P, vecType, sizeof(T) * 8 >= 8>::call(x, static_cast<T>( 4));
x = compute_findMSB_step_vec<L, T, P, vecType, sizeof(T) * 8 >= 16>::call(x, static_cast<T>( 8));
x = compute_findMSB_step_vec<L, T, P, vecType, sizeof(T) * 8 >= 32>::call(x, static_cast<T>(16));
x = compute_findMSB_step_vec<L, T, P, vecType, sizeof(T) * 8 >= 64>::call(x, static_cast<T>(32));
return vecType<L, int, P>(sizeof(T) * 8 - 1) - glm::bitCount(~x);
vec<L, T, P> x(v);
x = compute_findMSB_step_vec<L, T, P, sizeof(T) * 8 >= 8>::call(x, static_cast<T>( 1));
x = compute_findMSB_step_vec<L, T, P, sizeof(T) * 8 >= 8>::call(x, static_cast<T>( 2));
x = compute_findMSB_step_vec<L, T, P, sizeof(T) * 8 >= 8>::call(x, static_cast<T>( 4));
x = compute_findMSB_step_vec<L, T, P, sizeof(T) * 8 >= 16>::call(x, static_cast<T>( 8));
x = compute_findMSB_step_vec<L, T, P, sizeof(T) * 8 >= 32>::call(x, static_cast<T>(16));
x = compute_findMSB_step_vec<L, T, P, sizeof(T) * 8 >= 64>::call(x, static_cast<T>(32));
return vec<L, int, P>(sizeof(T) * 8 - 1) - glm::bitCount(~x);
}
};
@ -147,10 +147,10 @@ namespace detail
return IsNotNull ? int(Result) : -1;
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
struct compute_findMSB_vec<L, T, P, vecType, 32>
template<length_t L, typename T, precision P>
struct compute_findMSB_vec<L, T, P, 32>
{
GLM_FUNC_QUALIFIER static vecType<L, int, P> call(vecType<L, T, P> const& x)
GLM_FUNC_QUALIFIER static vec<L, int, P> call(vec<L, T, P> const& x)
{
return detail::functor1<L, int, T, P>::call(compute_findMSB_32, x);
}
@ -165,10 +165,10 @@ namespace detail
return IsNotNull ? int(Result) : -1;
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
struct compute_findMSB_vec<L, T, P, vecType, 64>
template<length_t L, typename T, precision P>
struct compute_findMSB_vec<L, T, P, 64>
{
GLM_FUNC_QUALIFIER static vecType<L, int, P> call(vecType<L, T, P> const& x)
GLM_FUNC_QUALIFIER static vec<L, int, P> call(vec<L, T, P> const& x)
{
return detail::functor1<L, int, T, P>::call(compute_findMSB_64, x);
}
@ -186,13 +186,13 @@ namespace detail
return static_cast<uint32>(Value64 % (Max32 + static_cast<uint64>(1)));
}
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, uint, P> uaddCarry(vecType<L, uint, P> const& x, vecType<L, uint, P> const& y, vecType<L, uint, P>& Carry)
template<length_t L, precision P>
GLM_FUNC_QUALIFIER vec<L, uint, P> uaddCarry(vec<L, uint, P> const& x, vec<L, uint, P> const& y, vec<L, uint, P>& Carry)
{
vecType<L, uint64, P> Value64(vecType<L, uint64, P>(x) + vecType<L, uint64, P>(y));
vecType<L, uint64, P> Max32((static_cast<uint64>(1) << static_cast<uint64>(32)) - static_cast<uint64>(1));
Carry = mix(vecType<L, uint32, P>(0), vecType<L, uint32, P>(1), greaterThan(Value64, Max32));
return vecType<L, uint32,P>(Value64 % (Max32 + static_cast<uint64>(1)));
vec<L, uint64, P> Value64(vec<L, uint64, P>(x) + vec<L, uint64, P>(y));
vec<L, uint64, P> Max32((static_cast<uint64>(1) << static_cast<uint64>(32)) - static_cast<uint64>(1));
Carry = mix(vec<L, uint32, P>(0), vec<L, uint32, P>(1), greaterThan(Value64, Max32));
return vec<L, uint32,P>(Value64 % (Max32 + static_cast<uint64>(1)));
}
// usubBorrow
@ -207,12 +207,12 @@ namespace detail
return static_cast<uint32>((static_cast<int64>(1) << static_cast<int64>(32)) + (static_cast<int64>(y) - static_cast<int64>(x)));
}
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, uint, P> usubBorrow(vecType<L, uint, P> const& x, vecType<L, uint, P> const& y, vecType<L, uint, P>& Borrow)
template<length_t L, precision P>
GLM_FUNC_QUALIFIER vec<L, uint, P> usubBorrow(vec<L, uint, P> const& x, vec<L, uint, P> const& y, vec<L, uint, P>& Borrow)
{
Borrow = mix(vecType<L, uint, P>(1), vecType<L, uint, P>(0), greaterThanEqual(x, y));
vecType<L, uint, P> const YgeX(y - x);
vecType<L, uint, P> const XgeY(vecType<L, uint32, P>((static_cast<int64>(1) << static_cast<int64>(32)) + (vecType<L, int64, P>(y) - vecType<L, int64, P>(x))));
Borrow = mix(vec<L, uint, P>(1), vec<L, uint, P>(0), greaterThanEqual(x, y));
vec<L, uint, P> const YgeX(y - x);
vec<L, uint, P> const XgeY(vec<L, uint32, P>((static_cast<int64>(1) << static_cast<int64>(32)) + (vec<L, int64, P>(y) - vec<L, int64, P>(x))));
return mix(XgeY, YgeX, greaterThanEqual(y, x));
}
@ -226,14 +226,14 @@ namespace detail
lsb = static_cast<uint>(Value64);
}
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER void umulExtended(vecType<L, uint, P> const& x, vecType<L, uint, P> const& y, vecType<L, uint, P>& msb, vecType<L, uint, P>& lsb)
template<length_t L, precision P>
GLM_FUNC_QUALIFIER void umulExtended(vec<L, uint, P> const& x, vec<L, uint, P> const& y, vec<L, uint, P>& msb, vec<L, uint, P>& lsb)
{
GLM_STATIC_ASSERT(sizeof(uint) == sizeof(uint32), "uint and uint32 size mismatch");
vecType<L, uint64, P> Value64(vecType<L, uint64, P>(x) * vecType<L, uint64, P>(y));
msb = vecType<L, uint32, P>(Value64 >> static_cast<uint64>(32));
lsb = vecType<L, uint32, P>(Value64);
vec<L, uint64, P> Value64(vec<L, uint64, P>(x) * vec<L, uint64, P>(y));
msb = vec<L, uint32, P>(Value64 >> static_cast<uint64>(32));
lsb = vec<L, uint32, P>(Value64);
}
// imulExtended
@ -246,14 +246,14 @@ namespace detail
lsb = static_cast<int>(Value64);
}
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER void imulExtended(vecType<L, int, P> const& x, vecType<L, int, P> const& y, vecType<L, int, P>& msb, vecType<L, int, P>& lsb)
template<length_t L, precision P>
GLM_FUNC_QUALIFIER void imulExtended(vec<L, int, P> const& x, vec<L, int, P> const& y, vec<L, int, P>& msb, vec<L, int, P>& lsb)
{
GLM_STATIC_ASSERT(sizeof(int) == sizeof(int32), "int and int32 size mismatch");
vecType<L, int64, P> Value64(vecType<L, int64, P>(x) * vecType<L, int64, P>(y));
lsb = vecType<L, int32, P>(Value64 & static_cast<int64>(0xFFFFFFFF));
msb = vecType<L, int32, P>((Value64 >> static_cast<int64>(32)) & static_cast<int64>(0xFFFFFFFF));
vec<L, int64, P> Value64(vec<L, int64, P>(x) * vec<L, int64, P>(y));
lsb = vec<L, int32, P>(Value64 & static_cast<int64>(0xFFFFFFFF));
msb = vec<L, int32, P>((Value64 >> static_cast<int64>(32)) & static_cast<int64>(0xFFFFFFFF));
}
// bitfieldExtract
@ -263,8 +263,8 @@ namespace detail
return bitfieldExtract(vec<1, genIUType>(Value), Offset, Bits).x;
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> bitfieldExtract(vecType<L, T, P> const& Value, int Offset, int Bits)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> bitfieldExtract(vec<L, T, P> const& Value, int Offset, int Bits)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::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<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> bitfieldInsert(vecType<L, T, P> const& Base, vecType<L, T, P> const& Insert, int Offset, int Bits)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> bitfieldInsert(vec<L, T, P> const& Base, vec<L, T, P> const& Insert, int Offset, int Bits)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitfieldInsert' only accept integer values");
@ -294,16 +294,16 @@ namespace detail
return bitfieldReverse(glm::vec<1, genType, glm::defaultp>(x)).x;
}
template<length_t L, typename T, glm::precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> bitfieldReverse(vecType<L, T, P> const& v)
template<length_t L, typename T, glm::precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> bitfieldReverse(vec<L, T, P> const& v)
{
vecType<L, T, P> x(v);
x = detail::compute_bitfieldReverseStep<L, T, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 2>::call(x, static_cast<T>(0x5555555555555555ull), static_cast<T>( 1));
x = detail::compute_bitfieldReverseStep<L, T, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 4>::call(x, static_cast<T>(0x3333333333333333ull), static_cast<T>( 2));
x = detail::compute_bitfieldReverseStep<L, T, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 8>::call(x, static_cast<T>(0x0F0F0F0F0F0F0F0Full), static_cast<T>( 4));
x = detail::compute_bitfieldReverseStep<L, T, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 16>::call(x, static_cast<T>(0x00FF00FF00FF00FFull), static_cast<T>( 8));
x = detail::compute_bitfieldReverseStep<L, T, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 32>::call(x, static_cast<T>(0x0000FFFF0000FFFFull), static_cast<T>(16));
x = detail::compute_bitfieldReverseStep<L, T, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 64>::call(x, static_cast<T>(0x00000000FFFFFFFFull), static_cast<T>(32));
vec<L, T, P> x(v);
x = detail::compute_bitfieldReverseStep<L, T, P, detail::is_aligned<P>::value, sizeof(T) * 8>= 2>::call(x, static_cast<T>(0x5555555555555555ull), static_cast<T>( 1));
x = detail::compute_bitfieldReverseStep<L, T, P, detail::is_aligned<P>::value, sizeof(T) * 8>= 4>::call(x, static_cast<T>(0x3333333333333333ull), static_cast<T>( 2));
x = detail::compute_bitfieldReverseStep<L, T, P, detail::is_aligned<P>::value, sizeof(T) * 8>= 8>::call(x, static_cast<T>(0x0F0F0F0F0F0F0F0Full), static_cast<T>( 4));
x = detail::compute_bitfieldReverseStep<L, T, P, detail::is_aligned<P>::value, sizeof(T) * 8>= 16>::call(x, static_cast<T>(0x00FF00FF00FF00FFull), static_cast<T>( 8));
x = detail::compute_bitfieldReverseStep<L, T, P, detail::is_aligned<P>::value, sizeof(T) * 8>= 32>::call(x, static_cast<T>(0x0000FFFF0000FFFFull), static_cast<T>(16));
x = detail::compute_bitfieldReverseStep<L, T, P, detail::is_aligned<P>::value, sizeof(T) * 8>= 64>::call(x, static_cast<T>(0x00000000FFFFFFFFull), static_cast<T>(32));
return x;
}
@ -314,24 +314,26 @@ namespace detail
return bitCount(glm::vec<1, genType, glm::defaultp>(x)).x;
}
template<length_t L, typename T, glm::precision P, template<length_t, typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, int, P> bitCount(vecType<L, T, P> const& v)
template<length_t L, typename T, glm::precision P>
GLM_FUNC_QUALIFIER vec<L, int, P> bitCount(vec<L, T, P> const& v)
{
#if GLM_COMPILER & GLM_COMPILER_VC
#pragma warning(push)
#pragma warning(disable : 4310) //cast truncates constant value
#endif
vecType<L, typename detail::make_unsigned<T>::type, P> x(*reinterpret_cast<vecType<L, typename detail::make_unsigned<T>::type, P> const *>(&v));
x = detail::compute_bitfieldBitCountStep<L, typename detail::make_unsigned<T>::type, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 2>::call(x, typename detail::make_unsigned<T>::type(0x5555555555555555ull), typename detail::make_unsigned<T>::type( 1));
x = detail::compute_bitfieldBitCountStep<L, typename detail::make_unsigned<T>::type, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 4>::call(x, typename detail::make_unsigned<T>::type(0x3333333333333333ull), typename detail::make_unsigned<T>::type( 2));
x = detail::compute_bitfieldBitCountStep<L, typename detail::make_unsigned<T>::type, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 8>::call(x, typename detail::make_unsigned<T>::type(0x0F0F0F0F0F0F0F0Full), typename detail::make_unsigned<T>::type( 4));
x = detail::compute_bitfieldBitCountStep<L, typename detail::make_unsigned<T>::type, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 16>::call(x, typename detail::make_unsigned<T>::type(0x00FF00FF00FF00FFull), typename detail::make_unsigned<T>::type( 8));
x = detail::compute_bitfieldBitCountStep<L, typename detail::make_unsigned<T>::type, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 32>::call(x, typename detail::make_unsigned<T>::type(0x0000FFFF0000FFFFull), typename detail::make_unsigned<T>::type(16));
x = detail::compute_bitfieldBitCountStep<L, typename detail::make_unsigned<T>::type, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 64>::call(x, typename detail::make_unsigned<T>::type(0x00000000FFFFFFFFull), typename detail::make_unsigned<T>::type(32));
return vecType<L, int, P>(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<L, typename detail::make_unsigned<T>::type, P> x(*reinterpret_cast<vec<L, typename detail::make_unsigned<T>::type, P> const *>(&v));
x = detail::compute_bitfieldBitCountStep<L, typename detail::make_unsigned<T>::type, P, detail::is_aligned<P>::value, sizeof(T) * 8>= 2>::call(x, typename detail::make_unsigned<T>::type(0x5555555555555555ull), typename detail::make_unsigned<T>::type( 1));
x = detail::compute_bitfieldBitCountStep<L, typename detail::make_unsigned<T>::type, P, detail::is_aligned<P>::value, sizeof(T) * 8>= 4>::call(x, typename detail::make_unsigned<T>::type(0x3333333333333333ull), typename detail::make_unsigned<T>::type( 2));
x = detail::compute_bitfieldBitCountStep<L, typename detail::make_unsigned<T>::type, P, detail::is_aligned<P>::value, sizeof(T) * 8>= 8>::call(x, typename detail::make_unsigned<T>::type(0x0F0F0F0F0F0F0F0Full), typename detail::make_unsigned<T>::type( 4));
x = detail::compute_bitfieldBitCountStep<L, typename detail::make_unsigned<T>::type, P, detail::is_aligned<P>::value, sizeof(T) * 8>= 16>::call(x, typename detail::make_unsigned<T>::type(0x00FF00FF00FF00FFull), typename detail::make_unsigned<T>::type( 8));
x = detail::compute_bitfieldBitCountStep<L, typename detail::make_unsigned<T>::type, P, detail::is_aligned<P>::value, sizeof(T) * 8>= 32>::call(x, typename detail::make_unsigned<T>::type(0x0000FFFF0000FFFFull), typename detail::make_unsigned<T>::type(16));
x = detail::compute_bitfieldBitCountStep<L, typename detail::make_unsigned<T>::type, P, detail::is_aligned<P>::value, sizeof(T) * 8>= 64>::call(x, typename detail::make_unsigned<T>::type(0x00000000FFFFFFFFull), typename detail::make_unsigned<T>::type(32));
return vec<L, int, P>(x);
# if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(pop)
# endif
}
// findLSB
@ -343,8 +345,8 @@ namespace detail
return detail::compute_findLSB<genIUType, sizeof(genIUType) * 8>::call(Value);
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, int, P> findLSB(vecType<L, T, P> const& x)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, int, P> findLSB(vec<L, T, P> const& x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'findLSB' only accept integer values");
@ -360,12 +362,12 @@ namespace detail
return findMSB(vec<1, genIUType>(v)).x;
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, int, P> findMSB(vecType<L, T, P> const& v)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, int, P> findMSB(vec<L, T, P> const& v)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'findMSB' only accept integer values");
return detail::compute_findMSB_vec<L, T, P, vecType, sizeof(T) * 8>::call(v);
return detail::compute_findMSB_vec<L, T, P, sizeof(T) * 8>::call(v);
}
}//namespace glm

View File

@ -9,7 +9,7 @@ namespace glm{
namespace detail
{
template<glm::precision P>
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<glm::precision P>
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)
{

View File

@ -35,55 +35,55 @@ namespace glm{
namespace detail
{
template<typename T, precision P>
struct outerProduct_trait<2, 2, T, P, vec, vec>
struct outerProduct_trait<2, 2, T, P>
{
typedef mat<2, 2, T, P> type;
};
template<typename T, precision P>
struct outerProduct_trait<2, 3, T, P, vec, vec>
struct outerProduct_trait<2, 3, T, P>
{
typedef mat<3, 2, T, P> type;
};
template<typename T, precision P>
struct outerProduct_trait<2, 4, T, P, vec, vec>
struct outerProduct_trait<2, 4, T, P>
{
typedef mat<4, 2, T, P> type;
};
template<typename T, precision P>
struct outerProduct_trait<3, 2, T, P, vec, vec>
struct outerProduct_trait<3, 2, T, P>
{
typedef mat<2, 3, T, P> type;
};
template<typename T, precision P>
struct outerProduct_trait<3, 3, T, P, vec, vec>
struct outerProduct_trait<3, 3, T, P>
{
typedef mat<3, 3, T, P> type;
};
template<typename T, precision P>
struct outerProduct_trait<3, 4, T, P, vec, vec>
struct outerProduct_trait<3, 4, T, P>
{
typedef mat<4, 3, T, P> type;
};
template<typename T, precision P>
struct outerProduct_trait<4, 2, T, P, vec, vec>
struct outerProduct_trait<4, 2, T, P>
{
typedef mat<2, 4, T, P> type;
};
template<typename T, precision P>
struct outerProduct_trait<4, 3, T, P, vec, vec>
struct outerProduct_trait<4, 3, T, P>
{
typedef mat<3, 4, T, P> type;
};
template<typename T, precision P>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/outerProduct.xml">GLSL outerProduct man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.6 Matrix Functions</a>
template<length_t DA, length_t DB, typename T, precision P, template<length_t, typename, precision> class vecTypeA, template<length_t, typename, precision> class vecTypeB>
GLM_FUNC_DECL typename detail::outerProduct_trait<DA, DB, T, P, vecTypeA, vecTypeB>::type outerProduct(vecTypeA<DA, T, P> const & c, vecTypeB<DB, T, P> const & r);
template<length_t DA, length_t DB, typename T, precision P>
GLM_FUNC_DECL typename detail::outerProduct_trait<DA, DB, T, P>::type outerProduct(vec<DA, T, P> const & c, vec<DB, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/determinant.xml">GLSL determinant man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.6 Matrix Functions</a>
@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/inverse.xml">GLSL inverse man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.6 Matrix Functions</a>

View File

@ -362,12 +362,12 @@ namespace detail
return detail::compute_matrixCompMult<matType, C, R, T, P, detail::is_aligned<P>::value>::call(x, y);
}
template<length_t DA, length_t DB, typename T, precision P, template<length_t, typename, precision> class vecTypeA, template<length_t, typename, precision> class vecTypeB>
GLM_FUNC_QUALIFIER typename detail::outerProduct_trait<DA, DB, T, P, vecTypeA, vecTypeB>::type outerProduct(vecTypeA<DA, T, P> const & c, vecTypeB<DB, T, P> const & r)
template<length_t DA, length_t DB, typename T, precision P>
GLM_FUNC_QUALIFIER typename detail::outerProduct_trait<DA, DB, T, P>::type outerProduct(vec<DA, T, P> const & c, vec<DB, T, P> const & r)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || GLM_UNRESTRICTED_GENTYPE, "'outerProduct' only accept floating-point inputs");
typename detail::outerProduct_trait<DA, DB, T, P, vecTypeA, vecTypeB>::type m;
typename detail::outerProduct_trait<DA, DB, T, P>::type m;
for(length_t i = 0; i < m.length(); ++i)
m[i] = c * r[i];
return m;

View File

@ -6,6 +6,7 @@
#include "type_mat4x4.hpp"
#include "func_geometric.hpp"
#include "../simd/matrix.h"
#include <cstring>
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

View File

@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/radians.xml">GLSL radians man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/degrees.xml">GLSL degrees man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/sin.xml">GLSL sin man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/cos.xml">GLSL cos man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/tan.xml">GLSL tan man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/asin.xml">GLSL asin man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/acos.xml">GLSL acos man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/atan.xml">GLSL atan man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/atan.xml">GLSL atan man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/sinh.xml">GLSL sinh man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/cosh.xml">GLSL cosh man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/tanh.xml">GLSL tanh man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/asinh.xml">GLSL asinh man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/acosh.xml">GLSL acosh man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/atanh.xml">GLSL atanh man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>

View File

@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/lessThan.xml">GLSL lessThan man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, bool, P> lessThan(vecType<L, T, P> const & x, vecType<L, T, P> const & y);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, bool, P> lessThan(vec<L, T, P> const& x, vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/lessThanEqual.xml">GLSL lessThanEqual man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, bool, P> lessThanEqual(vecType<L, T, P> const & x, vecType<L, T, P> const & y);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, bool, P> lessThanEqual(vec<L, T, P> const& x, vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/greaterThan.xml">GLSL greaterThan man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, bool, P> greaterThan(vecType<L, T, P> const & x, vecType<L, T, P> const & y);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, bool, P> greaterThan(vec<L, T, P> const& x, vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/greaterThanEqual.xml">GLSL greaterThanEqual man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, bool, P> greaterThanEqual(vecType<L, T, P> const & x, vecType<L, T, P> const & y);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, bool, P> greaterThanEqual(vec<L, T, P> const& x, vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/equal.xml">GLSL equal man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, bool, P> equal(vecType<L, T, P> const & x, vecType<L, T, P> const & y);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, bool, P> equal(vec<L, T, P> const& x, vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/notEqual.xml">GLSL notEqual man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, bool, P> notEqual(vecType<L, T, P> const & x, vecType<L, T, P> const & y);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, bool, P> notEqual(vec<L, T, P> const& x, vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/any.xml">GLSL any man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL bool any(vecType<L, bool, P> const & v);
template<length_t L, precision P>
GLM_FUNC_DECL bool any(vec<L, bool, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/all.xml">GLSL all man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL bool all(vecType<L, bool, P> const & v);
template<length_t L, precision P>
GLM_FUNC_DECL bool all(vec<L, bool, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/not.xml">GLSL not man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, bool, P> not_(vecType<L, bool, P> const & v);
template<length_t L, precision P>
GLM_FUNC_DECL vec<L, bool, P> not_(vec<L, bool, P> const& v);
/// @}
}//namespace glm

View File

@ -1,79 +1,79 @@
/// @ref core
/// @file glm/detail/func_vector_relational.inl
#include <limits>
#include "compute_vector_relational.hpp"
namespace glm
{
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, bool, P> lessThan(vecType<L, T, P> const & x, vecType<L, T, P> const & y)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, bool, P> lessThan(vec<L, T, P> const& x, vec<L, T, P> const& y)
{
assert(x.length() == y.length());
vecType<L, bool, P> Result;
vec<L, bool, P> Result;
for(length_t i = 0; i < x.length(); ++i)
Result[i] = x[i] < y[i];
return Result;
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, bool, P> lessThanEqual(vecType<L, T, P> const & x, vecType<L, T, P> const & y)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, bool, P> lessThanEqual(vec<L, T, P> const& x, vec<L, T, P> const& y)
{
assert(x.length() == y.length());
vecType<L, bool, P> Result;
vec<L, bool, P> Result;
for(length_t i = 0; i < x.length(); ++i)
Result[i] = x[i] <= y[i];
return Result;
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, bool, P> greaterThan(vecType<L, T, P> const & x, vecType<L, T, P> const & y)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, bool, P> greaterThan(vec<L, T, P> const& x, vec<L, T, P> const& y)
{
assert(x.length() == y.length());
vecType<L, bool, P> Result;
vec<L, bool, P> Result;
for(length_t i = 0; i < x.length(); ++i)
Result[i] = x[i] > y[i];
return Result;
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, bool, P> greaterThanEqual(vecType<L, T, P> const & x, vecType<L, T, P> const & y)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, bool, P> greaterThanEqual(vec<L, T, P> const& x, vec<L, T, P> const& y)
{
assert(x.length() == y.length());
vecType<L, bool, P> Result;
vec<L, bool, P> Result;
for(length_t i = 0; i < x.length(); ++i)
Result[i] = x[i] >= y[i];
return Result;
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, bool, P> equal(vecType<L, T, P> const & x, vecType<L, T, P> const & y)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, bool, P> equal(vec<L, T, P> const& x, vec<L, T, P> const& y)
{
assert(x.length() == y.length());
vecType<L, bool, P> Result;
vec<L, bool, P> Result;
for(length_t i = 0; i < x.length(); ++i)
Result[i] = x[i] == y[i];
Result[i] = detail::compute_equal<T>::call(x[i], y[i]);
return Result;
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, bool, P> notEqual(vecType<L, T, P> const & x, vecType<L, T, P> const & y)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, bool, P> notEqual(vec<L, T, P> const& x, vec<L, T, P> const& y)
{
assert(x.length() == y.length());
vecType<L, bool, P> Result;
vec<L, bool, P> Result;
for(length_t i = 0; i < x.length(); ++i)
Result[i] = x[i] != y[i];
Result[i] = !detail::compute_equal<T>::call(x[i], y[i]);
return Result;
}
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER bool any(vecType<L, bool, P> const & v)
template<length_t L, precision P>
GLM_FUNC_QUALIFIER bool any(vec<L, bool, P> const& v)
{
bool Result = false;
for(length_t i = 0; i < v.length(); ++i)
@ -81,8 +81,8 @@ namespace glm
return Result;
}
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER bool all(vecType<L, bool, P> const & v)
template<length_t L, precision P>
GLM_FUNC_QUALIFIER bool all(vec<L, bool, P> const& v)
{
bool Result = true;
for(length_t i = 0; i < v.length(); ++i)
@ -90,10 +90,10 @@ namespace glm
return Result;
}
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, bool, P> not_(vecType<L, bool, P> const & v)
template<length_t L, precision P>
GLM_FUNC_QUALIFIER vec<L, bool, P> not_(vec<L, bool, P> const& v)
{
vecType<L, bool, P> Result;
vec<L, bool, P> Result;
for(length_t i = 0; i < v.length(); ++i)
Result[i] = !v[i];
return Result;

View File

@ -8,7 +8,7 @@
namespace glm{
namespace detail
{
template<length_t Columns, length_t Rows, typename T, precision P, template<length_t, class, precision> class colType, template<length_t, class, precision> class rowType>
template<length_t Columns, length_t Rows, typename T, precision P>
struct outerProduct_trait{};
}//namespace detail

View File

@ -5,6 +5,7 @@
#include "precision.hpp"
#include "type_int.hpp"
#include "compute_vector_relational.hpp"
namespace glm{
namespace detail

View File

@ -528,13 +528,13 @@ namespace glm
template<typename T, precision P>
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<T>::call(v1.x, v2.x);
}
template<typename T, precision P>
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<precision P>

View File

@ -851,13 +851,15 @@ namespace glm
template<typename T, precision P>
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<T>::call(v1.x, v2.x) &&
detail::compute_equal<T>::call(v1.y, v2.y);
}
template<typename T, precision P>
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<precision P>

View File

@ -966,13 +966,16 @@ namespace glm
template<typename T, precision P>
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<T>::call(v1.x, v2.x) &&
detail::compute_equal<T>::call(v1.y, v2.y) &&
detail::compute_equal<T>::call(v1.z, v2.z);
}
template<typename T, precision P>
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<precision P>

View File

@ -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<T>::call(v1.x, v2.x) &&
detail::compute_equal<T>::call(v1.y, v2.y) &&
detail::compute_equal<T>::call(v1.z, v2.z) &&
detail::compute_equal<T>::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<T, P, detail::is_int<T>::value, sizeof(T) * 8, detail::is_aligned<P>::value>::call(v1, v2);
}
};

View File

@ -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<glm::uint16>(REG2 << 1);
}
template<>

View File

@ -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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> mod(vecType<L, T, P> const & x, T y);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> mod(vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> mod(vecType<L, T, P> const & x, vecType<L, T, P> const & y);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> mod(vec<L, T, P> const& x, vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/round.xml">GLSL round man page</a>
/// @see gtc_integer
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, int, P> iround(vecType<L, T, P> const & x);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, int, P> iround(vec<L, T, P> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/round.xml">GLSL round man page</a>
/// @see gtc_integer
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, uint, P> uround(vecType<L, T, P> const & x);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, uint, P> uround(vec<L, T, P> const& x);
/// @}
} //namespace glm

View File

@ -4,20 +4,20 @@
namespace glm{
namespace detail
{
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool Aligned>
struct compute_log2<L, T, P, vecType, false, Aligned>
template<length_t L, typename T, precision P, bool Aligned>
struct compute_log2<L, T, P, false, Aligned>
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const& v)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& v)
{
//Equivalent to return findMSB(vec); but save one function call in ASM with VC
//return findMSB(vec);
return vecType<L, T, P>(detail::compute_findMSB_vec<L, T, P, vecType, sizeof(T) * 8>::call(v));
return vec<L, T, P>(detail::compute_findMSB_vec<L, T, P, sizeof(T) * 8>::call(v));
}
};
# if GLM_HAS_BITSCAN_WINDOWS
template<precision P, bool Aligned>
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<int>(x + static_cast<genType>(0.5));
}
template<glm::length_t L, typename T, precision P, template<glm::length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, int, P> iround(vecType<L, T, P> const& x)
template<glm::length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, int, P> iround(vec<L, T, P> const& x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'iround' only accept floating-point inputs");
assert(all(lessThanEqual(vecType<L, T, P>(0), x)));
assert(all(lessThanEqual(vec<L, T, P>(0), x)));
return vecType<L, int, P>(x + static_cast<T>(0.5));
return vec<L, int, P>(x + static_cast<T>(0.5));
}
template<typename genType>
@ -58,12 +58,12 @@ namespace detail
return static_cast<uint>(x + static_cast<genType>(0.5));
}
template<glm::length_t L, typename T, precision P, template<glm::length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, uint, P> uround(vecType<L, T, P> const& x)
template<glm::length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, uint, P> uround(vec<L, T, P> const& x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'uround' only accept floating-point inputs");
assert(all(lessThanEqual(vecType<L, T, P>(0), x)));
assert(all(lessThanEqual(vec<L, T, P>(0), x)));
return vecType<L, uint, P>(x + static_cast<T>(0.5));
return vec<L, uint, P>(x + static_cast<T>(0.5));
}
}//namespace glm

View File

@ -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<float>::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));

View File

@ -176,18 +176,24 @@ namespace glm
/// Returns the length of the quaternion.
///
/// @tparam T Floating-point scalar types.
///
/// @see gtc_quaternion
template<typename T, precision P>
GLM_FUNC_DECL T length(tquat<T, P> const & q);
/// Returns the normalized quaternion.
///
/// @tparam T Floating-point scalar types.
///
/// @see gtc_quaternion
template<typename T, precision P>
GLM_FUNC_DECL tquat<T, P> normalize(tquat<T, P> 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<typename T, precision P>
GLM_FUNC_DECL T dot(tquat<T, P> const & x, tquat<T, P> 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<T, P> const & x, tquat<T, P> const & y, T const & a)
/// @see gtc_quaternion
template<typename T, precision P>
GLM_FUNC_DECL tquat<T, P> mix(tquat<T, P> const & x, tquat<T, P> 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<typename T, precision P>
GLM_FUNC_DECL tquat<T, P> lerp(tquat<T, P> const & x, tquat<T, P> 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<typename T, precision P>
GLM_FUNC_DECL tquat<T, P> slerp(tquat<T, P> const & x, tquat<T, P> const & y, T a);
/// Returns the q conjugate.
///
/// @tparam T Floating-point scalar types.
///
/// @see gtc_quaternion
template<typename T, precision P>
GLM_FUNC_DECL tquat<T, P> conjugate(tquat<T, P> const & q);
/// Returns the q inverse.
///
/// @tparam T Floating-point scalar types.
///
/// @see gtc_quaternion
template<typename T, precision P>
GLM_FUNC_DECL tquat<T, P> inverse(tquat<T, P> const & q);
@ -244,6 +257,7 @@ 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<typename T, precision P>
@ -252,120 +266,141 @@ namespace glm
/// 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<typename T, precision P>
GLM_FUNC_DECL vec<3, T, P> eulerAngles(tquat<T, P> const & x);
/// Returns roll value of euler angles expressed in radians.
///
/// @see gtx_quaternion
/// @tparam T Floating-point scalar types.
///
/// @see gtc_quaternion
template<typename T, precision P>
GLM_FUNC_DECL T roll(tquat<T, P> const & x);
GLM_FUNC_DECL T roll(tquat<T, P> const& x);
/// Returns pitch value of euler angles expressed in radians.
///
/// @see gtx_quaternion
/// @tparam T Floating-point scalar types.
///
/// @see gtc_quaternion
template<typename T, precision P>
GLM_FUNC_DECL T pitch(tquat<T, P> const & x);
GLM_FUNC_DECL T pitch(tquat<T, P> const& x);
/// Returns yaw value of euler angles expressed in radians.
///
/// @see gtx_quaternion
/// @tparam T Floating-point scalar types.
///
/// @see gtc_quaternion
template<typename T, precision P>
GLM_FUNC_DECL T yaw(tquat<T, P> const & x);
GLM_FUNC_DECL T yaw(tquat<T, P> const& x);
/// Converts a quaternion to a 3 * 3 matrix.
///
/// @tparam T Floating-point scalar types.
///
/// @see gtc_quaternion
template<typename T, precision P>
GLM_FUNC_DECL mat<3, 3, T, P> mat3_cast(tquat<T, P> const & x);
GLM_FUNC_DECL mat<3, 3, T, P> mat3_cast(tquat<T, P> const& x);
/// Converts a quaternion to a 4 * 4 matrix.
///
/// @tparam T Floating-point scalar types.
///
/// @see gtc_quaternion
template<typename T, precision P>
GLM_FUNC_DECL mat<4, 4, T, P> mat4_cast(tquat<T, P> const & x);
GLM_FUNC_DECL mat<4, 4, T, P> mat4_cast(tquat<T, P> const& x);
/// Converts a 3 * 3 matrix to a quaternion.
///
/// @tparam T Floating-point scalar types.
///
/// @see gtc_quaternion
template<typename T, precision P>
GLM_FUNC_DECL tquat<T, P> quat_cast(mat<3, 3, T, P> const & x);
GLM_FUNC_DECL tquat<T, P> 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<typename T, precision P>
GLM_FUNC_DECL tquat<T, P> quat_cast(mat<4, 4, T, P> const & x);
GLM_FUNC_DECL tquat<T, P> quat_cast(mat<4, 4, T, P> const& x);
/// Returns the quaternion rotation angle.
///
/// @see gtc_quaternion
template<typename T, precision P>
GLM_FUNC_DECL T angle(tquat<T, P> const & x);
/// Returns the q rotation axis.
/// @tparam T Floating-point scalar types.
///
/// @see gtc_quaternion
template<typename T, precision P>
GLM_FUNC_DECL vec<3, T, P> axis(tquat<T, P> const & x);
GLM_FUNC_DECL T angle(tquat<T, P> const& x);
/// Returns the q rotation axis.
///
/// @tparam T Floating-point scalar types.
///
/// @see gtc_quaternion
template<typename T, precision P>
GLM_FUNC_DECL vec<3, T, P> axis(tquat<T, P> 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<typename T, precision P>
GLM_FUNC_DECL tquat<T, P> angleAxis(T const & angle, vec<3, T, P> const & axis);
GLM_FUNC_DECL tquat<T, P> 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<typename T, precision P>
GLM_FUNC_DECL vec<4, bool, P> lessThan(tquat<T, P> const & x, tquat<T, P> const & y);
GLM_FUNC_DECL vec<4, bool, P> lessThan(tquat<T, P> const& x, tquat<T, P> 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<typename T, precision P>
GLM_FUNC_DECL vec<4, bool, P> lessThanEqual(tquat<T, P> const & x, tquat<T, P> const & y);
GLM_FUNC_DECL vec<4, bool, P> lessThanEqual(tquat<T, P> const& x, tquat<T, P> 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<typename T, precision P>
GLM_FUNC_DECL vec<4, bool, P> greaterThan(tquat<T, P> const & x, tquat<T, P> const & y);
GLM_FUNC_DECL vec<4, bool, P> greaterThan(tquat<T, P> const& x, tquat<T, P> 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<typename T, precision P>
GLM_FUNC_DECL vec<4, bool, P> greaterThanEqual(tquat<T, P> const & x, tquat<T, P> const & y);
GLM_FUNC_DECL vec<4, bool, P> greaterThanEqual(tquat<T, P> const& x, tquat<T, P> 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<typename T, precision P>
GLM_FUNC_DECL vec<4, bool, P> equal(tquat<T, P> const & x, tquat<T, P> const & y);
GLM_FUNC_DECL vec<4, bool, P> equal(tquat<T, P> const& x, tquat<T, P> 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<typename T, precision P>
GLM_FUNC_DECL vec<4, bool, P> notEqual(tquat<T, P> const & x, tquat<T, P> const & y);
GLM_FUNC_DECL vec<4, bool, P> notEqual(tquat<T, P> const& x, tquat<T, P> 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<typename T, precision P>
GLM_FUNC_DECL vec<4, bool, P> isnan(tquat<T, P> const & x);
GLM_FUNC_DECL vec<4, bool, P> isnan(tquat<T, P> 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<typename T, precision P>
GLM_FUNC_DECL vec<4, bool, P> isinf(tquat<T, P> const & x);
GLM_FUNC_DECL vec<4, bool, P> isinf(tquat<T, P> const& x);
/// @}
} //namespace glm

View File

@ -4,6 +4,7 @@
#include "../trigonometric.hpp"
#include "../geometric.hpp"
#include "../exponential.hpp"
#include "../detail/compute_vector_relational.hpp"
#include <limits>
namespace glm{
@ -754,20 +755,20 @@ namespace detail
}
template<typename T, precision P>
GLM_FUNC_QUALIFIER vec<4, bool, P> equal(tquat<T, P> const & x, tquat<T, P> const & y)
GLM_FUNC_QUALIFIER vec<4, bool, P> equal(tquat<T, P> const& x, tquat<T, P> 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<T>::call(x[i], y[i]);
return Result;
}
template<typename T, precision P>
GLM_FUNC_QUALIFIER vec<4, bool, P> notEqual(tquat<T, P> const & x, tquat<T, P> const & y)
GLM_FUNC_QUALIFIER vec<4, bool, P> notEqual(tquat<T, P> const& x, tquat<T, P> 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<T>::call(x[i], y[i]);
return Result;
}

View File

@ -28,68 +28,52 @@ 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<typename genType>
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<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> linearRand(
vecType<L, T, P> const& Min,
vecType<L, T, P> const& Max);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> linearRand(vec<L, T, P> const& Min, vec<L, T, P> const& Max);
/// Generate random numbers in the interval [Min, Max], according a gaussian distribution
///
/// @param Mean
/// @param Deviation
/// @see gtc_random
template<typename genType>
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<typename T>
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<typename T>
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<typename T>
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<typename T>
GLM_FUNC_DECL vec<3, T, defaultp> ballRand(
T Radius);
GLM_FUNC_DECL vec<3, T, defaultp> ballRand(T Radius);
/// @}
}//namespace glm

View File

@ -10,14 +10,14 @@
namespace glm{
namespace detail
{
template<length_t L, typename T, precision P, template<length_t, class, precision> class vecType>
template <length_t L, typename T, precision P>
struct compute_rand
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call();
GLM_FUNC_QUALIFIER static vec<L, T, P> call();
};
template<precision P>
struct compute_rand<1, uint8, P, vec>
template <precision P>
struct compute_rand<1, uint8, P>
{
GLM_FUNC_QUALIFIER static vec<1, uint8, P> call()
{
@ -26,8 +26,8 @@ namespace detail
}
};
template<precision P>
struct compute_rand<2, uint8, P, vec>
template <precision P>
struct compute_rand<2, uint8, P>
{
GLM_FUNC_QUALIFIER static vec<2, uint8, P> call()
{
@ -37,8 +37,8 @@ namespace detail
}
};
template<precision P>
struct compute_rand<3, uint8, P, vec>
template <precision P>
struct compute_rand<3, uint8, P>
{
GLM_FUNC_QUALIFIER static vec<3, uint8, P> call()
{
@ -49,8 +49,8 @@ namespace detail
}
};
template<precision P>
struct compute_rand<4, uint8, P, vec>
template <precision P>
struct compute_rand<4, uint8, P>
{
GLM_FUNC_QUALIFIER static vec<4, uint8, P> call()
{
@ -62,195 +62,195 @@ namespace detail
}
};
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
struct compute_rand<L, uint16, P, vecType>
template <length_t L, precision P>
struct compute_rand<L, uint16, P>
{
GLM_FUNC_QUALIFIER static vecType<L, uint16, P> call()
GLM_FUNC_QUALIFIER static vec<L, uint16, P> call()
{
return
(vecType<L, uint16, P>(compute_rand<L, uint8, P, vecType>::call()) << static_cast<uint16>(8)) |
(vecType<L, uint16, P>(compute_rand<L, uint8, P, vecType>::call()) << static_cast<uint16>(0));
(vec<L, uint16, P>(compute_rand<L, uint8, P>::call()) << static_cast<uint16>(8)) |
(vec<L, uint16, P>(compute_rand<L, uint8, P>::call()) << static_cast<uint16>(0));
}
};
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
struct compute_rand<L, uint32, P, vecType>
template <length_t L, precision P>
struct compute_rand<L, uint32, P>
{
GLM_FUNC_QUALIFIER static vecType<L, uint32, P> call()
GLM_FUNC_QUALIFIER static vec<L, uint32, P> call()
{
return
(vecType<L, uint32, P>(compute_rand<L, uint16, P, vecType>::call()) << static_cast<uint32>(16)) |
(vecType<L, uint32, P>(compute_rand<L, uint16, P, vecType>::call()) << static_cast<uint32>(0));
(vec<L, uint32, P>(compute_rand<L, uint16, P>::call()) << static_cast<uint32>(16)) |
(vec<L, uint32, P>(compute_rand<L, uint16, P>::call()) << static_cast<uint32>(0));
}
};
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
struct compute_rand<L, uint64, P, vecType>
template <length_t L, precision P>
struct compute_rand<L, uint64, P>
{
GLM_FUNC_QUALIFIER static vecType<L, uint64, P> call()
GLM_FUNC_QUALIFIER static vec<L, uint64, P> call()
{
return
(vecType<L, uint64, P>(compute_rand<L, uint32, P, vecType>::call()) << static_cast<uint64>(32)) |
(vecType<L, uint64, P>(compute_rand<L, uint32, P, vecType>::call()) << static_cast<uint64>(0));
(vec<L, uint64, P>(compute_rand<L, uint32, P>::call()) << static_cast<uint64>(32)) |
(vec<L, uint64, P>(compute_rand<L, uint32, P>::call()) << static_cast<uint64>(0));
}
};
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
template <length_t L, typename T, precision P>
struct compute_linearRand
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & Min, vecType<L, T, P> const & Max);
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& Min, vec<L, T, P> const& Max);
};
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
struct compute_linearRand<L, int8, P, vecType>
template<length_t L, precision P>
struct compute_linearRand<L, int8, P>
{
GLM_FUNC_QUALIFIER static vecType<L, int8, P> call(vecType<L, int8, P> const & Min, vecType<L, int8, P> const & Max)
GLM_FUNC_QUALIFIER static vec<L, int8, P> call(vec<L, int8, P> const& Min, vec<L, int8, P> const& Max)
{
return (vecType<L, int8, P>(compute_rand<L, uint8, P, vecType>::call() % vecType<L, uint8, P>(Max + static_cast<int8>(1) - Min))) + Min;
return (vec<L, int8, P>(compute_rand<L, uint8, P>::call() % vec<L, uint8, P>(Max + static_cast<int8>(1) - Min))) + Min;
}
};
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
struct compute_linearRand<L, uint8, P, vecType>
template<length_t L, precision P>
struct compute_linearRand<L, uint8, P>
{
GLM_FUNC_QUALIFIER static vecType<L, uint8, P> call(vecType<L, uint8, P> const & Min, vecType<L, uint8, P> const & Max)
GLM_FUNC_QUALIFIER static vec<L, uint8, P> call(vec<L, uint8, P> const& Min, vec<L, uint8, P> const& Max)
{
return (compute_rand<L, uint8, P, vecType>::call() % (Max + static_cast<uint8>(1) - Min)) + Min;
return (compute_rand<L, uint8, P>::call() % (Max + static_cast<uint8>(1) - Min)) + Min;
}
};
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
struct compute_linearRand<L, int16, P, vecType>
template<length_t L, precision P>
struct compute_linearRand<L, int16, P>
{
GLM_FUNC_QUALIFIER static vecType<L, int16, P> call(vecType<L, int16, P> const & Min, vecType<L, int16, P> const & Max)
GLM_FUNC_QUALIFIER static vec<L, int16, P> call(vec<L, int16, P> const& Min, vec<L, int16, P> const& Max)
{
return (vecType<L, int16, P>(compute_rand<L, uint16, P, vecType>::call() % vecType<L, uint16, P>(Max + static_cast<int16>(1) - Min))) + Min;
return (vec<L, int16, P>(compute_rand<L, uint16, P>::call() % vec<L, uint16, P>(Max + static_cast<int16>(1) - Min))) + Min;
}
};
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
struct compute_linearRand<L, uint16, P, vecType>
template<length_t L, precision P>
struct compute_linearRand<L, uint16, P>
{
GLM_FUNC_QUALIFIER static vecType<L, uint16, P> call(vecType<L, uint16, P> const & Min, vecType<L, uint16, P> const & Max)
GLM_FUNC_QUALIFIER static vec<L, uint16, P> call(vec<L, uint16, P> const& Min, vec<L, uint16, P> const& Max)
{
return (compute_rand<L, uint16, P, vecType>::call() % (Max + static_cast<uint16>(1) - Min)) + Min;
return (compute_rand<L, uint16, P>::call() % (Max + static_cast<uint16>(1) - Min)) + Min;
}
};
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
struct compute_linearRand<L, int32, P, vecType>
template<length_t L, precision P>
struct compute_linearRand<L, int32, P>
{
GLM_FUNC_QUALIFIER static vecType<L, int32, P> call(vecType<L, int32, P> const & Min, vecType<L, int32, P> const & Max)
GLM_FUNC_QUALIFIER static vec<L, int32, P> call(vec<L, int32, P> const & Min, vec<L, int32, P> const& Max)
{
return (vecType<L, int32, P>(compute_rand<L, uint32, P, vecType>::call() % vecType<L, uint32, P>(Max + static_cast<int32>(1) - Min))) + Min;
return (vec<L, int32, P>(compute_rand<L, uint32, P>::call() % vec<L, uint32, P>(Max + static_cast<int32>(1) - Min))) + Min;
}
};
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
struct compute_linearRand<L, uint32, P, vecType>
template<length_t L, precision P>
struct compute_linearRand<L, uint32, P>
{
GLM_FUNC_QUALIFIER static vecType<L, uint32, P> call(vecType<L, uint32, P> const & Min, vecType<L, uint32, P> const & Max)
GLM_FUNC_QUALIFIER static vec<L, uint32, P> call(vec<L, uint32, P> const& Min, vec<L, uint32, P> const& Max)
{
return (compute_rand<L, uint32, P, vecType>::call() % (Max + static_cast<uint32>(1) - Min)) + Min;
return (compute_rand<L, uint32, P>::call() % (Max + static_cast<uint32>(1) - Min)) + Min;
}
};
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
struct compute_linearRand<L, int64, P, vecType>
template<length_t L, precision P>
struct compute_linearRand<L, int64, P>
{
GLM_FUNC_QUALIFIER static vecType<L, int64, P> call(vecType<L, int64, P> const & Min, vecType<L, int64, P> const & Max)
GLM_FUNC_QUALIFIER static vec<L, int64, P> call(vec<L, int64, P> const& Min, vec<L, int64, P> const& Max)
{
return (vecType<L, int64, P>(compute_rand<L, uint64, P, vecType>::call() % vecType<L, uint64, P>(Max + static_cast<int64>(1) - Min))) + Min;
return (vec<L, int64, P>(compute_rand<L, uint64, P>::call() % vec<L, uint64, P>(Max + static_cast<int64>(1) - Min))) + Min;
}
};
template<length_t L, precision P, template<length_t, typename, precision> class vecType>
struct compute_linearRand<L, uint64, P, vecType>
template<length_t L, precision P>
struct compute_linearRand<L, uint64, P>
{
GLM_FUNC_QUALIFIER static vecType<L, uint64, P> call(vecType<L, uint64, P> const & Min, vecType<L, uint64, P> const & Max)
GLM_FUNC_QUALIFIER static vec<L, uint64, P> call(vec<L, uint64, P> const& Min, vec<L, uint64, P> const& Max)
{
return (compute_rand<L, uint64, P, vecType>::call() % (Max + static_cast<uint64>(1) - Min)) + Min;
return (compute_rand<L, uint64, P>::call() % (Max + static_cast<uint64>(1) - Min)) + Min;
}
};
template<length_t L, template<length_t, typename, precision> class vecType>
struct compute_linearRand<L, float, lowp, vecType>
template<length_t L>
struct compute_linearRand<L, float, lowp>
{
GLM_FUNC_QUALIFIER static vecType<L, float, lowp> call(vecType<L, float, lowp> const & Min, vecType<L, float, lowp> const & Max)
GLM_FUNC_QUALIFIER static vec<L, float, lowp> call(vec<L, float, lowp> const& Min, vec<L, float, lowp> const& Max)
{
return vecType<L, float, lowp>(compute_rand<L, uint8, lowp, vecType>::call()) / static_cast<float>(std::numeric_limits<uint8>::max()) * (Max - Min) + Min;
return vec<L, float, lowp>(compute_rand<L, uint8, lowp>::call()) / static_cast<float>(std::numeric_limits<uint8>::max()) * (Max - Min) + Min;
}
};
template<length_t L, template<length_t, typename, precision> class vecType>
struct compute_linearRand<L, float, mediump, vecType>
template<length_t L>
struct compute_linearRand<L, float, mediump>
{
GLM_FUNC_QUALIFIER static vecType<L, float, mediump> call(vecType<L, float, mediump> const & Min, vecType<L, float, mediump> const & Max)
GLM_FUNC_QUALIFIER static vec<L, float, mediump> call(vec<L, float, mediump> const& Min, vec<L, float, mediump> const& Max)
{
return vecType<L, float, mediump>(compute_rand<L, uint16, mediump, vecType>::call()) / static_cast<float>(std::numeric_limits<uint16>::max()) * (Max - Min) + Min;
return vec<L, float, mediump>(compute_rand<L, uint16, mediump>::call()) / static_cast<float>(std::numeric_limits<uint16>::max()) * (Max - Min) + Min;
}
};
template<length_t L, template<length_t, typename, precision> class vecType>
struct compute_linearRand<L, float, highp, vecType>
template<length_t L>
struct compute_linearRand<L, float, highp>
{
GLM_FUNC_QUALIFIER static vecType<L, float, highp> call(vecType<L, float, highp> const & Min, vecType<L, float, highp> const & Max)
GLM_FUNC_QUALIFIER static vec<L, float, highp> call(vec<L, float, highp> const& Min, vec<L, float, highp> const& Max)
{
return vecType<L, float, highp>(compute_rand<L, uint32, highp, vecType>::call()) / static_cast<float>(std::numeric_limits<uint32>::max()) * (Max - Min) + Min;
return vec<L, float, highp>(compute_rand<L, uint32, highp>::call()) / static_cast<float>(std::numeric_limits<uint32>::max()) * (Max - Min) + Min;
}
};
template<length_t L, template<length_t, typename, precision> class vecType>
struct compute_linearRand<L, double, lowp, vecType>
template<length_t L>
struct compute_linearRand<L, double, lowp>
{
GLM_FUNC_QUALIFIER static vecType<L, double, lowp> call(vecType<L, double, lowp> const & Min, vecType<L, double, lowp> const & Max)
GLM_FUNC_QUALIFIER static vec<L, double, lowp> call(vec<L, double, lowp> const& Min, vec<L, double, lowp> const& Max)
{
return vecType<L, double, lowp>(compute_rand<L, uint16, lowp, vecType>::call()) / static_cast<double>(std::numeric_limits<uint16>::max()) * (Max - Min) + Min;
return vec<L, double, lowp>(compute_rand<L, uint16, lowp>::call()) / static_cast<double>(std::numeric_limits<uint16>::max()) * (Max - Min) + Min;
}
};
template<length_t L, template<length_t, typename, precision> class vecType>
struct compute_linearRand<L, double, mediump, vecType>
template<length_t L>
struct compute_linearRand<L, double, mediump>
{
GLM_FUNC_QUALIFIER static vecType<L, double, mediump> call(vecType<L, double, mediump> const & Min, vecType<L, double, mediump> const & Max)
GLM_FUNC_QUALIFIER static vec<L, double, mediump> call(vec<L, double, mediump> const& Min, vec<L, double, mediump> const& Max)
{
return vecType<L, double, mediump>(compute_rand<L, uint32, mediump, vecType>::call()) / static_cast<double>(std::numeric_limits<uint32>::max()) * (Max - Min) + Min;
return vec<L, double, mediump>(compute_rand<L, uint32, mediump>::call()) / static_cast<double>(std::numeric_limits<uint32>::max()) * (Max - Min) + Min;
}
};
template<length_t L, template<length_t, typename, precision> class vecType>
struct compute_linearRand<L, double, highp, vecType>
template<length_t L>
struct compute_linearRand<L, double, highp>
{
GLM_FUNC_QUALIFIER static vecType<L, double, highp> call(vecType<L, double, highp> const & Min, vecType<L, double, highp> const & Max)
GLM_FUNC_QUALIFIER static vec<L, double, highp> call(vec<L, double, highp> const& Min, vec<L, double, highp> const& Max)
{
return vecType<L, double, highp>(compute_rand<L, uint64, highp, vecType>::call()) / static_cast<double>(std::numeric_limits<uint64>::max()) * (Max - Min) + Min;
return vec<L, double, highp>(compute_rand<L, uint64, highp>::call()) / static_cast<double>(std::numeric_limits<uint64>::max()) * (Max - Min) + Min;
}
};
template<length_t L, template<length_t, typename, precision> class vecType>
struct compute_linearRand<L, long double, lowp, vecType>
template<length_t L>
struct compute_linearRand<L, long double, lowp>
{
GLM_FUNC_QUALIFIER static vecType<L, long double, lowp> call(vecType<L, long double, lowp> const & Min, vecType<L, long double, lowp> const & Max)
GLM_FUNC_QUALIFIER static vec<L, long double, lowp> call(vec<L, long double, lowp> const& Min, vec<L, long double, lowp> const& Max)
{
return vecType<L, long double, lowp>(compute_rand<L, uint32, lowp, vecType>::call()) / static_cast<long double>(std::numeric_limits<uint32>::max()) * (Max - Min) + Min;
return vec<L, long double, lowp>(compute_rand<L, uint32, lowp>::call()) / static_cast<long double>(std::numeric_limits<uint32>::max()) * (Max - Min) + Min;
}
};
template<length_t L, template<length_t, typename, precision> class vecType>
struct compute_linearRand<L, long double, mediump, vecType>
template<length_t L>
struct compute_linearRand<L, long double, mediump>
{
GLM_FUNC_QUALIFIER static vecType<L, long double, mediump> call(vecType<L, long double, mediump> const & Min, vecType<L, long double, mediump> const & Max)
GLM_FUNC_QUALIFIER static vec<L, long double, mediump> call(vec<L, long double, mediump> const& Min, vec<L, long double, mediump> const& Max)
{
return vecType<L, long double, mediump>(compute_rand<L, uint64, mediump, vecType>::call()) / static_cast<long double>(std::numeric_limits<uint64>::max()) * (Max - Min) + Min;
return vec<L, long double, mediump>(compute_rand<L, uint64, mediump>::call()) / static_cast<long double>(std::numeric_limits<uint64>::max()) * (Max - Min) + Min;
}
};
template<length_t L, template<length_t, typename, precision> class vecType>
struct compute_linearRand<L, long double, highp, vecType>
template<length_t L>
struct compute_linearRand<L, long double, highp>
{
GLM_FUNC_QUALIFIER static vecType<L, long double, highp> call(vecType<L, long double, highp> const & Min, vecType<L, long double, highp> const & Max)
GLM_FUNC_QUALIFIER static vec<L, long double, highp> call(vec<L, long double, highp> const& Min, vec<L, long double, highp> const& Max)
{
return vecType<L, long double, highp>(compute_rand<L, uint64, highp, vecType>::call()) / static_cast<long double>(std::numeric_limits<uint64>::max()) * (Max - Min) + Min;
return vec<L, long double, highp>(compute_rand<L, uint64, highp>::call()) / static_cast<long double>(std::numeric_limits<uint64>::max()) * (Max - Min) + Min;
}
};
}//namespace detail
@ -258,15 +258,15 @@ namespace detail
template<typename genType>
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<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> linearRand(vecType<L, T, P> const & Min, vecType<L, T, P> const & Max)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> linearRand(vec<L, T, P> const & Min, vec<L, T, P> const& Max)
{
return detail::compute_linearRand<L, T, P, vecType>::call(Min, Max);
return detail::compute_linearRand<L, T, P>::call(Min, Max);
}
template<typename genType>
@ -285,8 +285,8 @@ namespace detail
return x2 * Deviation * Deviation * sqrt((genType(-2) * log(w)) / w) + Mean;
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> gaussRand(vecType<L, T, P> const & Mean, vecType<L, T, P> const & Deviation)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> gaussRand(vec<L, T, P> const& Mean, vec<L, T, P> const& Deviation)
{
return detail::functor2<L, T, P>::call(gaussRand, Mean, Deviation);
}

View File

@ -39,8 +39,8 @@ namespace glm
/// Return true if the value is a power of two number.
///
/// @see gtc_round
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, bool, P> isPowerOfTwo(vecType<L, T, P> const & value);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, bool, P> isPowerOfTwo(vec<L, T, P> 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<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> ceilPowerOfTwo(vecType<L, T, P> const & value);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> ceilPowerOfTwo(vec<L, T, P> 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<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> floorPowerOfTwo(vecType<L, T, P> const & value);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> floorPowerOfTwo(vec<L, T, P> 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<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> roundPowerOfTwo(vecType<L, T, P> const & value);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> roundPowerOfTwo(vec<L, T, P> 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<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, bool, P> isMultiple(vecType<L, T, P> const & Value, T Multiple);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, bool, P> isMultiple(vec<L, T, P> const& Value, T Multiple);
/// Return true if the 'Value' is a multiple of 'Multiple'.
///
/// @see gtc_round
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, bool, P> isMultiple(vecType<L, T, P> const & Value, vecType<L, T, P> const & Multiple);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, bool, P> isMultiple(vec<L, T, P> const& Value, vec<L, T, P> 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<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> ceilMultiple(vecType<L, T, P> const & Source, vecType<L, T, P> const & Multiple);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> ceilMultiple(vec<L, T, P> const & Source, vec<L, T, P> 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<typename genType>
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<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> floorMultiple(
vecType<L, T, P> const& Source,
vecType<L, T, P> const& Multiple);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> floorMultiple(vec<L, T, P> const& Source, vec<L, T, P> 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<typename genType>
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<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_DECL vecType<L, T, P> roundMultiple(
vecType<L, T, P> const& Source,
vecType<L, T, P> const& Multiple);
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> roundMultiple(vec<L, T, P> const& Source, vec<L, T, P> const& Multiple);
/// @}
} //namespace glm

View File

@ -6,62 +6,62 @@
namespace glm{
namespace detail
{
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool compute = false>
template<length_t L, typename T, precision P, bool compute = false>
struct compute_ceilShift
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & v, T)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& v, T)
{
return v;
}
};
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
struct compute_ceilShift<L, T, P, vecType, true>
template<length_t L, typename T, precision P>
struct compute_ceilShift<L, T, P, true>
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & v, T Shift)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& v, T Shift)
{
return v | (v >> Shift);
}
};
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType, bool isSigned = true>
template<length_t L, typename T, precision P, bool isSigned = true>
struct compute_ceilPowerOfTwo
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & x)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& x)
{
GLM_STATIC_ASSERT(!std::numeric_limits<T>::is_iec559, "'ceilPowerOfTwo' only accept integer scalar or vector inputs");
vecType<L, T, P> const Sign(sign(x));
vec<L, T, P> const Sign(sign(x));
vecType<L, T, P> v(abs(x));
vec<L, T, P> v(abs(x));
v = v - static_cast<T>(1);
v = v | (v >> static_cast<T>(1));
v = v | (v >> static_cast<T>(2));
v = v | (v >> static_cast<T>(4));
v = compute_ceilShift<L, T, P, vecType, sizeof(T) >= 2>::call(v, 8);
v = compute_ceilShift<L, T, P, vecType, sizeof(T) >= 4>::call(v, 16);
v = compute_ceilShift<L, T, P, vecType, sizeof(T) >= 8>::call(v, 32);
v = compute_ceilShift<L, T, P, sizeof(T) >= 2>::call(v, 8);
v = compute_ceilShift<L, T, P, sizeof(T) >= 4>::call(v, 16);
v = compute_ceilShift<L, T, P, sizeof(T) >= 8>::call(v, 32);
return (v + static_cast<T>(1)) * Sign;
}
};
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
struct compute_ceilPowerOfTwo<L, T, P, vecType, false>
template<length_t L, typename T, precision P>
struct compute_ceilPowerOfTwo<L, T, P, false>
{
GLM_FUNC_QUALIFIER static vecType<L, T, P> call(vecType<L, T, P> const & x)
GLM_FUNC_QUALIFIER static vec<L, T, P> call(vec<L, T, P> const& x)
{
GLM_STATIC_ASSERT(!std::numeric_limits<T>::is_iec559, "'ceilPowerOfTwo' only accept integer scalar or vector inputs");
vecType<L, T, P> v(x);
vec<L, T, P> v(x);
v = v - static_cast<T>(1);
v = v | (v >> static_cast<T>(1));
v = v | (v >> static_cast<T>(2));
v = v | (v >> static_cast<T>(4));
v = compute_ceilShift<L, T, P, vecType, sizeof(T) >= 2>::call(v, 8);
v = compute_ceilShift<L, T, P, vecType, sizeof(T) >= 4>::call(v, 16);
v = compute_ceilShift<L, T, P, vecType, sizeof(T) >= 8>::call(v, 32);
v = compute_ceilShift<L, T, P, sizeof(T) >= 2>::call(v, 8);
v = compute_ceilShift<L, T, P, sizeof(T) >= 4>::call(v, 16);
v = compute_ceilShift<L, T, P, sizeof(T) >= 8>::call(v, 32);
return v + static_cast<T>(1);
}
};
@ -219,11 +219,11 @@ namespace detail
return !(Result & (Result - 1));
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, bool, P> isPowerOfTwo(vecType<L, T, P> const & Value)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, bool, P> isPowerOfTwo(vec<L, T, P> const & Value)
{
vecType<L, T, P> const Result(abs(Value));
return equal(Result & (Result - 1), vecType<L, T, P>(0));
vec<L, T, P> const Result(abs(Value));
return equal(Result & (Result - 1), vec<L, T, P>(0));
}
//////////////////
@ -232,13 +232,13 @@ namespace detail
template<typename genType>
GLM_FUNC_QUALIFIER genType ceilPowerOfTwo(genType value)
{
return detail::compute_ceilPowerOfTwo<1, genType, defaultp, vec, std::numeric_limits<genType>::is_signed>::call(vec<1, genType, defaultp>(value)).x;
return detail::compute_ceilPowerOfTwo<1, genType, defaultp, std::numeric_limits<genType>::is_signed>::call(vec<1, genType, defaultp>(value)).x;
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> ceilPowerOfTwo(vecType<L, T, P> const & v)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> ceilPowerOfTwo(vec<L, T, P> const& v)
{
return detail::compute_ceilPowerOfTwo<L, T, P, vecType, std::numeric_limits<T>::is_signed>::call(v);
return detail::compute_ceilPowerOfTwo<L, T, P, std::numeric_limits<T>::is_signed>::call(v);
}
///////////////////
@ -250,8 +250,8 @@ namespace detail
return isPowerOfTwo(value) ? value : static_cast<genType>(1) << findMSB(value);
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> floorPowerOfTwo(vecType<L, T, P> const & v)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> floorPowerOfTwo(vec<L, T, P> const & v)
{
return detail::functor1<L, T, T, P>::call(floorPowerOfTwo, v);
}
@ -270,8 +270,8 @@ namespace detail
return (next - value) < (value - prev) ? next : prev;
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> roundPowerOfTwo(vecType<L, T, P> const & v)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> roundPowerOfTwo(vec<L, T, P> const & v)
{
return detail::functor1<L, T, T, P>::call(roundPowerOfTwo, v);
}
@ -285,16 +285,16 @@ namespace detail
return isMultiple(vec<1, genType>(Value), vec<1, genType>(Multiple)).x;
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, bool, P> isMultiple(vecType<L, T, P> const & Value, T Multiple)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, bool, P> isMultiple(vec<L, T, P> const & Value, T Multiple)
{
return (Value % Multiple) == vecType<L, T, P>(0);
return (Value % Multiple) == vec<L, T, P>(0);
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, bool, P> isMultiple(vecType<L, T, P> const & Value, vecType<L, T, P> const & Multiple)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, bool, P> isMultiple(vec<L, T, P> const& Value, vec<L, T, P> const& Multiple)
{
return (Value % Multiple) == vecType<L, T, P>(0);
return (Value % Multiple) == vec<L, T, P>(0);
}
//////////////////////
@ -306,8 +306,8 @@ namespace detail
return detail::compute_ceilMultiple<std::numeric_limits<genType>::is_iec559, std::numeric_limits<genType>::is_signed>::call(Source, Multiple);
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> ceilMultiple(vecType<L, T, P> const & Source, vecType<L, T, P> const & Multiple)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> ceilMultiple(vec<L, T, P> const& Source, vec<L, T, P> const& Multiple)
{
return detail::functor2<L, T, P>::call(ceilMultiple, Source, Multiple);
}
@ -321,8 +321,8 @@ namespace detail
return detail::compute_floorMultiple<std::numeric_limits<genType>::is_iec559, std::numeric_limits<genType>::is_signed>::call(Source, Multiple);
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> floorMultiple(vecType<L, T, P> const & Source, vecType<L, T, P> const & Multiple)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> floorMultiple(vec<L, T, P> const& Source, vec<L, T, P> const& Multiple)
{
return detail::functor2<L, T, P>::call(floorMultiple, Source, Multiple);
}
@ -336,8 +336,8 @@ namespace detail
return detail::compute_roundMultiple<std::numeric_limits<genType>::is_iec559, std::numeric_limits<genType>::is_signed>::call(Source, Multiple);
}
template<length_t L, typename T, precision P, template<length_t, typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, T, P> roundMultiple(vecType<L, T, P> const & Source, vecType<L, T, P> const & Multiple)
template<length_t L, typename T, precision P>
GLM_FUNC_QUALIFIER vec<L, T, P> roundMultiple(vec<L, T, P> const& Source, vec<L, T, P> const& Multiple)
{
return detail::functor2<L, T, P>::call(roundMultiple, Source, Multiple);
}

View File

@ -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<float>::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<float>::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<float>::call(t, x))
{ // raise underflow flag
GLM_SET_FLOAT_WORD(y,hx);
return y;
}
@ -127,11 +136,16 @@ namespace detail
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
if(detail::compute_equal<double>::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<double>::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<double>::call(t, x))
{ // raise underflow flag
GLM_INSERT_WORDS(y,hx,lx);
return y;
}

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -15,17 +15,17 @@ enum result
namespace bitfieldInsert
{
template<typename genType, typename sizeType>
template<typename genType>
struct type
{
genType Base;
genType Insert;
sizeType Offset;
sizeType Bits;
int Offset;
int Bits;
genType Return;
};
typedef type<glm::uint, glm::uint> typeU32;
typedef type<glm::uint> 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<typename genType, typename sizeType>
template<typename genType>
struct type
{
genType Value;
sizeType Offset;
sizeType Bits;
int Offset;
int Bits;
genType Return;
result Result;
};
typedef type<glm::uint, glm::uint> typeU32;
typedef type<glm::uint> 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<typename genIUType>
GLM_FUNC_QUALIFIER int findMSB_intrinsic(genIUType Value)
static int findMSB_intrinsic(genIUType Value)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::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<typename genIUType>
GLM_FUNC_QUALIFIER int findMSB_avx(genIUType Value)
static int findMSB_avx(genIUType Value)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::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<typename genIUType>
GLM_FUNC_QUALIFIER int findMSB_095(genIUType Value)
static int findMSB_095(genIUType Value)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::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<int>(Bit);
}
else //if(Value < 0)
{
@ -589,7 +589,7 @@ namespace findMSB
}
template<typename genIUType>
GLM_FUNC_QUALIFIER int findMSB_nlz1(genIUType x)
static int findMSB_nlz1(genIUType x)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::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<int>(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<int, int> 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<int, int>); ++i)
{
int Result = findMSB_nlz2(Data[i].Value);
int Result = findMSB_nlz2(static_cast<unsigned int>(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<int, int>); ++i)
{
int Result = findMSB_095(Data[i].Value);
int Result = findMSB_095(static_cast<unsigned int>(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<int, int>); ++i)
{
int Result = findMSB_pop(Data[i].Value);
int Result = findMSB_pop(static_cast<unsigned int>(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();
# endif
std::printf("glm::findMSB: %d clocks\n", static_cast<unsigned int>(Timestamps1 - Timestamps0));
std::printf("findMSB - nlz1: %d clocks\n", static_cast<unsigned int>(Timestamps2 - Timestamps1));
@ -758,7 +757,7 @@ namespace findMSB
return Error;
}
int test_ivec4()
static int test_ivec4()
{
type<glm::ivec4, glm::ivec4> const Data[] =
{
@ -810,7 +809,7 @@ namespace findMSB
return Error;
}
int test_int()
static int test_int()
{
typedef type<glm::uint, int> 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<typename genIUType>
GLM_FUNC_QUALIFIER int findLSB_intrinsic(genIUType Value)
static int findLSB_intrinsic(genIUType Value)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'findLSB' only accept integer values");
@ -956,7 +955,7 @@ namespace findLSB
# endif
template<typename genIUType>
GLM_FUNC_QUALIFIER int findLSB_095(genIUType Value)
static int findLSB_095(genIUType Value)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'findLSB' only accept integer values");
if(Value == 0)
@ -968,7 +967,7 @@ namespace findLSB
}
template<typename genIUType>
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<typename genIUType>
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<int>(glm::bitCount(~x & (x - static_cast<genIUType>(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<glm::length_t L, typename T, glm::precision P, template<glm::length_t, typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER vecType<L, int, P> bitCount_bitfield(vecType<L, T, P> const & v)
static vecType<L, int, P> bitCount_bitfield(vecType<L, T, P> const & v)
{
vecType<L, typename glm::detail::make_unsigned<T>::type, P> x(*reinterpret_cast<vecType<L, typename glm::detail::make_unsigned<T>::type, P> const *>(&v));
x = compute_bitfieldBitCountStep<sizeof(T) * 8 >= 2>::call(x, typename glm::detail::make_unsigned<T>::type(0x5555555555555555ull), typename glm::detail::make_unsigned<T>::type( 1));
@ -1429,12 +1428,12 @@ namespace bitCount
}
template<typename genType>
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;
# else
std::size_t const Samples = 1;
# endif
::bitCount::perf(Samples);
::bitfieldReverse::perf(Samples);
::findMSB::perf(Samples);
::findLSB::perf(Samples);
# endif
return Error;
}

View File

@ -4,7 +4,7 @@
#include <glm/vector_relational.hpp>
#include <glm/gtc/vec1.hpp>
int test_not()
static int test_not()
{
int Error(0);

View File

@ -2,7 +2,7 @@
#include <glm/gtc/vec1.hpp>
#include <glm/gtc/quaternion.hpp>
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;

View File

@ -1,6 +1,6 @@
#include <glm/glm.hpp>
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;