mirror of
https://github.com/g-truc/glm.git
synced 2024-11-13 22:01:46 +00:00
Replace function instanciations with macros by templates
This commit is contained in:
parent
3e099707a1
commit
0042517167
BIN
doc/glm.docx
BIN
doc/glm.docx
Binary file not shown.
@ -33,6 +33,89 @@
|
|||||||
#include "type_vec3.hpp"
|
#include "type_vec3.hpp"
|
||||||
#include "type_vec4.hpp"
|
#include "type_vec4.hpp"
|
||||||
|
|
||||||
|
namespace glm{
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
struct functor1{};
|
||||||
|
|
||||||
|
template <typename T, precision P>
|
||||||
|
struct functor1<T, P, tvec1>
|
||||||
|
{
|
||||||
|
GLM_FUNC_QUALIFIER static tvec1<T, P> call(T (*Func) (T x), tvec1<T, P> const & v)
|
||||||
|
{
|
||||||
|
return tvec1<T, P>(Func(v.x));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T, precision P>
|
||||||
|
struct functor1<T, P, tvec2>
|
||||||
|
{
|
||||||
|
GLM_FUNC_QUALIFIER static tvec2<T, P> call(T (*Func) (T x), tvec2<T, P> const & v)
|
||||||
|
{
|
||||||
|
return tvec2<T, P>(Func(v.x), Func(v.y));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T, precision P>
|
||||||
|
struct functor1<T, P, tvec3>
|
||||||
|
{
|
||||||
|
GLM_FUNC_QUALIFIER static tvec3<T, P> call(T (*Func) (T x), tvec3<T, P> const & v)
|
||||||
|
{
|
||||||
|
return tvec3<T, P>(Func(v.x), Func(v.y), Func(v.z));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T, precision P>
|
||||||
|
struct functor1<T, P, tvec4>
|
||||||
|
{
|
||||||
|
GLM_FUNC_QUALIFIER static tvec4<T, P> call(T (*Func) (T x), tvec4<T, P> const & v)
|
||||||
|
{
|
||||||
|
return tvec4<T, P>(Func(v.x), Func(v.y), Func(v.z), Func(v.w));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
struct functor2{};
|
||||||
|
|
||||||
|
template <typename T, precision P>
|
||||||
|
struct functor2<T, P, tvec1>
|
||||||
|
{
|
||||||
|
GLM_FUNC_QUALIFIER static tvec1<T, P> call(T (*Func) (T x, T y), tvec1<T, P> const & a, tvec1<T, P> const & b)
|
||||||
|
{
|
||||||
|
return tvec1<T, P>(Func(a.x, b.x));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T, precision P>
|
||||||
|
struct functor2<T, P, tvec2>
|
||||||
|
{
|
||||||
|
GLM_FUNC_QUALIFIER static tvec2<T, P> call(T (*Func) (T x, T y), tvec2<T, P> const & a, tvec2<T, P> const & b)
|
||||||
|
{
|
||||||
|
return tvec2<T, P>(Func(a.x, b.x), Func(a.y, b.y));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T, precision P>
|
||||||
|
struct functor2<T, P, tvec3>
|
||||||
|
{
|
||||||
|
GLM_FUNC_QUALIFIER static tvec3<T, P> call(T (*Func) (T x, T y), tvec3<T, P> const & a, tvec3<T, P> const & b)
|
||||||
|
{
|
||||||
|
return tvec3<T, P>(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T, precision P>
|
||||||
|
struct functor2<T, P, tvec4>
|
||||||
|
{
|
||||||
|
GLM_FUNC_QUALIFIER static tvec4<T, P> call(T (*Func) (T x, T y), tvec4<T, P> const & a, tvec4<T, P> const & b)
|
||||||
|
{
|
||||||
|
return tvec4<T, P>(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z), Func(a.w, b.w));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}//namespace detail
|
||||||
|
}//namespace glm
|
||||||
|
|
||||||
#define VECTORIZE1_VEC(func) \
|
#define VECTORIZE1_VEC(func) \
|
||||||
template <typename T, precision P> \
|
template <typename T, precision P> \
|
||||||
GLM_FUNC_QUALIFIER tvec1<T, P> func( \
|
GLM_FUNC_QUALIFIER tvec1<T, P> func( \
|
||||||
|
@ -52,7 +52,7 @@ namespace glm
|
|||||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/abs.xml">GLSL abs man page</a>
|
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/abs.xml">GLSL abs 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://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType abs(genType const & x);
|
GLM_FUNC_DECL genType abs(genType x);
|
||||||
|
|
||||||
/// Returns 1.0 if x > 0, 0.0 if x == 0, or -1.0 if x < 0.
|
/// Returns 1.0 if x > 0, 0.0 if x == 0, or -1.0 if x < 0.
|
||||||
///
|
///
|
||||||
@ -61,7 +61,7 @@ namespace glm
|
|||||||
/// @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/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>
|
/// @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>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType sign(genType const & x);
|
GLM_FUNC_DECL genType sign(genType x);
|
||||||
|
|
||||||
/// Returns a value equal to the nearest integer that is less then or equal to x.
|
/// Returns a value equal to the nearest integer that is less then or equal to x.
|
||||||
///
|
///
|
||||||
@ -70,7 +70,7 @@ namespace glm
|
|||||||
/// @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/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>
|
/// @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>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType floor(genType const & x);
|
GLM_FUNC_DECL genType floor(genType x);
|
||||||
|
|
||||||
/// Returns a value equal to the nearest integer to x
|
/// Returns a value equal to the nearest integer to x
|
||||||
/// whose absolute value is not larger than the absolute value of x.
|
/// whose absolute value is not larger than the absolute value of x.
|
||||||
@ -80,7 +80,7 @@ namespace glm
|
|||||||
/// @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/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>
|
/// @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>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType trunc(genType const & x);
|
GLM_FUNC_DECL genType trunc(genType x);
|
||||||
|
|
||||||
/// Returns a value equal to the nearest integer to x.
|
/// Returns a value equal to the nearest integer to x.
|
||||||
/// The fraction 0.5 will round in a direction chosen by the
|
/// The fraction 0.5 will round in a direction chosen by the
|
||||||
@ -93,7 +93,7 @@ namespace glm
|
|||||||
/// @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/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>
|
/// @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>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType round(genType const & x);
|
GLM_FUNC_DECL genType round(genType x);
|
||||||
|
|
||||||
/// Returns a value equal to the nearest integer to x.
|
/// Returns a value equal to the nearest integer to x.
|
||||||
/// A fractional part of 0.5 will round toward the nearest even
|
/// A fractional part of 0.5 will round toward the nearest even
|
||||||
@ -105,7 +105,7 @@ namespace glm
|
|||||||
/// @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://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>
|
/// @see <a href="http://developer.amd.com/documentation/articles/pages/New-Round-to-Even-Technique.aspx">New round to even technique</a>
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType roundEven(genType const & x);
|
GLM_FUNC_DECL genType roundEven(genType x);
|
||||||
|
|
||||||
/// Returns a value equal to the nearest integer
|
/// Returns a value equal to the nearest integer
|
||||||
/// that is greater than or equal to x.
|
/// that is greater than or equal to x.
|
||||||
@ -115,7 +115,7 @@ namespace glm
|
|||||||
/// @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/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>
|
/// @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>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType ceil(genType const & x);
|
GLM_FUNC_DECL genType ceil(genType x);
|
||||||
|
|
||||||
/// Return x - floor(x).
|
/// Return x - floor(x).
|
||||||
///
|
///
|
||||||
@ -124,7 +124,7 @@ namespace glm
|
|||||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/fract.xml">GLSL fract man page</a>
|
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/fract.xml">GLSL fract 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://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType fract(genType const & x);
|
GLM_FUNC_DECL genType fract(genType x);
|
||||||
|
|
||||||
/// Modulus. Returns x - y * floor(x / y)
|
/// Modulus. Returns x - y * floor(x / y)
|
||||||
/// for each component in x using the floating point value y.
|
/// for each component in x using the floating point value y.
|
||||||
@ -134,9 +134,7 @@ namespace glm
|
|||||||
/// @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/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>
|
/// @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>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType mod(
|
GLM_FUNC_DECL genType mod(genType x, genType y);
|
||||||
genType const & x,
|
|
||||||
genType const & y);
|
|
||||||
|
|
||||||
/// Modulus. Returns x - y * floor(x / y)
|
/// Modulus. Returns x - y * floor(x / y)
|
||||||
/// for each component in x using the floating point value y.
|
/// for each component in x using the floating point value y.
|
||||||
@ -146,9 +144,7 @@ namespace glm
|
|||||||
/// @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/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>
|
/// @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>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType mod(
|
GLM_FUNC_DECL genType mod(genType const & x, typename genType::value_type const & y);
|
||||||
genType const & x,
|
|
||||||
typename genType::value_type const & y);
|
|
||||||
|
|
||||||
/// Returns the fractional part of x and sets i to the integer
|
/// Returns the fractional part of x and sets i to the integer
|
||||||
/// part (as a whole number floating point value). Both the
|
/// part (as a whole number floating point value). Both the
|
||||||
@ -160,9 +156,7 @@ namespace glm
|
|||||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/modf.xml">GLSL modf man page</a>
|
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/modf.xml">GLSL modf 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://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType modf(
|
GLM_FUNC_DECL genType modf(genType const & x, genType & i);
|
||||||
genType const & x,
|
|
||||||
genType & i);
|
|
||||||
|
|
||||||
/// Returns y if y < x; otherwise, it returns x.
|
/// Returns y if y < x; otherwise, it returns x.
|
||||||
///
|
///
|
||||||
@ -171,14 +165,10 @@ namespace glm
|
|||||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/min.xml">GLSL min man page</a>
|
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/min.xml">GLSL min 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://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType min(
|
GLM_FUNC_DECL genType min(genType x, genType y);
|
||||||
genType const & x,
|
|
||||||
genType const & y);
|
|
||||||
|
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType min(
|
GLM_FUNC_DECL genType min(genType const & x, typename genType::value_type const & y);
|
||||||
genType const & x,
|
|
||||||
typename genType::value_type const & y);
|
|
||||||
|
|
||||||
/// Returns y if x < y; otherwise, it returns x.
|
/// Returns y if x < y; otherwise, it returns x.
|
||||||
///
|
///
|
||||||
@ -187,14 +177,10 @@ namespace glm
|
|||||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/max.xml">GLSL max man page</a>
|
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/max.xml">GLSL max 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://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType max(
|
GLM_FUNC_DECL genType max(genType x, genType y);
|
||||||
genType const & x,
|
|
||||||
genType const & y);
|
|
||||||
|
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType max(
|
GLM_FUNC_DECL genType max(genType const & x, typename genType::value_type const & y);
|
||||||
genType const & x,
|
|
||||||
typename genType::value_type const & y);
|
|
||||||
|
|
||||||
/// Returns min(max(x, minVal), maxVal) for each component in x
|
/// Returns min(max(x, minVal), maxVal) for each component in x
|
||||||
/// using the floating-point values minVal and maxVal.
|
/// using the floating-point values minVal and maxVal.
|
||||||
@ -204,16 +190,10 @@ namespace glm
|
|||||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/clamp.xml">GLSL clamp man page</a>
|
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/clamp.xml">GLSL clamp 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://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType clamp(
|
GLM_FUNC_DECL genType clamp(genType const & x, genType const & minVal, genType const & maxVal);
|
||||||
genType const & x,
|
|
||||||
genType const & minVal,
|
|
||||||
genType const & maxVal);
|
|
||||||
|
|
||||||
template <typename genType, precision P>
|
template <typename genType, precision P>
|
||||||
GLM_FUNC_DECL genType clamp(
|
GLM_FUNC_DECL genType clamp(genType const & x, typename genType::value_type const & minVal, typename genType::value_type const & maxVal);
|
||||||
genType const & x,
|
|
||||||
typename genType::value_type const & minVal,
|
|
||||||
typename genType::value_type const & maxVal);
|
|
||||||
|
|
||||||
/// If genTypeU is a floating scalar or vector:
|
/// If genTypeU is a floating scalar or vector:
|
||||||
/// Returns x * (1.0 - a) + y * a, i.e., the linear blend of
|
/// Returns x * (1.0 - a) + y * a, i.e., the linear blend of
|
||||||
@ -258,40 +238,27 @@ namespace glm
|
|||||||
/// glm::vec4 u = glm::mix(g, h, r); // Interpolations can be perform per component with a vector for the last parameter.
|
/// glm::vec4 u = glm::mix(g, h, r); // Interpolations can be perform per component with a vector for the last parameter.
|
||||||
/// @endcode
|
/// @endcode
|
||||||
template <typename T, typename U, precision P, template <typename, precision> class vecType>
|
template <typename T, typename U, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_DECL vecType<T, P> mix(
|
GLM_FUNC_DECL vecType<T, P> mix(vecType<T, P> const & x, vecType<T, P> const & y, vecType<U, P> const & a);
|
||||||
vecType<T, P> const & x,
|
|
||||||
vecType<T, P> const & y,
|
|
||||||
vecType<U, P> const & a);
|
|
||||||
|
|
||||||
template <typename T, typename U, precision P, template <typename, precision> class vecType>
|
template <typename T, typename U, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_DECL vecType<T, P> mix(
|
GLM_FUNC_DECL vecType<T, P> mix(vecType<T, P> const & x, vecType<T, P> const & y, U const & a);
|
||||||
vecType<T, P> const & x,
|
|
||||||
vecType<T, P> const & y,
|
|
||||||
U const & a);
|
|
||||||
|
|
||||||
template <typename genTypeT, typename genTypeU>
|
template <typename genTypeT, typename genTypeU>
|
||||||
GLM_FUNC_DECL genTypeT mix(
|
GLM_FUNC_DECL genTypeT mix(genTypeT const & x, genTypeT const & y, genTypeU const & a);
|
||||||
genTypeT const & x,
|
|
||||||
genTypeT const & y,
|
|
||||||
genTypeU const & a);
|
|
||||||
|
|
||||||
/// Returns 0.0 if x < edge, otherwise it returns 1.0 for each component of a genType.
|
/// 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>
|
/// @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>
|
/// @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>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType step(
|
GLM_FUNC_DECL genType step(genType const & edge, genType const & x);
|
||||||
genType const & edge,
|
|
||||||
genType const & x);
|
|
||||||
|
|
||||||
/// Returns 0.0 if x < edge, otherwise it returns 1.0.
|
/// 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/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>
|
/// @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 <typename, precision> class vecType, typename T, precision P>
|
template <template <typename, precision> class vecType, typename T, precision P>
|
||||||
GLM_FUNC_DECL vecType<T, P> step(
|
GLM_FUNC_DECL vecType<T, P> step(T const & edge, vecType<T, P> const & x);
|
||||||
T const & edge,
|
|
||||||
vecType<T, P> const & x);
|
|
||||||
|
|
||||||
/// Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and
|
/// Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and
|
||||||
/// performs smooth Hermite interpolation between 0 and 1
|
/// performs smooth Hermite interpolation between 0 and 1
|
||||||
@ -308,16 +275,10 @@ namespace glm
|
|||||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/smoothstep.xml">GLSL smoothstep man page</a>
|
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/smoothstep.xml">GLSL smoothstep 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://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType smoothstep(
|
GLM_FUNC_DECL genType smoothstep(genType const & edge0, genType const & edge1, genType const & x);
|
||||||
genType const & edge0,
|
|
||||||
genType const & edge1,
|
|
||||||
genType const & x);
|
|
||||||
|
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL genType smoothstep(
|
GLM_FUNC_DECL genType smoothstep(typename genType::value_type const & edge0, typename genType::value_type const & edge1, genType const & x);
|
||||||
typename genType::value_type const & edge0,
|
|
||||||
typename genType::value_type const & edge1,
|
|
||||||
genType const & x);
|
|
||||||
|
|
||||||
/// Returns true if x holds a NaN (not a number)
|
/// Returns true if x holds a NaN (not a number)
|
||||||
/// representation in the underlying implementation's set of
|
/// representation in the underlying implementation's set of
|
||||||
|
@ -131,23 +131,21 @@ namespace detail
|
|||||||
|
|
||||||
// abs
|
// abs
|
||||||
template <typename genFIType>
|
template <typename genFIType>
|
||||||
GLM_FUNC_QUALIFIER genFIType abs
|
GLM_FUNC_QUALIFIER genFIType abs(genFIType x)
|
||||||
(
|
|
||||||
genFIType const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return detail::compute_abs<genFIType, std::numeric_limits<genFIType>::is_signed>::call(x);
|
return detail::compute_abs<genFIType, std::numeric_limits<genFIType>::is_signed>::call(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC(abs)
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> abs(vecType<T, P> const & x)
|
||||||
|
{
|
||||||
|
return detail::functor1<T, P, vecType>::call(abs, x);
|
||||||
|
}
|
||||||
|
|
||||||
// sign
|
// sign
|
||||||
//Try something like based on x >> 31 to get the sign bit
|
//Try something like based on x >> 31 to get the sign bit
|
||||||
template <typename genFIType>
|
template <typename genFIType>
|
||||||
GLM_FUNC_QUALIFIER genFIType sign
|
GLM_FUNC_QUALIFIER genFIType sign(genFIType x)
|
||||||
(
|
|
||||||
genFIType const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(
|
GLM_STATIC_ASSERT(
|
||||||
std::numeric_limits<genFIType>::is_iec559 ||
|
std::numeric_limits<genFIType>::is_iec559 ||
|
||||||
@ -163,49 +161,59 @@ namespace detail
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC(sign)
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> sign(vecType<T, P> const & x)
|
||||||
|
{
|
||||||
|
return detail::functor1<T, P, vecType>::call(sign, x);
|
||||||
|
}
|
||||||
|
|
||||||
// floor
|
// floor
|
||||||
template <typename genType>
|
using ::std::floor;
|
||||||
GLM_FUNC_QUALIFIER genType floor(genType const & x)
|
|
||||||
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> floor(vecType<T, P> const & x)
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(
|
return detail::functor1<T, P, vecType>::call(::std::floor, x);
|
||||||
std::numeric_limits<genType>::is_iec559,
|
|
||||||
"'floor' only accept floating-point inputs");
|
|
||||||
|
|
||||||
return ::std::floor(x);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC(floor)
|
|
||||||
|
|
||||||
// trunc
|
// trunc
|
||||||
template <typename genType>
|
# if GLM_LANG & GLM_LANG_CXX0X_FLAG
|
||||||
GLM_FUNC_QUALIFIER genType trunc(genType const & x)
|
using ::std::trunc;
|
||||||
|
# else
|
||||||
|
template <typename genType>
|
||||||
|
GLM_FUNC_QUALIFIER genType trunc(genType x)
|
||||||
|
{
|
||||||
|
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'trunc' only accept floating-point inputs");
|
||||||
|
|
||||||
|
return x < static_cast<genType>(0) ? -floor(-x) : floor(x);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> trunc(vecType<T, P> const & x)
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(
|
return detail::functor1<T, P, vecType>::call(::std::trunc, x);
|
||||||
std::numeric_limits<genType>::is_iec559,
|
|
||||||
"'trunc' only accept floating-point inputs");
|
|
||||||
|
|
||||||
// TODO, add C++11 std::trunk
|
|
||||||
return x < 0 ? -floor(-x) : floor(x);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC(trunc)
|
|
||||||
|
|
||||||
// round
|
// round
|
||||||
template <typename genType>
|
# if GLM_LANG & GLM_LANG_CXX0X_FLAG
|
||||||
GLM_FUNC_QUALIFIER genType round(genType const& x)
|
using ::std::round;
|
||||||
|
# else
|
||||||
|
template <typename genType>
|
||||||
|
GLM_FUNC_QUALIFIER genType round(genType x)
|
||||||
|
{
|
||||||
|
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'round' only accept floating-point inputs");
|
||||||
|
|
||||||
|
return x < static_cast<genType>(0) ? static_cast<genType>(int(x - static_cast<genType>(0.5))) : static_cast<genType>(int(x + static_cast<genType>(0.5)));
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> round(vecType<T, P> const & x)
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(
|
return detail::functor1<T, P, vecType>::call(::std::round, x);
|
||||||
std::numeric_limits<genType>::is_iec559,
|
|
||||||
"'round' only accept floating-point inputs");
|
|
||||||
|
|
||||||
// TODO, add C++11 std::round
|
|
||||||
return x < 0 ? genType(int(x - genType(0.5))) : genType(int(x + genType(0.5)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC(round)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// roundEven
|
// roundEven
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
@ -219,11 +227,9 @@ namespace detail
|
|||||||
|
|
||||||
// roundEven
|
// roundEven
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType roundEven(genType const & x)
|
GLM_FUNC_QUALIFIER genType roundEven(genType x)
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(
|
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'roundEven' only accept floating-point inputs");
|
||||||
std::numeric_limits<genType>::is_iec559,
|
|
||||||
"'roundEven' only accept floating-point inputs");
|
|
||||||
|
|
||||||
int Integer = static_cast<int>(x);
|
int Integer = static_cast<int>(x);
|
||||||
genType IntegerPart = static_cast<genType>(Integer);
|
genType IntegerPart = static_cast<genType>(Integer);
|
||||||
@ -251,60 +257,56 @@ namespace detail
|
|||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC(roundEven)
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> roundEven(vecType<T, P> const & x)
|
||||||
|
{
|
||||||
|
return detail::functor1<T, P, vecType>::call(roundEven, x);
|
||||||
|
}
|
||||||
|
|
||||||
// ceil
|
// ceil
|
||||||
using std::ceil;
|
using ::std::ceil;
|
||||||
/*
|
|
||||||
template <typename genType>
|
|
||||||
GLM_FUNC_QUALIFIER genType ceil(genType const & x)
|
|
||||||
{
|
|
||||||
GLM_STATIC_ASSERT(
|
|
||||||
std::numeric_limits<genType>::is_iec559,
|
|
||||||
"'ceil' only accept floating-point inputs");
|
|
||||||
|
|
||||||
return ::std::ceil(x);
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> ceil(vecType<T, P> const & x)
|
||||||
|
{
|
||||||
|
return detail::functor1<T, P, vecType>::call(::std::ceil, x);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
VECTORIZE_VEC(ceil)
|
|
||||||
|
|
||||||
// fract
|
// fract
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType fract
|
GLM_FUNC_QUALIFIER genType fract(genType x)
|
||||||
(
|
|
||||||
genType const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'fract' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'fract' only accept floating-point inputs");
|
||||||
|
|
||||||
return x - floor(x);
|
return x - floor(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC(fract)
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> fract(vecType<T, P> const & x)
|
||||||
|
{
|
||||||
|
return detail::functor1<T, P, vecType>::call(fract, x);
|
||||||
|
}
|
||||||
|
|
||||||
// mod
|
// mod
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType mod
|
GLM_FUNC_QUALIFIER genType mod(genType x, genType y)
|
||||||
(
|
|
||||||
genType const & x,
|
|
||||||
genType const & y
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'mod' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'mod' only accept floating-point inputs");
|
||||||
|
|
||||||
return x - y * floor(x / y);
|
return x - y * floor(x / y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> mod(vecType<T, P> const & a, vecType<T, P> const & b)
|
||||||
|
{
|
||||||
|
return detail::functor2<T, P, vecType>::call(mod, a, b);
|
||||||
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC_SCA(mod)
|
VECTORIZE_VEC_SCA(mod)
|
||||||
VECTORIZE_VEC_VEC(mod)
|
|
||||||
|
|
||||||
// modf
|
// modf
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType modf
|
GLM_FUNC_QUALIFIER genType modf(genType const & x, genType & i)
|
||||||
(
|
|
||||||
genType const & x,
|
|
||||||
genType & i
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'modf' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'modf' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -312,22 +314,14 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec1<T, P> modf
|
GLM_FUNC_QUALIFIER tvec1<T, P> modf(tvec1<T, P> const & x, tvec1<T, P> & i)
|
||||||
(
|
|
||||||
tvec1<T, P> const & x,
|
|
||||||
tvec1<T, P> & i
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return tvec1<T, P>(
|
return tvec1<T, P>(
|
||||||
modf(x.x, i.x));
|
modf(x.x, i.x));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec2<T, P> modf
|
GLM_FUNC_QUALIFIER tvec2<T, P> modf(tvec2<T, P> const & x, tvec2<T, P> & i)
|
||||||
(
|
|
||||||
tvec2<T, P> const & x,
|
|
||||||
tvec2<T, P> & i
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return tvec2<T, P>(
|
return tvec2<T, P>(
|
||||||
modf(x.x, i.x),
|
modf(x.x, i.x),
|
||||||
@ -335,11 +329,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec3<T, P> modf
|
GLM_FUNC_QUALIFIER tvec3<T, P> modf(tvec3<T, P> const & x, tvec3<T, P> & i)
|
||||||
(
|
|
||||||
tvec3<T, P> const & x,
|
|
||||||
tvec3<T, P> & i
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return tvec3<T, P>(
|
return tvec3<T, P>(
|
||||||
modf(x.x, i.x),
|
modf(x.x, i.x),
|
||||||
@ -348,11 +338,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec4<T, P> modf
|
GLM_FUNC_QUALIFIER tvec4<T, P> modf(tvec4<T, P> const & x, tvec4<T, P> & i)
|
||||||
(
|
|
||||||
tvec4<T, P> const & x,
|
|
||||||
tvec4<T, P> & i
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return tvec4<T, P>(
|
return tvec4<T, P>(
|
||||||
modf(x.x, i.x),
|
modf(x.x, i.x),
|
||||||
@ -371,67 +357,51 @@ namespace detail
|
|||||||
|
|
||||||
// min
|
// min
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType min
|
GLM_FUNC_QUALIFIER genType min(genType x, genType y)
|
||||||
(
|
|
||||||
genType const & x,
|
|
||||||
genType const & y
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(
|
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559 || std::numeric_limits<genType>::is_integer, "'min' only accept floating-point or integer inputs");
|
||||||
std::numeric_limits<genType>::is_iec559 || std::numeric_limits<genType>::is_integer,
|
|
||||||
"'min' only accept floating-point or integer inputs");
|
|
||||||
|
|
||||||
return x < y ? x : y;
|
return x < y ? x : y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> min(vecType<T, P> const & a, vecType<T, P> const & b)
|
||||||
|
{
|
||||||
|
return detail::functor2<T, P, vecType>::call(min, a, b);
|
||||||
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC_SCA(min)
|
VECTORIZE_VEC_SCA(min)
|
||||||
VECTORIZE_VEC_VEC(min)
|
|
||||||
|
|
||||||
// max
|
// max
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType max
|
GLM_FUNC_QUALIFIER genType max(genType x, genType y)
|
||||||
(
|
|
||||||
genType const & x,
|
|
||||||
genType const & y
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(
|
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559 || std::numeric_limits<genType>::is_integer, "'max' only accept floating-point or integer inputs");
|
||||||
std::numeric_limits<genType>::is_iec559 || std::numeric_limits<genType>::is_integer,
|
|
||||||
"'max' only accept floating-point or integer inputs");
|
|
||||||
|
|
||||||
return x > y ? x : y;
|
return x > y ? x : y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<T, P> max(vecType<T, P> const & a, vecType<T, P> const & b)
|
||||||
|
{
|
||||||
|
return detail::functor2<T, P, vecType>::call(max, a, b);
|
||||||
|
}
|
||||||
|
|
||||||
VECTORIZE_VEC_SCA(max)
|
VECTORIZE_VEC_SCA(max)
|
||||||
VECTORIZE_VEC_VEC(max)
|
|
||||||
|
|
||||||
// clamp
|
// clamp
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType clamp
|
GLM_FUNC_QUALIFIER genType clamp(genType const & x, genType const & minVal, genType const & maxVal)
|
||||||
(
|
|
||||||
genType const & x,
|
|
||||||
genType const & minVal,
|
|
||||||
genType const & maxVal
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(
|
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559 || std::numeric_limits<genType>::is_integer, "'clamp' only accept floating-point or integer inputs");
|
||||||
std::numeric_limits<genType>::is_iec559 || std::numeric_limits<genType>::is_integer,
|
|
||||||
"'clamp' only accept floating-point or integer inputs");
|
|
||||||
|
|
||||||
return min(maxVal, max(minVal, x));
|
return min(maxVal, max(minVal, x));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec2<T, P> clamp
|
GLM_FUNC_QUALIFIER tvec2<T, P> clamp(tvec2<T, P> const & x, T const & minVal, T const & maxVal)
|
||||||
(
|
|
||||||
tvec2<T, P> const & x,
|
|
||||||
T const & minVal,
|
|
||||||
T const & maxVal
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer, "'clamp' only accept floating-point or integer inputs");
|
||||||
std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer,
|
|
||||||
"'clamp' only accept floating-point or integer inputs");
|
|
||||||
|
|
||||||
return tvec2<T, P>(
|
return tvec2<T, P>(
|
||||||
clamp(x.x, minVal, maxVal),
|
clamp(x.x, minVal, maxVal),
|
||||||
@ -439,16 +409,9 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec3<T, P> clamp
|
GLM_FUNC_QUALIFIER tvec3<T, P> clamp(tvec3<T, P> const & x, T const & minVal, T const & maxVal)
|
||||||
(
|
|
||||||
tvec3<T, P> const & x,
|
|
||||||
T const & minVal,
|
|
||||||
T const & maxVal
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer, "'clamp' only accept floating-point or integer inputs");
|
||||||
std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer,
|
|
||||||
"'clamp' only accept floating-point or integer inputs");
|
|
||||||
|
|
||||||
return tvec3<T, P>(
|
return tvec3<T, P>(
|
||||||
clamp(x.x, minVal, maxVal),
|
clamp(x.x, minVal, maxVal),
|
||||||
@ -457,16 +420,9 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec4<T, P> clamp
|
GLM_FUNC_QUALIFIER tvec4<T, P> clamp(tvec4<T, P> const & x, T const & minVal, T const & maxVal)
|
||||||
(
|
|
||||||
tvec4<T, P> const & x,
|
|
||||||
T const & minVal,
|
|
||||||
T const & maxVal
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer, "'clamp' only accept floating-point or integer inputs");
|
||||||
std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer,
|
|
||||||
"'clamp' only accept floating-point or integer inputs");
|
|
||||||
|
|
||||||
return tvec4<T, P>(
|
return tvec4<T, P>(
|
||||||
clamp(x.x, minVal, maxVal),
|
clamp(x.x, minVal, maxVal),
|
||||||
@ -476,16 +432,9 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec2<T, P> clamp
|
GLM_FUNC_QUALIFIER tvec2<T, P> clamp(tvec2<T, P> const & x, tvec2<T, P> const & minVal, tvec2<T, P> const & maxVal)
|
||||||
(
|
|
||||||
tvec2<T, P> const & x,
|
|
||||||
tvec2<T, P> const & minVal,
|
|
||||||
tvec2<T, P> const & maxVal
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer, "'clamp' only accept floating-point or integer inputs");
|
||||||
std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer,
|
|
||||||
"'clamp' only accept floating-point or integer inputs");
|
|
||||||
|
|
||||||
return tvec2<T, P>(
|
return tvec2<T, P>(
|
||||||
clamp(x.x, minVal.x, maxVal.x),
|
clamp(x.x, minVal.x, maxVal.x),
|
||||||
@ -493,16 +442,9 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec3<T, P> clamp
|
GLM_FUNC_QUALIFIER tvec3<T, P> clamp(tvec3<T, P> const & x, tvec3<T, P> const & minVal, tvec3<T, P> const & maxVal)
|
||||||
(
|
|
||||||
tvec3<T, P> const & x,
|
|
||||||
tvec3<T, P> const & minVal,
|
|
||||||
tvec3<T, P> const & maxVal
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer, "'clamp' only accept floating-point or integer inputs");
|
||||||
std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer,
|
|
||||||
"'clamp' only accept floating-point or integer inputs");
|
|
||||||
|
|
||||||
return tvec3<T, P>(
|
return tvec3<T, P>(
|
||||||
clamp(x.x, minVal.x, maxVal.x),
|
clamp(x.x, minVal.x, maxVal.x),
|
||||||
@ -511,16 +453,9 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec4<T, P> clamp
|
GLM_FUNC_QUALIFIER tvec4<T, P> clamp(tvec4<T, P> const & x, tvec4<T, P> const & minVal, tvec4<T, P> const & maxVal)
|
||||||
(
|
|
||||||
tvec4<T, P> const & x,
|
|
||||||
tvec4<T, P> const & minVal,
|
|
||||||
tvec4<T, P> const & maxVal
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer, "'clamp' only accept floating-point or integer inputs");
|
||||||
std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer,
|
|
||||||
"'clamp' only accept floating-point or integer inputs");
|
|
||||||
|
|
||||||
return tvec4<T, P>(
|
return tvec4<T, P>(
|
||||||
clamp(x.x, minVal.x, maxVal.x),
|
clamp(x.x, minVal.x, maxVal.x),
|
||||||
@ -530,55 +465,32 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename U, precision P, template <typename, precision> class vecType>
|
template <typename T, typename U, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> mix
|
GLM_FUNC_QUALIFIER vecType<T, P> mix(vecType<T, P> const & x, vecType<T, P> const & y, vecType<U, P> const & a)
|
||||||
(
|
|
||||||
vecType<T, P> const & x,
|
|
||||||
vecType<T, P> const & y,
|
|
||||||
vecType<U, P> const & a
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return detail::compute_mix_vector<T, U, P, vecType>::call(x, y, a);
|
return detail::compute_mix_vector<T, U, P, vecType>::call(x, y, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename U, precision P, template <typename, precision> class vecType>
|
template <typename T, typename U, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> mix
|
GLM_FUNC_QUALIFIER vecType<T, P> mix(vecType<T, P> const & x, vecType<T, P> const & y, U const & a)
|
||||||
(
|
|
||||||
vecType<T, P> const & x,
|
|
||||||
vecType<T, P> const & y,
|
|
||||||
U const & a
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return detail::compute_mix_scalar<T, U, P, vecType>::call(x, y, a);
|
return detail::compute_mix_scalar<T, U, P, vecType>::call(x, y, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename genTypeT, typename genTypeU>
|
template <typename genTypeT, typename genTypeU>
|
||||||
GLM_FUNC_QUALIFIER genTypeT mix
|
GLM_FUNC_QUALIFIER genTypeT mix(genTypeT const & x, genTypeT const & y, genTypeU const & a)
|
||||||
(
|
|
||||||
genTypeT const & x,
|
|
||||||
genTypeT const & y,
|
|
||||||
genTypeU const & a
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return detail::compute_mix<genTypeT, genTypeU>::call(x, y, a);
|
return detail::compute_mix<genTypeT, genTypeU>::call(x, y, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
// step
|
// step
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType step
|
GLM_FUNC_QUALIFIER genType step(genType const & edge, genType const & x)
|
||||||
(
|
|
||||||
genType const & edge,
|
|
||||||
genType const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return mix(genType(1), genType(0), glm::lessThan(x, edge));
|
return mix(genType(1), genType(0), glm::lessThan(x, edge));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <template <typename, precision> class vecType, typename T, precision P>
|
template <template <typename, precision> class vecType, typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> step
|
GLM_FUNC_QUALIFIER vecType<T, P> step(T const & edge, vecType<T, P> const & x)
|
||||||
(
|
|
||||||
T const & edge,
|
|
||||||
vecType<T, P> const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'step' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'step' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -587,12 +499,7 @@ namespace detail
|
|||||||
|
|
||||||
// smoothstep
|
// smoothstep
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType smoothstep
|
GLM_FUNC_QUALIFIER genType smoothstep(genType const & edge0, genType const & edge1, genType const & x)
|
||||||
(
|
|
||||||
genType const & edge0,
|
|
||||||
genType const & edge1,
|
|
||||||
genType const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'smoothstep' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'smoothstep' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -601,12 +508,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec2<T, P> smoothstep
|
GLM_FUNC_QUALIFIER tvec2<T, P> smoothstep(T const & edge0, T const & edge1, tvec2<T, P> const & x)
|
||||||
(
|
|
||||||
T const & edge0,
|
|
||||||
T const & edge1,
|
|
||||||
tvec2<T, P> const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'smoothstep' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'smoothstep' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -616,12 +518,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec3<T, P> smoothstep
|
GLM_FUNC_QUALIFIER tvec3<T, P> smoothstep(T const & edge0, T const & edge1, tvec3<T, P> const & x)
|
||||||
(
|
|
||||||
T const & edge0,
|
|
||||||
T const & edge1,
|
|
||||||
tvec3<T, P> const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'smoothstep' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'smoothstep' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -632,12 +529,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec4<T, P> smoothstep
|
GLM_FUNC_QUALIFIER tvec4<T, P> smoothstep(T const & edge0, T const & edge1, tvec4<T, P> const & x)
|
||||||
(
|
|
||||||
T const & edge0,
|
|
||||||
T const & edge1,
|
|
||||||
tvec4<T, P> const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'smoothstep' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'smoothstep' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -649,12 +541,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec2<T, P> smoothstep
|
GLM_FUNC_QUALIFIER tvec2<T, P> smoothstep(tvec2<T, P> const & edge0, tvec2<T, P> const & edge1, tvec2<T, P> const & x)
|
||||||
(
|
|
||||||
tvec2<T, P> const & edge0,
|
|
||||||
tvec2<T, P> const & edge1,
|
|
||||||
tvec2<T, P> const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'smoothstep' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'smoothstep' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -664,12 +551,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec3<T, P> smoothstep
|
GLM_FUNC_QUALIFIER tvec3<T, P> smoothstep(tvec3<T, P> const & edge0, tvec3<T, P> const & edge1, tvec3<T, P> const & x)
|
||||||
(
|
|
||||||
tvec3<T, P> const & edge0,
|
|
||||||
tvec3<T, P> const & edge1,
|
|
||||||
tvec3<T, P> const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'smoothstep' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'smoothstep' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -680,12 +562,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec4<T, P> smoothstep
|
GLM_FUNC_QUALIFIER tvec4<T, P> smoothstep(tvec4<T, P> const & edge0, tvec4<T, P> const & edge1, tvec4<T, P> const & x)
|
||||||
(
|
|
||||||
tvec4<T, P> const & edge0,
|
|
||||||
tvec4<T, P> const & edge1,
|
|
||||||
tvec4<T, P> const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'smoothstep' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'smoothstep' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -720,10 +597,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER typename tvec1<T, P>::bool_type isnan
|
GLM_FUNC_QUALIFIER typename tvec1<T, P>::bool_type isnan(tvec1<T, P> const & x)
|
||||||
(
|
|
||||||
tvec1<T, P> const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isnan' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isnan' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -732,10 +606,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER typename tvec2<T, P>::bool_type isnan
|
GLM_FUNC_QUALIFIER typename tvec2<T, P>::bool_type isnan(tvec2<T, P> const & x)
|
||||||
(
|
|
||||||
tvec2<T, P> const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isnan' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isnan' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -745,10 +616,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER typename tvec3<T, P>::bool_type isnan
|
GLM_FUNC_QUALIFIER typename tvec3<T, P>::bool_type isnan(tvec3<T, P> const & x)
|
||||||
(
|
|
||||||
tvec3<T, P> const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isnan' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isnan' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -759,10 +627,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER typename tvec4<T, P>::bool_type isnan
|
GLM_FUNC_QUALIFIER typename tvec4<T, P>::bool_type isnan(tvec4<T, P> const & x)
|
||||||
(
|
|
||||||
tvec4<T, P> const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isnan' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isnan' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -774,8 +639,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER bool isinf(
|
GLM_FUNC_QUALIFIER bool isinf(genType const & x)
|
||||||
genType const & x)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'isinf' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'isinf' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -798,10 +662,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER typename tvec1<T, P>::bool_type isinf
|
GLM_FUNC_QUALIFIER typename tvec1<T, P>::bool_type isinf(tvec1<T, P> const & x)
|
||||||
(
|
|
||||||
tvec1<T, P> const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isinf' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isinf' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -810,10 +671,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER typename tvec2<T, P>::bool_type isinf
|
GLM_FUNC_QUALIFIER typename tvec2<T, P>::bool_type isinf(tvec2<T, P> const & x)
|
||||||
(
|
|
||||||
tvec2<T, P> const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isinf' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isinf' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -823,10 +681,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER typename tvec3<T, P>::bool_type isinf
|
GLM_FUNC_QUALIFIER typename tvec3<T, P>::bool_type isinf(tvec3<T, P> const & x)
|
||||||
(
|
|
||||||
tvec3<T, P> const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isinf' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isinf' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -837,10 +692,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER typename tvec4<T, P>::bool_type isinf
|
GLM_FUNC_QUALIFIER typename tvec4<T, P>::bool_type isinf(tvec4<T, P> const & x)
|
||||||
(
|
|
||||||
tvec4<T, P> const & x
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isinf' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isinf' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -896,22 +748,13 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType fma
|
GLM_FUNC_QUALIFIER genType fma(genType const & a, genType const & b, genType const & c)
|
||||||
(
|
|
||||||
genType const & a,
|
|
||||||
genType const & b,
|
|
||||||
genType const & c
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return a * b + c;
|
return a * b + c;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType frexp
|
GLM_FUNC_QUALIFIER genType frexp(genType const & x, int & exp)
|
||||||
(
|
|
||||||
genType const & x,
|
|
||||||
int & exp
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'frexp' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'frexp' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -919,11 +762,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec1<T, P> frexp
|
GLM_FUNC_QUALIFIER tvec1<T, P> frexp(tvec1<T, P> const & x, tvec1<int, P> & exp)
|
||||||
(
|
|
||||||
tvec1<T, P> const & x,
|
|
||||||
tvec1<int, P> & exp
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'frexp' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'frexp' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -931,11 +770,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec2<T, P> frexp
|
GLM_FUNC_QUALIFIER tvec2<T, P> frexp(tvec2<T, P> const & x, tvec2<int, P> & exp)
|
||||||
(
|
|
||||||
tvec2<T, P> const & x,
|
|
||||||
tvec2<int, P> & exp
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'frexp' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'frexp' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -945,11 +780,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec3<T, P> frexp
|
GLM_FUNC_QUALIFIER tvec3<T, P> frexp(tvec3<T, P> const & x, tvec3<int, P> & exp)
|
||||||
(
|
|
||||||
tvec3<T, P> const & x,
|
|
||||||
tvec3<int, P> & exp
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'frexp' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'frexp' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -960,11 +791,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec4<T, P> frexp
|
GLM_FUNC_QUALIFIER tvec4<T, P> frexp(tvec4<T, P> const & x, tvec4<int, P> & exp)
|
||||||
(
|
|
||||||
tvec4<T, P> const & x,
|
|
||||||
tvec4<int, P> & exp
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'frexp' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'frexp' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -976,11 +803,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename genType, precision P>
|
template <typename genType, precision P>
|
||||||
GLM_FUNC_QUALIFIER genType ldexp
|
GLM_FUNC_QUALIFIER genType ldexp(genType const & x, int const & exp)
|
||||||
(
|
|
||||||
genType const & x,
|
|
||||||
int const & exp
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'ldexp' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'ldexp' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -988,11 +811,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec1<T, P> ldexp
|
GLM_FUNC_QUALIFIER tvec1<T, P> ldexp(tvec1<T, P> const & x, tvec1<int, P> const & exp)
|
||||||
(
|
|
||||||
tvec1<T, P> const & x,
|
|
||||||
tvec1<int, P> const & exp
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'ldexp' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'ldexp' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -1001,11 +820,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec2<T, P> ldexp
|
GLM_FUNC_QUALIFIER tvec2<T, P> ldexp(tvec2<T, P> const & x, tvec2<int, P> const & exp)
|
||||||
(
|
|
||||||
tvec2<T, P> const & x,
|
|
||||||
tvec2<int, P> const & exp
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'ldexp' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'ldexp' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -1015,11 +830,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec3<T, P> ldexp
|
GLM_FUNC_QUALIFIER tvec3<T, P> ldexp(tvec3<T, P> const & x, tvec3<int, P> const & exps)
|
||||||
(
|
|
||||||
tvec3<T, P> const & x,
|
|
||||||
tvec3<int, P> const & exp
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'ldexp' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'ldexp' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -1030,11 +841,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec4<T, P> ldexp
|
GLM_FUNC_QUALIFIER tvec4<T, P> ldexp(tvec4<T, P> const & x, tvec4<int, P> const & exp)
|
||||||
(
|
|
||||||
tvec4<T, P> const & x,
|
|
||||||
tvec4<int, P> const & exp
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'ldexp' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'ldexp' only accept floating-point inputs");
|
||||||
|
|
||||||
@ -1044,5 +851,4 @@ namespace detail
|
|||||||
ldexp(x.z, exp.z),
|
ldexp(x.z, exp.z),
|
||||||
ldexp(x.w, exp.w));
|
ldexp(x.w, exp.w));
|
||||||
}
|
}
|
||||||
|
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
@ -16,6 +16,79 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
int test_floor()
|
||||||
|
{
|
||||||
|
int Error(0);
|
||||||
|
|
||||||
|
{
|
||||||
|
float A(1.1f);
|
||||||
|
float B = glm::floor(A);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
double A(1.1f);
|
||||||
|
double B = glm::floor(A);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
glm::vec1 A(1.1f);
|
||||||
|
glm::vec1 B = glm::floor(A);
|
||||||
|
|
||||||
|
Error += glm::all(glm::epsilonEqual(B, glm::vec1(1.0), 0.0001f)) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
glm::dvec1 A(1.1f);
|
||||||
|
glm::dvec1 B = glm::floor(A);
|
||||||
|
|
||||||
|
Error += glm::all(glm::epsilonEqual(B, glm::dvec1(1.0), 0.0001)) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
glm::vec2 A(1.1f);
|
||||||
|
glm::vec2 B = glm::floor(A);
|
||||||
|
|
||||||
|
Error += glm::all(glm::epsilonEqual(B, glm::vec2(1.0), 0.0001f)) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
glm::dvec2 A(1.1f);
|
||||||
|
glm::dvec2 B = glm::floor(A);
|
||||||
|
|
||||||
|
Error += glm::all(glm::epsilonEqual(B, glm::dvec2(1.0), 0.0001)) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
glm::vec3 A(1.1f);
|
||||||
|
glm::vec3 B = glm::floor(A);
|
||||||
|
|
||||||
|
Error += glm::all(glm::epsilonEqual(B, glm::vec3(1.0), 0.0001f)) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
glm::dvec3 A(1.1f);
|
||||||
|
glm::dvec3 B = glm::floor(A);
|
||||||
|
|
||||||
|
Error += glm::all(glm::epsilonEqual(B, glm::dvec3(1.0), 0.0001)) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
glm::vec4 A(1.1f);
|
||||||
|
glm::vec4 B = glm::floor(A);
|
||||||
|
|
||||||
|
Error += glm::all(glm::epsilonEqual(B, glm::vec4(1.0), 0.0001f)) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
glm::dvec4 A(1.1f);
|
||||||
|
glm::dvec4 B = glm::floor(A);
|
||||||
|
|
||||||
|
Error += glm::all(glm::epsilonEqual(B, glm::dvec4(1.0), 0.0001)) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
||||||
int test_modf()
|
int test_modf()
|
||||||
{
|
{
|
||||||
int Error(0);
|
int Error(0);
|
||||||
@ -685,6 +758,7 @@ int main()
|
|||||||
{
|
{
|
||||||
int Error(0);
|
int Error(0);
|
||||||
|
|
||||||
|
Error += test_floor();
|
||||||
Error += test_modf();
|
Error += test_modf();
|
||||||
Error += test_floatBitsToInt();
|
Error += test_floatBitsToInt();
|
||||||
Error += test_floatBitsToUint();
|
Error += test_floatBitsToUint();
|
||||||
|
Loading…
Reference in New Issue
Block a user