mirror of
https://github.com/g-truc/glm.git
synced 2024-11-22 17:04:35 +00:00
some more min/max wrappings 2
This commit is contained in:
parent
74eb4f745f
commit
731c903164
@ -39,33 +39,33 @@ namespace glm
|
||||
# endif
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER T fmin(T a, T b, T c)
|
||||
GLM_FUNC_QUALIFIER T (fmin)(T a, T b, T c)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'fmin' only accept floating-point input");
|
||||
|
||||
if (isnan(a))
|
||||
return fmin(b, c);
|
||||
return (fmin)(b, c);
|
||||
if (isnan(b))
|
||||
return fmin(a, c);
|
||||
return (fmin)(a, c);
|
||||
if (isnan(c))
|
||||
return min(a, b);
|
||||
return min(a, b, c);
|
||||
return (min)(a, b, c);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER T fmin(T a, T b, T c, T d)
|
||||
GLM_FUNC_QUALIFIER T (fmin)(T a, T b, T c, T d)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'fmin' only accept floating-point input");
|
||||
|
||||
if (isnan(a))
|
||||
return fmin(b, c, d);
|
||||
return (fmin)(b, c, d);
|
||||
if (isnan(b))
|
||||
return min(a, fmin(c, d));
|
||||
return (min)(a, (fmin)(c, d));
|
||||
if (isnan(c))
|
||||
return fmin(min(a, b), d);
|
||||
return (fmin)(min(a, b), d);
|
||||
if (isnan(d))
|
||||
return min(a, b, c);
|
||||
return min(a, b, c, d);
|
||||
return (min)(a, b, c);
|
||||
return (min)(a, b, c, d);
|
||||
}
|
||||
|
||||
|
||||
@ -73,44 +73,44 @@ namespace glm
|
||||
using std::fmax;
|
||||
# else
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER T fmax(T a, T b)
|
||||
GLM_FUNC_QUALIFIER T (fmax)(T a, T b)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'fmax' only accept floating-point input");
|
||||
|
||||
if (isnan(a))
|
||||
return b;
|
||||
return max(a, b);
|
||||
return (max)(a, b);
|
||||
}
|
||||
# endif
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER T fmax(T a, T b, T c)
|
||||
GLM_FUNC_QUALIFIER T (fmax)(T a, T b, T c)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'fmax' only accept floating-point input");
|
||||
|
||||
if (isnan(a))
|
||||
return fmax(b, c);
|
||||
return (fmax)(b, c);
|
||||
if (isnan(b))
|
||||
return fmax(a, c);
|
||||
return (fmax)(a, c);
|
||||
if (isnan(c))
|
||||
return max(a, b);
|
||||
return max(a, b, c);
|
||||
return (max)(a, b);
|
||||
return (max)(a, b, c);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER T fmax(T a, T b, T c, T d)
|
||||
GLM_FUNC_QUALIFIER T (fmax)(T a, T b, T c, T d)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'fmax' only accept floating-point input");
|
||||
|
||||
if (isnan(a))
|
||||
return fmax(b, c, d);
|
||||
return (fmax)(b, c, d);
|
||||
if (isnan(b))
|
||||
return max(a, fmax(c, d));
|
||||
return (max)(a, (fmax)(c, d));
|
||||
if (isnan(c))
|
||||
return fmax(max(a, b), d);
|
||||
return (fmax)((max)(a, b), d);
|
||||
if (isnan(d))
|
||||
return max(a, b, c);
|
||||
return max(a, b, c, d);
|
||||
return (max)(a, b, c);
|
||||
return (max)(a, b, c, d);
|
||||
}
|
||||
|
||||
// fclamp
|
||||
@ -118,7 +118,7 @@ namespace glm
|
||||
GLM_FUNC_QUALIFIER genType fclamp(genType x, genType minVal, genType maxVal)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'fclamp' only accept floating-point or integer inputs");
|
||||
return fmin(fmax(x, minVal), maxVal);
|
||||
return fmin((fmax)(x, minVal), maxVal);
|
||||
}
|
||||
|
||||
template<typename genType>
|
||||
|
Loading…
Reference in New Issue
Block a user