Fixed isfinite with C++98 compilers #343
This commit is contained in:
@@ -84,6 +84,7 @@ namespace glm
|
||||
template <typename T, precision P> GLM_FUNC_QUALIFIER tvec4<T, P> atan2(const tvec4<T, P>& x, const tvec4<T, P>& y){return atan(x, y);} //!< \brief Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0. (From GLM_GTX_compatibility)
|
||||
|
||||
template <typename genType> GLM_FUNC_DECL bool isfinite(genType const & x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)
|
||||
template <typename T, precision P> GLM_FUNC_DECL tvec1<bool, P> isfinite(const tvec1<T, P>& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)
|
||||
template <typename T, precision P> GLM_FUNC_DECL tvec2<bool, P> isfinite(const tvec2<T, P>& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)
|
||||
template <typename T, precision P> GLM_FUNC_DECL tvec3<bool, P> isfinite(const tvec3<T, P>& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)
|
||||
template <typename T, precision P> GLM_FUNC_DECL tvec4<bool, P> isfinite(const tvec4<T, P>& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)
|
||||
|
||||
@@ -46,10 +46,21 @@ namespace glm
|
||||
# elif GLM_COMPILER & GLM_COMPILER_GCC && GLM_PLATFORM & GLM_PLATFORM_ANDROID
|
||||
return _isfinite(x) != 0;
|
||||
# else
|
||||
return x >= std::numeric_limits<genType>::min() && x <= std::numeric_limits<genType>::max();
|
||||
if (std::numeric_limits<genType>::is_integer || std::denorm_absent == std::numeric_limits<genType>::has_denorm)
|
||||
return std::numeric_limits<genType>::min() <= x && std::numeric_limits<genType>::max() >= x;
|
||||
else
|
||||
return -std::numeric_limits<genType>::max() <= x && std::numeric_limits<genType>::max() >= x;
|
||||
# endif
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec1<bool, P> isfinite(
|
||||
tvec1<T, P> const & x)
|
||||
{
|
||||
return tvec1<bool, P>(
|
||||
isfinite(x.x));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tvec2<bool, P> isfinite(
|
||||
tvec2<T, P> const & x)
|
||||
|
||||
Reference in New Issue
Block a user