mirror of
https://github.com/g-truc/glm.git
synced 2024-11-10 04:31:47 +00:00
Vectorize
This commit is contained in:
parent
d070f7cf77
commit
e6fded40dc
@ -26,7 +26,7 @@
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define VECTORIZE_1PARAM(func) \
|
||||
#define VECTORIZE_VEC(func) \
|
||||
template <typename T> \
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> func( \
|
||||
detail::tvec2<T> const & v) \
|
||||
@ -57,7 +57,47 @@
|
||||
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> \
|
||||
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);
|
||||
}
|
||||
|
||||
VECTORIZE_1PARAM(abs)
|
||||
VECTORIZE_VEC(abs)
|
||||
|
||||
// sign
|
||||
//Try something like based on x >> 31 to get the sign bit
|
||||
@ -94,7 +94,7 @@ namespace detail
|
||||
return result;
|
||||
}
|
||||
|
||||
VECTORIZE_1PARAM(sign)
|
||||
VECTORIZE_VEC(sign)
|
||||
|
||||
// floor
|
||||
template <>
|
||||
@ -111,7 +111,7 @@ namespace detail
|
||||
return ::std::floor(x);
|
||||
}
|
||||
|
||||
VECTORIZE_1PARAM(floor)
|
||||
VECTORIZE_VEC(floor)
|
||||
|
||||
// trunc
|
||||
template <typename genType>
|
||||
@ -121,7 +121,7 @@ namespace detail
|
||||
return x < 0 ? -floor(-x) : floor(x);
|
||||
}
|
||||
|
||||
VECTORIZE_1PARAM(trunc)
|
||||
VECTORIZE_VEC(trunc)
|
||||
|
||||
// round
|
||||
template <typename genType>
|
||||
@ -134,7 +134,7 @@ namespace detail
|
||||
return genType(int(x + genType(0.5)));
|
||||
}
|
||||
|
||||
VECTORIZE_1PARAM(round)
|
||||
VECTORIZE_VEC(round)
|
||||
|
||||
/*
|
||||
// roundEven
|
||||
@ -161,7 +161,7 @@ namespace detail
|
||||
return genType(int(x + RoundValue));
|
||||
}
|
||||
|
||||
VECTORIZE_1PARAM(roundEven)
|
||||
VECTORIZE_VEC(roundEven)
|
||||
|
||||
// ceil
|
||||
template <typename genType>
|
||||
@ -172,7 +172,7 @@ namespace detail
|
||||
return ::std::ceil(x);
|
||||
}
|
||||
|
||||
VECTORIZE_1PARAM(ceil)
|
||||
VECTORIZE_VEC(ceil)
|
||||
|
||||
// fract
|
||||
template <typename genType>
|
||||
@ -186,7 +186,7 @@ namespace detail
|
||||
return x - ::std::floor(x);
|
||||
}
|
||||
|
||||
VECTORIZE_1PARAM(fract)
|
||||
VECTORIZE_VEC(fract)
|
||||
|
||||
// mod
|
||||
template <typename genType>
|
||||
@ -201,83 +201,8 @@ namespace detail
|
||||
return x - y * floor(x / y);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> 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));
|
||||
}
|
||||
VECTORIZE_VEC_SCA(mod)
|
||||
VECTORIZE_VEC_VEC(mod)
|
||||
|
||||
// modf
|
||||
template <typename genType>
|
||||
@ -298,39 +223,39 @@ namespace detail
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<valType> modf
|
||||
(
|
||||
detail::tvec2<valType> const & x,
|
||||
detail::tvec2<valType> const & y
|
||||
detail::tvec2<valType> & i
|
||||
)
|
||||
{
|
||||
return detail::tvec2<valType>(
|
||||
modf(x.x, y.x),
|
||||
modf(x.y, y.y));
|
||||
modf(x.x, i.x),
|
||||
modf(x.y, i.y));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> modf
|
||||
(
|
||||
detail::tvec3<valType> const & x,
|
||||
detail::tvec3<valType> const & y
|
||||
detail::tvec3<valType> & i
|
||||
)
|
||||
{
|
||||
return detail::tvec3<valType>(
|
||||
modf(x.x, y.x),
|
||||
modf(x.y, y.y),
|
||||
modf(x.z, y.z));
|
||||
modf(x.x, i.x),
|
||||
modf(x.y, i.y),
|
||||
modf(x.z, i.z));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<valType> modf
|
||||
(
|
||||
detail::tvec4<valType> const & x,
|
||||
detail::tvec4<valType> const & y
|
||||
detail::tvec4<valType> & i
|
||||
)
|
||||
{
|
||||
return detail::tvec4<valType>(
|
||||
modf(x.x, y.x),
|
||||
modf(x.y, y.y),
|
||||
modf(x.z, y.z),
|
||||
modf(x.w, y.w));
|
||||
modf(x.x, i.x),
|
||||
modf(x.y, i.y),
|
||||
modf(x.z, i.z),
|
||||
modf(x.w, i.w));
|
||||
}
|
||||
|
||||
//// Only valid if (INT_MIN <= x-y <= INT_MAX)
|
||||
@ -357,83 +282,8 @@ namespace detail
|
||||
return x < y ? x : y;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> 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));
|
||||
}
|
||||
VECTORIZE_VEC_SCA(min)
|
||||
VECTORIZE_VEC_VEC(min)
|
||||
|
||||
// max
|
||||
template <typename genType>
|
||||
@ -451,82 +301,8 @@ namespace detail
|
||||
return x > y ? x : y;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> 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));
|
||||
}
|
||||
VECTORIZE_VEC_SCA(max)
|
||||
VECTORIZE_VEC_VEC(max)
|
||||
|
||||
// clamp
|
||||
template <typename valType>
|
||||
|
@ -41,44 +41,7 @@ namespace glm
|
||||
return ::std::pow(x, y);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC_VEC(pow)
|
||||
|
||||
// exp
|
||||
template <typename genType>
|
||||
@ -92,41 +55,7 @@ namespace glm
|
||||
return ::std::exp(x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(exp)
|
||||
|
||||
// log
|
||||
template <typename genType>
|
||||
@ -140,41 +69,7 @@ namespace glm
|
||||
return ::std::log(x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(log)
|
||||
|
||||
//exp2, ln2 = 0.69314718055994530941723212145818f
|
||||
template <typename genType>
|
||||
@ -188,41 +83,7 @@ namespace glm
|
||||
return ::std::exp(genType(0.69314718055994530941723212145818) * x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(exp2)
|
||||
|
||||
namespace detail
|
||||
{
|
||||
@ -255,44 +116,11 @@ namespace detail
|
||||
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);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(log2)
|
||||
|
||||
// sqrt
|
||||
template <typename genType>
|
||||
@ -306,41 +134,7 @@ namespace detail
|
||||
return genType(::std::sqrt(x));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(sqrt)
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType inversesqrt
|
||||
@ -353,40 +147,6 @@ namespace detail
|
||||
return genType(1) / ::std::sqrt(x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
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));
|
||||
}
|
||||
VECTORIZE_VEC(inversesqrt)
|
||||
|
||||
}//namespace glm
|
||||
|
@ -415,41 +415,7 @@ namespace glm
|
||||
return Out;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
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]));
|
||||
}
|
||||
VECTORIZE_VEC(bitfieldReverse)
|
||||
|
||||
// bitCount
|
||||
template <typename genIUType>
|
||||
|
@ -26,27 +26,27 @@
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
GLM_FUNC_QUALIFIER detail::uint32 packUnorm2x16(detail::tvec2<detail::float32> const & v)
|
||||
namespace glm
|
||||
{
|
||||
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 B(detail::uint16(round(clamp(v.y, 0.0f, 1.0f) * 65535.0f)));
|
||||
return detail::uint32((B << 16) | A);
|
||||
}
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<detail::float32> unpackUnorm2x16(detail::uint32 const & p)
|
||||
{
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<detail::float32> unpackUnorm2x16(detail::uint32 const & p)
|
||||
{
|
||||
detail::uint32 Mask16((1 << 16) - 1);
|
||||
detail::uint32 A((p >> 0) & Mask16);
|
||||
detail::uint32 B((p >> 16) & Mask16);
|
||||
return detail::tvec2<detail::float32>(
|
||||
A * 1.0f / 65535.0f,
|
||||
B * 1.0f / 65535.0f);
|
||||
}
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER detail::uint32 packSnorm2x16(detail::tvec2<detail::float32> const & v)
|
||||
{
|
||||
GLM_FUNC_QUALIFIER detail::uint32 packSnorm2x16(detail::tvec2<detail::float32> const & v)
|
||||
{
|
||||
union iu
|
||||
{
|
||||
detail::int16 i;
|
||||
@ -58,10 +58,10 @@ GLM_FUNC_QUALIFIER detail::uint32 packSnorm2x16(detail::tvec2<detail::float32> c
|
||||
B.i = detail::int16(round(Unpack.y));
|
||||
detail::uint32 Pack = (detail::uint32(B.u) << 16) | (detail::uint32(A.u) << 0);
|
||||
return Pack;
|
||||
}
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<detail::float32> unpackSnorm2x16(detail::uint32 const & p)
|
||||
{
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<detail::float32> unpackSnorm2x16(detail::uint32 const & p)
|
||||
{
|
||||
union iu
|
||||
{
|
||||
detail::int16 i;
|
||||
@ -74,19 +74,19 @@ GLM_FUNC_QUALIFIER detail::tvec2<detail::float32> unpackSnorm2x16(detail::uint32
|
||||
detail::tvec2<detail::float32> Pack(A.i, B.i);
|
||||
|
||||
return clamp(Pack * 1.0f / 32767.0f, -1.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER detail::uint32 packUnorm4x8(detail::tvec4<detail::float32> const & v)
|
||||
{
|
||||
GLM_FUNC_QUALIFIER detail::uint32 packUnorm4x8(detail::tvec4<detail::float32> const & v)
|
||||
{
|
||||
detail::uint8 A((detail::uint8)round(clamp(v.x, 0.0f, 1.0f) * 255.0f));
|
||||
detail::uint8 B((detail::uint8)round(clamp(v.y, 0.0f, 1.0f) * 255.0f));
|
||||
detail::uint8 C((detail::uint8)round(clamp(v.z, 0.0f, 1.0f) * 255.0f));
|
||||
detail::uint8 D((detail::uint8)round(clamp(v.w, 0.0f, 1.0f) * 255.0f));
|
||||
return detail::uint32((D << 24) | (C << 16) | (B << 8) | A);
|
||||
}
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<detail::float32> unpackUnorm4x8(detail::uint32 const & p)
|
||||
{
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<detail::float32> unpackUnorm4x8(detail::uint32 const & p)
|
||||
{
|
||||
detail::uint32 Mask8((1 << 8) - 1);
|
||||
detail::uint32 A((p >> 0) & Mask8);
|
||||
detail::uint32 B((p >> 8) & Mask8);
|
||||
@ -97,10 +97,10 @@ GLM_FUNC_QUALIFIER detail::tvec4<detail::float32> unpackUnorm4x8(detail::uint32
|
||||
B * 1.0f / 255.0f,
|
||||
C * 1.0f / 255.0f,
|
||||
D * 1.0f / 255.0f);
|
||||
}
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER detail::uint32 packSnorm4x8(detail::tvec4<detail::float32> const & v)
|
||||
{
|
||||
GLM_FUNC_QUALIFIER detail::uint32 packSnorm4x8(detail::tvec4<detail::float32> const & v)
|
||||
{
|
||||
union iu
|
||||
{
|
||||
detail::int8 i;
|
||||
@ -114,10 +114,10 @@ GLM_FUNC_QUALIFIER detail::uint32 packSnorm4x8(detail::tvec4<detail::float32> co
|
||||
D.i = detail::int8(round(Unpack.w));
|
||||
detail::uint32 Pack = (detail::uint32(D.u) << 24) | (detail::uint32(C.u) << 16) | (detail::uint32(B.u) << 8) | (detail::uint32(A.u) << 0);
|
||||
return Pack;
|
||||
}
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<detail::float32> unpackSnorm4x8(detail::uint32 const & p)
|
||||
{
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<detail::float32> unpackSnorm4x8(detail::uint32 const & p)
|
||||
{
|
||||
union iu
|
||||
{
|
||||
detail::int8 i;
|
||||
@ -132,28 +132,27 @@ GLM_FUNC_QUALIFIER detail::tvec4<detail::float32> unpackSnorm4x8(detail::uint32
|
||||
detail::tvec4<detail::float32> Pack(A.i, B.i, C.i, D.i);
|
||||
|
||||
return clamp(Pack * 1.0f / 127.0f, -1.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER double packDouble2x32(detail::tvec2<detail::uint32> const & v)
|
||||
{
|
||||
GLM_FUNC_QUALIFIER double packDouble2x32(detail::tvec2<detail::uint32> const & v)
|
||||
{
|
||||
return *(double*)&v;
|
||||
}
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<uint> unpackDouble2x32(double const & v)
|
||||
{
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<uint> unpackDouble2x32(double const & v)
|
||||
{
|
||||
return *(detail::tvec2<uint>*)&v;
|
||||
}
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint packHalf2x16(detail::tvec2<float> const & v)
|
||||
{
|
||||
GLM_FUNC_QUALIFIER uint packHalf2x16(detail::tvec2<float> const & v)
|
||||
{
|
||||
detail::tvec2<detail::hdata> Pack(detail::toFloat16(v.x), detail::toFloat16(v.y));
|
||||
return *(uint*)&Pack;
|
||||
}
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER vec2 unpackHalf2x16(uint const & v)
|
||||
{
|
||||
GLM_FUNC_QUALIFIER vec2 unpackHalf2x16(uint const & v)
|
||||
{
|
||||
detail::tvec2<detail::hdata> Unpack = *(detail::tvec2<detail::hdata>*)&v;
|
||||
return vec2(detail::toFloat32(Unpack.x), detail::toFloat32(Unpack.y));
|
||||
}
|
||||
|
||||
}
|
||||
}//namespace glm
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user