Vectorize
This commit is contained in:
parent
d070f7cf77
commit
e6fded40dc
@ -26,7 +26,7 @@
|
|||||||
/// @author Christophe Riccio
|
/// @author Christophe Riccio
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define VECTORIZE_1PARAM(func) \
|
#define VECTORIZE_VEC(func) \
|
||||||
template <typename T> \
|
template <typename T> \
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<T> func( \
|
GLM_FUNC_QUALIFIER detail::tvec2<T> func( \
|
||||||
detail::tvec2<T> const & v) \
|
detail::tvec2<T> const & v) \
|
||||||
@ -57,7 +57,47 @@
|
|||||||
func(v.w)); \
|
func(v.w)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define VECTORIZE_2PARAMS(func) \
|
#define VECTORIZE_VEC_SCA(func) \
|
||||||
|
template <typename T> \
|
||||||
|
GLM_FUNC_QUALIFIER detail::tvec2<T> func \
|
||||||
|
( \
|
||||||
|
detail::tvec2<T> const & x, \
|
||||||
|
typename detail::tvec2<T>::value_type const & y \
|
||||||
|
) \
|
||||||
|
{ \
|
||||||
|
return detail::tvec2<T>( \
|
||||||
|
func(x.x, y), \
|
||||||
|
func(x.y, y)); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
template <typename T> \
|
||||||
|
GLM_FUNC_QUALIFIER detail::tvec3<T> func \
|
||||||
|
( \
|
||||||
|
detail::tvec3<T> const & x, \
|
||||||
|
typename detail::tvec3<T>::value_type const & y \
|
||||||
|
) \
|
||||||
|
{ \
|
||||||
|
return detail::tvec3<T>( \
|
||||||
|
func(x.x, y), \
|
||||||
|
func(x.y, y), \
|
||||||
|
func(x.z, y)); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
template <typename T> \
|
||||||
|
GLM_FUNC_QUALIFIER detail::tvec4<T> func \
|
||||||
|
( \
|
||||||
|
detail::tvec4<T> const & x, \
|
||||||
|
typename detail::tvec4<T>::value_type const & y \
|
||||||
|
) \
|
||||||
|
{ \
|
||||||
|
return detail::tvec4<T>( \
|
||||||
|
func(x.x, y), \
|
||||||
|
func(x.y, y), \
|
||||||
|
func(x.z, y), \
|
||||||
|
func(x.w, y)); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define VECTORIZE_VEC_VEC(func) \
|
||||||
template <typename T> \
|
template <typename T> \
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<T> func \
|
GLM_FUNC_QUALIFIER detail::tvec2<T> func \
|
||||||
( \
|
( \
|
||||||
|
@ -70,7 +70,7 @@ namespace detail
|
|||||||
return detail::Abs_<genFIType, std::numeric_limits<genFIType>::is_signed>::get(x);
|
return detail::Abs_<genFIType, std::numeric_limits<genFIType>::is_signed>::get(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_1PARAM(abs)
|
VECTORIZE_VEC(abs)
|
||||||
|
|
||||||
// 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
|
||||||
@ -94,7 +94,7 @@ namespace detail
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_1PARAM(sign)
|
VECTORIZE_VEC(sign)
|
||||||
|
|
||||||
// floor
|
// floor
|
||||||
template <>
|
template <>
|
||||||
@ -111,7 +111,7 @@ namespace detail
|
|||||||
return ::std::floor(x);
|
return ::std::floor(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_1PARAM(floor)
|
VECTORIZE_VEC(floor)
|
||||||
|
|
||||||
// trunc
|
// trunc
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
@ -121,7 +121,7 @@ namespace detail
|
|||||||
return x < 0 ? -floor(-x) : floor(x);
|
return x < 0 ? -floor(-x) : floor(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_1PARAM(trunc)
|
VECTORIZE_VEC(trunc)
|
||||||
|
|
||||||
// round
|
// round
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
@ -134,7 +134,7 @@ namespace detail
|
|||||||
return genType(int(x + genType(0.5)));
|
return genType(int(x + genType(0.5)));
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_1PARAM(round)
|
VECTORIZE_VEC(round)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// roundEven
|
// roundEven
|
||||||
@ -161,7 +161,7 @@ namespace detail
|
|||||||
return genType(int(x + RoundValue));
|
return genType(int(x + RoundValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_1PARAM(roundEven)
|
VECTORIZE_VEC(roundEven)
|
||||||
|
|
||||||
// ceil
|
// ceil
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
@ -172,7 +172,7 @@ namespace detail
|
|||||||
return ::std::ceil(x);
|
return ::std::ceil(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_1PARAM(ceil)
|
VECTORIZE_VEC(ceil)
|
||||||
|
|
||||||
// fract
|
// fract
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
@ -186,7 +186,7 @@ namespace detail
|
|||||||
return x - ::std::floor(x);
|
return x - ::std::floor(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTORIZE_1PARAM(fract)
|
VECTORIZE_VEC(fract)
|
||||||
|
|
||||||
// mod
|
// mod
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
@ -201,83 +201,8 @@ namespace detail
|
|||||||
return x - y * floor(x / y);
|
return x - y * floor(x / y);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
VECTORIZE_VEC_SCA(mod)
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<T> mod
|
VECTORIZE_VEC_VEC(mod)
|
||||||
(
|
|
||||||
detail::tvec2<T> const & x,
|
|
||||||
typename detail::tvec2<T>::value_type const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec2<T>(
|
|
||||||
mod(x.x, y),
|
|
||||||
mod(x.y, y));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<T> mod
|
|
||||||
(
|
|
||||||
detail::tvec3<T> const & x,
|
|
||||||
typename detail::tvec3<T>::value_type const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec3<T>(
|
|
||||||
mod(x.x, y),
|
|
||||||
mod(x.y, y),
|
|
||||||
mod(x.z, y));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<T> mod
|
|
||||||
(
|
|
||||||
detail::tvec4<T> const & x,
|
|
||||||
typename detail::tvec4<T>::value_type const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec4<T>(
|
|
||||||
mod(x.x, y),
|
|
||||||
mod(x.y, y),
|
|
||||||
mod(x.z, y),
|
|
||||||
mod(x.w, y));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<T> mod
|
|
||||||
(
|
|
||||||
detail::tvec2<T> const & x,
|
|
||||||
detail::tvec2<T> const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec2<T>(
|
|
||||||
mod(x.x, y.x),
|
|
||||||
mod(x.y, y.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<T> mod
|
|
||||||
(
|
|
||||||
detail::tvec3<T> const & x,
|
|
||||||
detail::tvec3<T> const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec3<T>(
|
|
||||||
mod(x.x, y.x),
|
|
||||||
mod(x.y, y.y),
|
|
||||||
mod(x.z, y.z));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<T> mod
|
|
||||||
(
|
|
||||||
detail::tvec4<T> const & x,
|
|
||||||
detail::tvec4<T> const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec4<T>(
|
|
||||||
mod(x.x, y.x),
|
|
||||||
mod(x.y, y.y),
|
|
||||||
mod(x.z, y.z),
|
|
||||||
mod(x.w, y.w));
|
|
||||||
}
|
|
||||||
|
|
||||||
// modf
|
// modf
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
@ -298,39 +223,39 @@ namespace detail
|
|||||||
GLM_FUNC_QUALIFIER detail::tvec2<valType> modf
|
GLM_FUNC_QUALIFIER detail::tvec2<valType> modf
|
||||||
(
|
(
|
||||||
detail::tvec2<valType> const & x,
|
detail::tvec2<valType> const & x,
|
||||||
detail::tvec2<valType> const & y
|
detail::tvec2<valType> & i
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return detail::tvec2<valType>(
|
return detail::tvec2<valType>(
|
||||||
modf(x.x, y.x),
|
modf(x.x, i.x),
|
||||||
modf(x.y, y.y));
|
modf(x.y, i.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> modf
|
GLM_FUNC_QUALIFIER detail::tvec3<valType> modf
|
||||||
(
|
(
|
||||||
detail::tvec3<valType> const & x,
|
detail::tvec3<valType> const & x,
|
||||||
detail::tvec3<valType> const & y
|
detail::tvec3<valType> & i
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return detail::tvec3<valType>(
|
return detail::tvec3<valType>(
|
||||||
modf(x.x, y.x),
|
modf(x.x, i.x),
|
||||||
modf(x.y, y.y),
|
modf(x.y, i.y),
|
||||||
modf(x.z, y.z));
|
modf(x.z, i.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<valType> modf
|
GLM_FUNC_QUALIFIER detail::tvec4<valType> modf
|
||||||
(
|
(
|
||||||
detail::tvec4<valType> const & x,
|
detail::tvec4<valType> const & x,
|
||||||
detail::tvec4<valType> const & y
|
detail::tvec4<valType> & i
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return detail::tvec4<valType>(
|
return detail::tvec4<valType>(
|
||||||
modf(x.x, y.x),
|
modf(x.x, i.x),
|
||||||
modf(x.y, y.y),
|
modf(x.y, i.y),
|
||||||
modf(x.z, y.z),
|
modf(x.z, i.z),
|
||||||
modf(x.w, y.w));
|
modf(x.w, i.w));
|
||||||
}
|
}
|
||||||
|
|
||||||
//// Only valid if (INT_MIN <= x-y <= INT_MAX)
|
//// Only valid if (INT_MIN <= x-y <= INT_MAX)
|
||||||
@ -357,83 +282,8 @@ namespace detail
|
|||||||
return x < y ? x : y;
|
return x < y ? x : y;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
VECTORIZE_VEC_SCA(min)
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<T> min
|
VECTORIZE_VEC_VEC(min)
|
||||||
(
|
|
||||||
detail::tvec2<T> const & x,
|
|
||||||
typename detail::tvec2<T>::value_type const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec2<T>(
|
|
||||||
min(x.x, y),
|
|
||||||
min(x.y, y));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<T> min
|
|
||||||
(
|
|
||||||
detail::tvec3<T> const & x,
|
|
||||||
typename detail::tvec3<T>::value_type const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec3<T>(
|
|
||||||
min(x.x, y),
|
|
||||||
min(x.y, y),
|
|
||||||
min(x.z, y));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<T> min
|
|
||||||
(
|
|
||||||
detail::tvec4<T> const & x,
|
|
||||||
typename detail::tvec4<T>::value_type const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec4<T>(
|
|
||||||
min(x.x, y),
|
|
||||||
min(x.y, y),
|
|
||||||
min(x.z, y),
|
|
||||||
min(x.w, y));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<T> min
|
|
||||||
(
|
|
||||||
detail::tvec2<T> const & x,
|
|
||||||
detail::tvec2<T> const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec2<T>(
|
|
||||||
min(x.x, y.x),
|
|
||||||
min(x.y, y.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<T> min
|
|
||||||
(
|
|
||||||
detail::tvec3<T> const & x,
|
|
||||||
detail::tvec3<T> const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec3<T>(
|
|
||||||
min(x.x, y.x),
|
|
||||||
min(x.y, y.y),
|
|
||||||
min(x.z, y.z));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<T> min
|
|
||||||
(
|
|
||||||
detail::tvec4<T> const & x,
|
|
||||||
detail::tvec4<T> const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec4<T>(
|
|
||||||
min(x.x, y.x),
|
|
||||||
min(x.y, y.y),
|
|
||||||
min(x.z, y.z),
|
|
||||||
min(x.w, y.w));
|
|
||||||
}
|
|
||||||
|
|
||||||
// max
|
// max
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
@ -451,82 +301,8 @@ namespace detail
|
|||||||
return x > y ? x : y;
|
return x > y ? x : y;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
VECTORIZE_VEC_SCA(max)
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<T> max
|
VECTORIZE_VEC_VEC(max)
|
||||||
(
|
|
||||||
detail::tvec2<T> const & x,
|
|
||||||
typename detail::tvec2<T>::value_type y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec2<T>(
|
|
||||||
max(x.x, y),
|
|
||||||
max(x.y, y));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<T> max
|
|
||||||
(
|
|
||||||
detail::tvec3<T> const & x,
|
|
||||||
typename detail::tvec3<T>::value_type y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec3<T>(
|
|
||||||
max(x.x, y),
|
|
||||||
max(x.y, y),
|
|
||||||
max(x.z, y));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<T> max
|
|
||||||
(
|
|
||||||
detail::tvec4<T> const & x,
|
|
||||||
typename detail::tvec4<T>::value_type y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec4<T>(
|
|
||||||
max(x.x, y),
|
|
||||||
max(x.y, y),
|
|
||||||
max(x.z, y),
|
|
||||||
max(x.w, y));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<T> max
|
|
||||||
(
|
|
||||||
detail::tvec2<T> const & x,
|
|
||||||
detail::tvec2<T> const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec2<T>(
|
|
||||||
max(x.x, y.x),
|
|
||||||
max(x.y, y.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<T> max
|
|
||||||
(
|
|
||||||
detail::tvec3<T> const & x,
|
|
||||||
detail::tvec3<T> const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec3<T>(
|
|
||||||
max(x.x, y.x),
|
|
||||||
max(x.y, y.y),
|
|
||||||
max(x.z, y.z));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<T> max
|
|
||||||
(
|
|
||||||
detail::tvec4<T> const & x,
|
|
||||||
detail::tvec4<T> const & y)
|
|
||||||
{
|
|
||||||
return detail::tvec4<T>(
|
|
||||||
max(x.x, y.x),
|
|
||||||
max(x.y, y.y),
|
|
||||||
max(x.z, y.z),
|
|
||||||
max(x.w, y.w));
|
|
||||||
}
|
|
||||||
|
|
||||||
// clamp
|
// clamp
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
|
@ -41,44 +41,7 @@ namespace glm
|
|||||||
return ::std::pow(x, y);
|
return ::std::pow(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
VECTORIZE_VEC_VEC(pow)
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<T> pow
|
|
||||||
(
|
|
||||||
detail::tvec2<T> const & x,
|
|
||||||
detail::tvec2<T> const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec2<T>(
|
|
||||||
pow(x.x, y.x),
|
|
||||||
pow(x.y, y.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<T> pow
|
|
||||||
(
|
|
||||||
detail::tvec3<T> const & x,
|
|
||||||
detail::tvec3<T> const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec3<T>(
|
|
||||||
pow(x.x, y.x),
|
|
||||||
pow(x.y, y.y),
|
|
||||||
pow(x.z, y.z));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<T> pow
|
|
||||||
(
|
|
||||||
detail::tvec4<T> const & x,
|
|
||||||
detail::tvec4<T> const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec4<T>(
|
|
||||||
pow(x.x, y.x),
|
|
||||||
pow(x.y, y.y),
|
|
||||||
pow(x.z, y.z),
|
|
||||||
pow(x.w, y.w));
|
|
||||||
}
|
|
||||||
|
|
||||||
// exp
|
// exp
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
@ -92,41 +55,7 @@ namespace glm
|
|||||||
return ::std::exp(x);
|
return ::std::exp(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
VECTORIZE_VEC(exp)
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<T> exp
|
|
||||||
(
|
|
||||||
detail::tvec2<T> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec2<T>(
|
|
||||||
exp(x.x),
|
|
||||||
exp(x.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<T> exp
|
|
||||||
(
|
|
||||||
detail::tvec3<T> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec3<T>(
|
|
||||||
exp(x.x),
|
|
||||||
exp(x.y),
|
|
||||||
exp(x.z));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<T> exp
|
|
||||||
(
|
|
||||||
detail::tvec4<T> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec4<T>(
|
|
||||||
exp(x.x),
|
|
||||||
exp(x.y),
|
|
||||||
exp(x.z),
|
|
||||||
exp(x.w));
|
|
||||||
}
|
|
||||||
|
|
||||||
// log
|
// log
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
@ -140,41 +69,7 @@ namespace glm
|
|||||||
return ::std::log(x);
|
return ::std::log(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
VECTORIZE_VEC(log)
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<T> log
|
|
||||||
(
|
|
||||||
detail::tvec2<T> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec2<T>(
|
|
||||||
log(x.x),
|
|
||||||
log(x.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<T> log
|
|
||||||
(
|
|
||||||
detail::tvec3<T> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec3<T>(
|
|
||||||
log(x.x),
|
|
||||||
log(x.y),
|
|
||||||
log(x.z));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<T> log
|
|
||||||
(
|
|
||||||
detail::tvec4<T> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec4<T>(
|
|
||||||
log(x.x),
|
|
||||||
log(x.y),
|
|
||||||
log(x.z),
|
|
||||||
log(x.w));
|
|
||||||
}
|
|
||||||
|
|
||||||
//exp2, ln2 = 0.69314718055994530941723212145818f
|
//exp2, ln2 = 0.69314718055994530941723212145818f
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
@ -188,41 +83,7 @@ namespace glm
|
|||||||
return ::std::exp(genType(0.69314718055994530941723212145818) * x);
|
return ::std::exp(genType(0.69314718055994530941723212145818) * x);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
VECTORIZE_VEC(exp2)
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<T> exp2
|
|
||||||
(
|
|
||||||
detail::tvec2<T> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec2<T>(
|
|
||||||
exp2(x.x),
|
|
||||||
exp2(x.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<T> exp2
|
|
||||||
(
|
|
||||||
detail::tvec3<T> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec3<T>(
|
|
||||||
exp2(x.x),
|
|
||||||
exp2(x.y),
|
|
||||||
exp2(x.z));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<T> exp2
|
|
||||||
(
|
|
||||||
detail::tvec4<T> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec4<T>(
|
|
||||||
exp2(x.x),
|
|
||||||
exp2(x.y),
|
|
||||||
exp2(x.z),
|
|
||||||
exp2(x.w));
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
@ -255,44 +116,11 @@ namespace detail
|
|||||||
genType const & x
|
genType const & x
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
assert(x > genType(0)); // log2 is only defined on the range (0, inf]
|
||||||
return detail::compute_log2<detail::float_or_int_trait<genType>::ID>()(x);
|
return detail::compute_log2<detail::float_or_int_trait<genType>::ID>()(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
VECTORIZE_VEC(log2)
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<T> log2
|
|
||||||
(
|
|
||||||
detail::tvec2<T> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec2<T>(
|
|
||||||
log2(x.x),
|
|
||||||
log2(x.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<T> log2
|
|
||||||
(
|
|
||||||
detail::tvec3<T> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec3<T>(
|
|
||||||
log2(x.x),
|
|
||||||
log2(x.y),
|
|
||||||
log2(x.z));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<T> log2
|
|
||||||
(
|
|
||||||
detail::tvec4<T> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec4<T>(
|
|
||||||
log2(x.x),
|
|
||||||
log2(x.y),
|
|
||||||
log2(x.z),
|
|
||||||
log2(x.w));
|
|
||||||
}
|
|
||||||
|
|
||||||
// sqrt
|
// sqrt
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
@ -306,41 +134,7 @@ namespace detail
|
|||||||
return genType(::std::sqrt(x));
|
return genType(::std::sqrt(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
VECTORIZE_VEC(sqrt)
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<T> sqrt
|
|
||||||
(
|
|
||||||
detail::tvec2<T> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec2<T>(
|
|
||||||
glm::sqrt(x.x),
|
|
||||||
glm::sqrt(x.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<T> sqrt
|
|
||||||
(
|
|
||||||
detail::tvec3<T> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec3<T>(
|
|
||||||
glm::sqrt(x.x),
|
|
||||||
glm::sqrt(x.y),
|
|
||||||
glm::sqrt(x.z));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<T> sqrt
|
|
||||||
(
|
|
||||||
detail::tvec4<T> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec4<T>(
|
|
||||||
glm::sqrt(x.x),
|
|
||||||
glm::sqrt(x.y),
|
|
||||||
glm::sqrt(x.z),
|
|
||||||
glm::sqrt(x.w));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType inversesqrt
|
GLM_FUNC_QUALIFIER genType inversesqrt
|
||||||
@ -353,40 +147,6 @@ namespace detail
|
|||||||
return genType(1) / ::std::sqrt(x);
|
return genType(1) / ::std::sqrt(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
VECTORIZE_VEC(inversesqrt)
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<T> inversesqrt
|
|
||||||
(
|
|
||||||
detail::tvec2<T> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec2<T>(
|
|
||||||
inversesqrt(x.x),
|
|
||||||
inversesqrt(x.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<T> inversesqrt
|
|
||||||
(
|
|
||||||
detail::tvec3<T> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec3<T>(
|
|
||||||
inversesqrt(x.x),
|
|
||||||
inversesqrt(x.y),
|
|
||||||
inversesqrt(x.z));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<T> inversesqrt
|
|
||||||
(
|
|
||||||
detail::tvec4<T> const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec4<T>(
|
|
||||||
inversesqrt(x.x),
|
|
||||||
inversesqrt(x.y),
|
|
||||||
inversesqrt(x.z),
|
|
||||||
inversesqrt(x.w));
|
|
||||||
}
|
|
||||||
|
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
@ -415,41 +415,7 @@ namespace glm
|
|||||||
return Out;
|
return Out;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
VECTORIZE_VEC(bitfieldReverse)
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<T> bitfieldReverse
|
|
||||||
(
|
|
||||||
detail::tvec2<T> const & value
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec2<T>(
|
|
||||||
bitfieldReverse(value[0]),
|
|
||||||
bitfieldReverse(value[1]));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<T> bitfieldReverse
|
|
||||||
(
|
|
||||||
detail::tvec3<T> const & value
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec3<T>(
|
|
||||||
bitfieldReverse(value[0]),
|
|
||||||
bitfieldReverse(value[1]),
|
|
||||||
bitfieldReverse(value[2]));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<T> bitfieldReverse
|
|
||||||
(
|
|
||||||
detail::tvec4<T> const & value
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return detail::tvec4<T>(
|
|
||||||
bitfieldReverse(value[0]),
|
|
||||||
bitfieldReverse(value[1]),
|
|
||||||
bitfieldReverse(value[2]),
|
|
||||||
bitfieldReverse(value[3]));
|
|
||||||
}
|
|
||||||
|
|
||||||
// bitCount
|
// bitCount
|
||||||
template <typename genIUType>
|
template <typename genIUType>
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
/// @author Christophe Riccio
|
/// @author Christophe Riccio
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace glm{
|
namespace glm
|
||||||
|
{
|
||||||
GLM_FUNC_QUALIFIER detail::uint32 packUnorm2x16(detail::tvec2<detail::float32> const & v)
|
GLM_FUNC_QUALIFIER detail::uint32 packUnorm2x16(detail::tvec2<detail::float32> const & v)
|
||||||
{
|
{
|
||||||
detail::uint16 A(detail::uint16(round(clamp(v.x, 0.0f, 1.0f) * 65535.0f)));
|
detail::uint16 A(detail::uint16(round(clamp(v.x, 0.0f, 1.0f) * 65535.0f)));
|
||||||
@ -155,5 +155,4 @@ GLM_FUNC_QUALIFIER vec2 unpackHalf2x16(uint const & v)
|
|||||||
detail::tvec2<detail::hdata> Unpack = *(detail::tvec2<detail::hdata>*)&v;
|
detail::tvec2<detail::hdata> Unpack = *(detail::tvec2<detail::hdata>*)&v;
|
||||||
return vec2(detail::toFloat32(Unpack.x), detail::toFloat32(Unpack.y));
|
return vec2(detail::toFloat32(Unpack.x), detail::toFloat32(Unpack.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
/// @author Christophe Riccio
|
/// @author Christophe Riccio
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace glm{
|
namespace glm
|
||||||
|
{
|
||||||
// radians
|
// radians
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType radians
|
GLM_FUNC_QUALIFIER genType radians
|
||||||
@ -753,5 +753,4 @@ GLM_FUNC_QUALIFIER detail::tvec4<T> atanh
|
|||||||
atanh(x.z),
|
atanh(x.z),
|
||||||
atanh(x.w));
|
atanh(x.w));
|
||||||
}
|
}
|
||||||
|
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
Loading…
x
Reference in New Issue
Block a user