mirror of
https://github.com/g-truc/glm.git
synced 2024-11-23 09:14:34 +00:00
Make detail::functor1 capable to return a different argument value_type than the argument value_type
This commit is contained in:
parent
bf08a0e234
commit
47a6947736
@ -36,42 +36,42 @@
|
|||||||
namespace glm{
|
namespace glm{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename R, typename T, precision P, template <typename, precision> class vecType>
|
||||||
struct functor1{};
|
struct functor1{};
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename R, typename T, precision P>
|
||||||
struct functor1<T, P, tvec1>
|
struct functor1<R, T, P, tvec1>
|
||||||
{
|
{
|
||||||
GLM_FUNC_QUALIFIER static tvec1<T, P> call(T (*Func) (T x), tvec1<T, P> const & v)
|
GLM_FUNC_QUALIFIER static tvec1<R, P> call(T (*Func) (T x), tvec1<T, P> const & v)
|
||||||
{
|
{
|
||||||
return tvec1<T, P>(Func(v.x));
|
return tvec1<R, P>(Func(v.x));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename R, typename T, precision P>
|
||||||
struct functor1<T, P, tvec2>
|
struct functor1<R, T, P, tvec2>
|
||||||
{
|
{
|
||||||
GLM_FUNC_QUALIFIER static tvec2<T, P> call(T (*Func) (T x), tvec2<T, P> const & v)
|
GLM_FUNC_QUALIFIER static tvec2<R, P> call(T (*Func) (T x), tvec2<T, P> const & v)
|
||||||
{
|
{
|
||||||
return tvec2<T, P>(Func(v.x), Func(v.y));
|
return tvec2<R, P>(Func(v.x), Func(v.y));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename R, typename T, precision P>
|
||||||
struct functor1<T, P, tvec3>
|
struct functor1<R, T, P, tvec3>
|
||||||
{
|
{
|
||||||
GLM_FUNC_QUALIFIER static tvec3<T, P> call(T (*Func) (T x), tvec3<T, P> const & v)
|
GLM_FUNC_QUALIFIER static tvec3<R, P> call(T (*Func) (T x), tvec3<T, P> const & v)
|
||||||
{
|
{
|
||||||
return tvec3<T, P>(Func(v.x), Func(v.y), Func(v.z));
|
return tvec3<R, P>(Func(v.x), Func(v.y), Func(v.z));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename R, typename T, precision P>
|
||||||
struct functor1<T, P, tvec4>
|
struct functor1<R, T, P, tvec4>
|
||||||
{
|
{
|
||||||
GLM_FUNC_QUALIFIER static tvec4<T, P> call(T (*Func) (T x), tvec4<T, P> const & v)
|
GLM_FUNC_QUALIFIER static tvec4<R, 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));
|
return tvec4<R, P>(Func(v.x), Func(v.y), Func(v.z), Func(v.w));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ namespace detail
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> abs(vecType<T, P> const & x)
|
GLM_FUNC_QUALIFIER vecType<T, P> abs(vecType<T, P> const & x)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(abs, x);
|
return detail::functor1<T, T, P, vecType>::call(abs, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sign
|
// sign
|
||||||
@ -164,7 +164,7 @@ namespace detail
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> sign(vecType<T, P> const & x)
|
GLM_FUNC_QUALIFIER vecType<T, P> sign(vecType<T, P> const & x)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(sign, x);
|
return detail::functor1<T, T, P, vecType>::call(sign, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
// floor
|
// floor
|
||||||
@ -173,7 +173,7 @@ namespace detail
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> floor(vecType<T, P> const & x)
|
GLM_FUNC_QUALIFIER vecType<T, P> floor(vecType<T, P> const & x)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(::std::floor, x);
|
return detail::functor1<T, T, P, vecType>::call(::std::floor, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
// trunc
|
// trunc
|
||||||
@ -192,7 +192,7 @@ namespace detail
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> trunc(vecType<T, P> const & x)
|
GLM_FUNC_QUALIFIER vecType<T, P> trunc(vecType<T, P> const & x)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(::std::trunc, x);
|
return detail::functor1<T, T, P, vecType>::call(::std::trunc, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
// round
|
// round
|
||||||
@ -211,7 +211,7 @@ namespace detail
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> round(vecType<T, P> const & x)
|
GLM_FUNC_QUALIFIER vecType<T, P> round(vecType<T, P> const & x)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(round, x);
|
return detail::functor1<T, T, P, vecType>::call(round, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -260,7 +260,7 @@ namespace detail
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> roundEven(vecType<T, P> const & x)
|
GLM_FUNC_QUALIFIER vecType<T, P> roundEven(vecType<T, P> const & x)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(roundEven, x);
|
return detail::functor1<T, T, P, vecType>::call(roundEven, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ceil
|
// ceil
|
||||||
@ -269,7 +269,7 @@ namespace detail
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> ceil(vecType<T, P> const & x)
|
GLM_FUNC_QUALIFIER vecType<T, P> ceil(vecType<T, P> const & x)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(::std::ceil, x);
|
return detail::functor1<T, T, P, vecType>::call(::std::ceil, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fract
|
// fract
|
||||||
@ -284,7 +284,7 @@ namespace detail
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> fract(vecType<T, P> const & x)
|
GLM_FUNC_QUALIFIER vecType<T, P> fract(vecType<T, P> const & x)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(fract, x);
|
return detail::functor1<T, T, P, vecType>::call(fract, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
// mod
|
// mod
|
||||||
|
@ -91,7 +91,7 @@ namespace detail
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> exp(vecType<T, P> const & x)
|
GLM_FUNC_QUALIFIER vecType<T, P> exp(vecType<T, P> const & x)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(::std::exp, x);
|
return detail::functor1<T, T, P, vecType>::call(::std::exp, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
// log
|
// log
|
||||||
@ -99,7 +99,7 @@ namespace detail
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> log(vecType<T, P> const & x)
|
GLM_FUNC_QUALIFIER vecType<T, P> log(vecType<T, P> const & x)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(::std::log, x);
|
return detail::functor1<T, T, P, vecType>::call(::std::log, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
//exp2, ln2 = 0.69314718055994530941723212145818f
|
//exp2, ln2 = 0.69314718055994530941723212145818f
|
||||||
@ -114,7 +114,7 @@ namespace detail
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> exp2(vecType<T, P> const & x)
|
GLM_FUNC_QUALIFIER vecType<T, P> exp2(vecType<T, P> const & x)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(exp2, x);
|
return detail::functor1<T, T, P, vecType>::call(exp2, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
// log2, ln2 = 0.69314718055994530941723212145818f
|
// log2, ln2 = 0.69314718055994530941723212145818f
|
||||||
@ -131,7 +131,7 @@ namespace detail
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> log2(vecType<T, P> const & x)
|
GLM_FUNC_QUALIFIER vecType<T, P> log2(vecType<T, P> const & x)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(log2, x);
|
return detail::functor1<T, T, P, vecType>::call(log2, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sqrt
|
// sqrt
|
||||||
@ -140,7 +140,7 @@ namespace detail
|
|||||||
GLM_FUNC_QUALIFIER vecType<T, P> sqrt(vecType<T, P> const & x)
|
GLM_FUNC_QUALIFIER vecType<T, P> sqrt(vecType<T, P> const & x)
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'sqrt' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'sqrt' only accept floating-point inputs");
|
||||||
return detail::functor1<T, P, vecType>::call(sqrt, x);
|
return detail::functor1<T, T, P, vecType>::call(sqrt, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
// inversesqrt
|
// inversesqrt
|
||||||
|
@ -44,7 +44,7 @@ namespace glm
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> radians(vecType<T, P> const & v)
|
GLM_FUNC_QUALIFIER vecType<T, P> radians(vecType<T, P> const & v)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(radians, v);
|
return detail::functor1<T, T, P, vecType>::call(radians, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// degrees
|
// degrees
|
||||||
@ -59,7 +59,7 @@ namespace glm
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> degrees(vecType<T, P> const & v)
|
GLM_FUNC_QUALIFIER vecType<T, P> degrees(vecType<T, P> const & v)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(degrees, v);
|
return detail::functor1<T, T, P, vecType>::call(degrees, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sin
|
// sin
|
||||||
@ -68,7 +68,7 @@ namespace glm
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> sin(vecType<T, P> const & v)
|
GLM_FUNC_QUALIFIER vecType<T, P> sin(vecType<T, P> const & v)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(sin, v);
|
return detail::functor1<T, T, P, vecType>::call(sin, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// cos
|
// cos
|
||||||
@ -77,7 +77,7 @@ namespace glm
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> cos(vecType<T, P> const & v)
|
GLM_FUNC_QUALIFIER vecType<T, P> cos(vecType<T, P> const & v)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(cos, v);
|
return detail::functor1<T, T, P, vecType>::call(cos, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// tan
|
// tan
|
||||||
@ -86,7 +86,7 @@ namespace glm
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> tan(vecType<T, P> const & v)
|
GLM_FUNC_QUALIFIER vecType<T, P> tan(vecType<T, P> const & v)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(tan, v);
|
return detail::functor1<T, T, P, vecType>::call(tan, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// asin
|
// asin
|
||||||
@ -95,7 +95,7 @@ namespace glm
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> asin(vecType<T, P> const & v)
|
GLM_FUNC_QUALIFIER vecType<T, P> asin(vecType<T, P> const & v)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(asin, v);
|
return detail::functor1<T, T, P, vecType>::call(asin, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// acos
|
// acos
|
||||||
@ -104,7 +104,7 @@ namespace glm
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> acos(vecType<T, P> const & v)
|
GLM_FUNC_QUALIFIER vecType<T, P> acos(vecType<T, P> const & v)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(acos, v);
|
return detail::functor1<T, T, P, vecType>::call(acos, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// atan
|
// atan
|
||||||
@ -127,7 +127,7 @@ namespace glm
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> atan(vecType<T, P> const & v)
|
GLM_FUNC_QUALIFIER vecType<T, P> atan(vecType<T, P> const & v)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(atan, v);
|
return detail::functor1<T, T, P, vecType>::call(atan, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sinh
|
// sinh
|
||||||
@ -136,7 +136,7 @@ namespace glm
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> sinh(vecType<T, P> const & v)
|
GLM_FUNC_QUALIFIER vecType<T, P> sinh(vecType<T, P> const & v)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(sinh, v);
|
return detail::functor1<T, T, P, vecType>::call(sinh, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// cosh
|
// cosh
|
||||||
@ -145,7 +145,7 @@ namespace glm
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> cosh(vecType<T, P> const & v)
|
GLM_FUNC_QUALIFIER vecType<T, P> cosh(vecType<T, P> const & v)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(cosh, v);
|
return detail::functor1<T, T, P, vecType>::call(cosh, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// tanh
|
// tanh
|
||||||
@ -154,7 +154,7 @@ namespace glm
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> tanh(vecType<T, P> const & v)
|
GLM_FUNC_QUALIFIER vecType<T, P> tanh(vecType<T, P> const & v)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(tanh, v);
|
return detail::functor1<T, T, P, vecType>::call(tanh, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// asinh
|
// asinh
|
||||||
@ -173,7 +173,7 @@ namespace glm
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> asinh(vecType<T, P> const & v)
|
GLM_FUNC_QUALIFIER vecType<T, P> asinh(vecType<T, P> const & v)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(asinh, v);
|
return detail::functor1<T, T, P, vecType>::call(asinh, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// acosh
|
// acosh
|
||||||
@ -194,7 +194,7 @@ namespace glm
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> acosh(vecType<T, P> const & v)
|
GLM_FUNC_QUALIFIER vecType<T, P> acosh(vecType<T, P> const & v)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(acosh, v);
|
return detail::functor1<T, T, P, vecType>::call(acosh, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// atanh
|
// atanh
|
||||||
@ -215,6 +215,6 @@ namespace glm
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> atanh(vecType<T, P> const & v)
|
GLM_FUNC_QUALIFIER vecType<T, P> atanh(vecType<T, P> const & v)
|
||||||
{
|
{
|
||||||
return detail::functor1<T, P, vecType>::call(atanh, v);
|
return detail::functor1<T, T, P, vecType>::call(atanh, v);
|
||||||
}
|
}
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
Loading…
Reference in New Issue
Block a user