From 229f3eced436f1c4d90ca24463ef41b5c4f5bb58 Mon Sep 17 00:00:00 2001 From: christophe Date: Mon, 25 Dec 2023 18:34:24 +0100 Subject: [PATCH] Add GLM_FORCE_UNRESTRICTED_FLOAT to skip static assert when using not float types --- glm/detail/compute_common.hpp | 2 +- glm/detail/func_common.inl | 68 +++++++++++++++---------------- glm/detail/func_exponential.inl | 8 ++-- glm/detail/func_trigonometric.inl | 12 +++--- glm/detail/setup.hpp | 11 +++++ glm/ext/quaternion_common.inl | 12 +++--- glm/ext/quaternion_geometric.inl | 2 +- glm/ext/scalar_common.inl | 18 ++++---- glm/ext/scalar_constants.inl | 4 +- glm/ext/scalar_integer.inl | 4 +- glm/ext/scalar_reciprocal.inl | 24 +++++------ glm/ext/scalar_ulp.inl | 4 +- glm/ext/vector_reciprocal.inl | 24 +++++------ glm/gtc/ulp.inl | 4 +- glm/gtx/common.inl | 10 ++--- glm/gtx/exterior_product.inl | 2 +- glm/gtx/fast_square_root.inl | 6 +-- glm/gtx/norm.inl | 8 ++-- glm/gtx/vector_angle.inl | 6 +-- readme.md | 1 + 20 files changed, 121 insertions(+), 109 deletions(-) diff --git a/glm/detail/compute_common.hpp b/glm/detail/compute_common.hpp index 0952195f..7b0af90e 100644 --- a/glm/detail/compute_common.hpp +++ b/glm/detail/compute_common.hpp @@ -16,7 +16,7 @@ namespace detail GLM_FUNC_QUALIFIER GLM_CONSTEXPR static genFIType call(genFIType x) { GLM_STATIC_ASSERT( - std::numeric_limits::is_iec559 || std::numeric_limits::is_signed, + std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT || std::numeric_limits::is_signed, "'abs' only accept floating-point and integer scalar or vector inputs"); return x >= genFIType(0) ? x : -x; diff --git a/glm/detail/func_common.inl b/glm/detail/func_common.inl index 8fcfd28b..2fc29d6e 100644 --- a/glm/detail/func_common.inl +++ b/glm/detail/func_common.inl @@ -16,7 +16,7 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType min(genType x, genType y) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || std::numeric_limits::is_integer, "'min' only accept floating-point or integer inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT || std::numeric_limits::is_integer, "'min' only accept floating-point or integer inputs"); return (y < x) ? y : x; } @@ -24,7 +24,7 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType max(genType x, genType y) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || std::numeric_limits::is_integer, "'max' only accept floating-point or integer inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT || std::numeric_limits::is_integer, "'max' only accept floating-point or integer inputs"); return (x < y) ? y : x; } @@ -44,7 +44,7 @@ namespace glm template GLM_FUNC_QUALIFIER genType round(genType x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'round' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'round' only accept floating-point inputs"); return x < static_cast(0) ? static_cast(int(x - static_cast(0.5))) : static_cast(int(x + static_cast(0.5))); } @@ -57,7 +57,7 @@ namespace glm template GLM_FUNC_QUALIFIER genType trunc(genType x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'trunc' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'trunc' only accept floating-point inputs"); return x < static_cast(0) ? -std::floor(-x) : std::floor(x); } @@ -82,7 +82,7 @@ namespace detail { GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec call(vec const& x, vec const& y, vec const& a) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_CONFIG_UNRESTRICTED_GENTYPE, "'mix' only accept floating-point inputs for the interpolator a"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT || GLM_CONFIG_UNRESTRICTED_GENTYPE, "'mix' only accept floating-point inputs for the interpolator a"); return vec(vec(x) * (static_cast(1) - a) + vec(y) * a); } @@ -105,7 +105,7 @@ namespace detail { GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec call(vec const& x, vec const& y, U const& a) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_CONFIG_UNRESTRICTED_GENTYPE, "'mix' only accept floating-point inputs for the interpolator a"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT || GLM_CONFIG_UNRESTRICTED_GENTYPE, "'mix' only accept floating-point inputs for the interpolator a"); return vec(vec(x) * (static_cast(1) - a) + vec(y) * a); } @@ -125,7 +125,7 @@ namespace detail { GLM_FUNC_QUALIFIER GLM_CONSTEXPR static T call(T const& x, T const& y, U const& a) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_CONFIG_UNRESTRICTED_GENTYPE, "'mix' only accept floating-point inputs for the interpolator a"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT || GLM_CONFIG_UNRESTRICTED_GENTYPE, "'mix' only accept floating-point inputs for the interpolator a"); return static_cast(static_cast(x) * (static_cast(1) - a) + static_cast(y) * a); } @@ -213,7 +213,7 @@ namespace detail { GLM_FUNC_QUALIFIER static vec call(vec const& a, vec const& b) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'mod' only accept floating-point inputs. Include for integer inputs."); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'mod' only accept floating-point inputs. Include for integer inputs."); return a - b * floor(a / b); } }; @@ -259,7 +259,7 @@ namespace detail { GLM_FUNC_QUALIFIER static vec call(vec const& edge0, vec const& edge1, vec const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_CONFIG_UNRESTRICTED_GENTYPE, "'smoothstep' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT || GLM_CONFIG_UNRESTRICTED_GENTYPE, "'smoothstep' only accept floating-point inputs"); vec const tmp(clamp((x - edge0) / (edge1 - edge0), static_cast(0), static_cast(1))); return tmp * tmp * (static_cast(3) - static_cast(2) * tmp); } @@ -284,7 +284,7 @@ namespace detail GLM_FUNC_QUALIFIER GLM_CONSTEXPR genFIType sign(genFIType x) { GLM_STATIC_ASSERT( - std::numeric_limits::is_iec559 || (std::numeric_limits::is_signed && std::numeric_limits::is_integer), + std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT || (std::numeric_limits::is_signed && std::numeric_limits::is_integer), "'sign' only accept signed inputs"); return detail::compute_sign<1, genFIType, defaultp, @@ -295,7 +295,7 @@ namespace detail GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec sign(vec const& x) { GLM_STATIC_ASSERT( - std::numeric_limits::is_iec559 || (std::numeric_limits::is_signed && std::numeric_limits::is_integer), + std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT || (std::numeric_limits::is_signed && std::numeric_limits::is_integer), "'sign' only accept signed inputs"); return detail::compute_sign::is_iec559, detail::is_aligned::value>::call(x); @@ -306,21 +306,21 @@ namespace detail template GLM_FUNC_QUALIFIER vec floor(vec const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'floor' only accept floating-point inputs."); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'floor' only accept floating-point inputs."); return detail::compute_floor::value>::call(x); } template GLM_FUNC_QUALIFIER vec trunc(vec const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'trunc' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'trunc' only accept floating-point inputs"); return detail::compute_trunc::value>::call(x); } template GLM_FUNC_QUALIFIER vec round(vec const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'round' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'round' only accept floating-point inputs"); return detail::compute_round::value>::call(x); } @@ -329,7 +329,7 @@ namespace detail template GLM_FUNC_QUALIFIER genType roundEven(genType const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'roundEven' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'roundEven' only accept floating-point inputs"); return genType(int(x + genType(int(x) % 2))); } @@ -339,7 +339,7 @@ namespace detail template GLM_FUNC_QUALIFIER genType roundEven(genType x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'roundEven' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'roundEven' only accept floating-point inputs"); int Integer = static_cast(x); genType IntegerPart = static_cast(Integer); @@ -370,7 +370,7 @@ namespace detail template GLM_FUNC_QUALIFIER vec roundEven(vec const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'roundEven' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'roundEven' only accept floating-point inputs"); return detail::functor1::call(roundEven, x); } @@ -379,7 +379,7 @@ namespace detail template GLM_FUNC_QUALIFIER vec ceil(vec const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'ceil' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'ceil' only accept floating-point inputs"); return detail::compute_ceil::value>::call(x); } @@ -393,7 +393,7 @@ namespace detail template GLM_FUNC_QUALIFIER vec fract(vec const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'fract' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'fract' only accept floating-point inputs"); return detail::compute_fract::value>::call(x); } @@ -426,7 +426,7 @@ namespace detail template GLM_FUNC_QUALIFIER genType modf(genType x, genType & i) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'modf' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'modf' only accept floating-point inputs"); return std::modf(x, &i); } @@ -476,7 +476,7 @@ namespace detail template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec min(vec const& a, T b) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || std::numeric_limits::is_integer, "'min' only accept floating-point or integer inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT || std::numeric_limits::is_integer, "'min' only accept floating-point or integer inputs"); return detail::compute_min_vector::value>::call(a, vec(b)); } @@ -490,7 +490,7 @@ namespace detail template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec max(vec const& a, T b) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || std::numeric_limits::is_integer, "'max' only accept floating-point or integer inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT || std::numeric_limits::is_integer, "'max' only accept floating-point or integer inputs"); return detail::compute_max_vector::value>::call(a, vec(b)); } @@ -504,21 +504,21 @@ namespace detail template GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType clamp(genType x, genType minVal, genType maxVal) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || std::numeric_limits::is_integer, "'clamp' only accept floating-point or integer inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT || std::numeric_limits::is_integer, "'clamp' only accept floating-point or integer inputs"); return min(max(x, minVal), maxVal); } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec clamp(vec const& x, T minVal, T maxVal) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || std::numeric_limits::is_integer, "'clamp' only accept floating-point or integer inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT || std::numeric_limits::is_integer, "'clamp' only accept floating-point or integer inputs"); return detail::compute_clamp_vector::value>::call(x, vec(minVal), vec(maxVal)); } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec clamp(vec const& x, vec const& minVal, vec const& maxVal) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || std::numeric_limits::is_integer, "'clamp' only accept floating-point or integer inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT || std::numeric_limits::is_integer, "'clamp' only accept floating-point or integer inputs"); return detail::compute_clamp_vector::value>::call(x, minVal, maxVal); } @@ -563,7 +563,7 @@ namespace detail template GLM_FUNC_QUALIFIER genType smoothstep(genType edge0, genType edge1, genType x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_CONFIG_UNRESTRICTED_GENTYPE, "'smoothstep' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT || GLM_CONFIG_UNRESTRICTED_GENTYPE, "'smoothstep' only accept floating-point inputs"); genType const tmp(clamp((x - edge0) / (edge1 - edge0), genType(0), genType(1))); return tmp * tmp * (genType(3) - genType(2) * tmp); @@ -587,7 +587,7 @@ namespace detail template GLM_FUNC_QUALIFIER bool isnan(genType x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'isnan' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'isnan' only accept floating-point inputs"); # if GLM_HAS_CXX11_STL return std::isnan(x); @@ -612,7 +612,7 @@ namespace detail template GLM_FUNC_QUALIFIER vec isnan(vec const& v) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'isnan' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'isnan' only accept floating-point inputs"); vec Result; for (length_t l = 0; l < v.length(); ++l) @@ -626,7 +626,7 @@ namespace detail template GLM_FUNC_QUALIFIER bool isinf(genType x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'isinf' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'isinf' only accept floating-point inputs"); # if GLM_HAS_CXX11_STL return std::isinf(x); @@ -654,7 +654,7 @@ namespace detail template GLM_FUNC_QUALIFIER vec isinf(vec const& v) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'isinf' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'isinf' only accept floating-point inputs"); vec Result; for (length_t l = 0; l < v.length(); ++l) @@ -751,7 +751,7 @@ namespace detail template GLM_FUNC_QUALIFIER genType frexp(genType x, int& exp) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'frexp' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'frexp' only accept floating-point inputs"); return std::frexp(x, &exp); } @@ -759,7 +759,7 @@ namespace detail template GLM_FUNC_QUALIFIER vec frexp(vec const& v, vec& exp) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'frexp' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'frexp' only accept floating-point inputs"); vec Result; for (length_t l = 0; l < v.length(); ++l) @@ -770,7 +770,7 @@ namespace detail template GLM_FUNC_QUALIFIER genType ldexp(genType const& x, int const& exp) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'ldexp' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'ldexp' only accept floating-point inputs"); return std::ldexp(x, exp); } @@ -778,7 +778,7 @@ namespace detail template GLM_FUNC_QUALIFIER vec ldexp(vec const& v, vec const& exp) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'ldexp' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'ldexp' only accept floating-point inputs"); vec Result; for (length_t l = 0; l < v.length(); ++l) diff --git a/glm/detail/func_exponential.inl b/glm/detail/func_exponential.inl index 2040d41f..d12b149d 100644 --- a/glm/detail/func_exponential.inl +++ b/glm/detail/func_exponential.inl @@ -25,7 +25,7 @@ namespace detail { GLM_FUNC_QUALIFIER static vec call(vec const& v) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'log2' only accept floating-point inputs. Include for integer inputs."); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'log2' only accept floating-point inputs. Include for integer inputs."); return detail::functor1::call(log2, v); } @@ -97,7 +97,7 @@ namespace detail template GLM_FUNC_QUALIFIER genType exp2(genType x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'exp2' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'exp2' only accept floating-point inputs"); return std::exp(static_cast(0.69314718055994530941723212145818) * x); } @@ -127,7 +127,7 @@ namespace detail template GLM_FUNC_QUALIFIER vec sqrt(vec const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'sqrt' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'sqrt' only accept floating-point inputs"); return detail::compute_sqrt::value>::call(x); } @@ -141,7 +141,7 @@ namespace detail template GLM_FUNC_QUALIFIER vec inversesqrt(vec const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'inversesqrt' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'inversesqrt' only accept floating-point inputs"); return detail::compute_inversesqrt::value>::call(x); } }//namespace glm diff --git a/glm/detail/func_trigonometric.inl b/glm/detail/func_trigonometric.inl index 6792d856..c48211a7 100644 --- a/glm/detail/func_trigonometric.inl +++ b/glm/detail/func_trigonometric.inl @@ -8,7 +8,7 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType radians(genType degrees) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'radians' only accept floating-point input"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'radians' only accept floating-point input"); return degrees * static_cast(0.01745329251994329576923690768489); } @@ -23,7 +23,7 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType degrees(genType radians) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'degrees' only accept floating-point input"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'degrees' only accept floating-point input"); return radians * static_cast(57.295779513082320876798154814105); } @@ -83,7 +83,7 @@ namespace glm template GLM_FUNC_QUALIFIER genType atan(genType y, genType x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'atan' only accept floating-point input"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'atan' only accept floating-point input"); return ::std::atan2(y, x); } @@ -136,7 +136,7 @@ namespace glm template GLM_FUNC_QUALIFIER genType asinh(genType x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'asinh' only accept floating-point input"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'asinh' only accept floating-point input"); return (x < static_cast(0) ? static_cast(-1) : (x > static_cast(0) ? static_cast(1) : static_cast(0))) * log(std::abs(x) + sqrt(static_cast(1) + x * x)); } @@ -155,7 +155,7 @@ namespace glm template GLM_FUNC_QUALIFIER genType acosh(genType x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'acosh' only accept floating-point input"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'acosh' only accept floating-point input"); if(x < static_cast(1)) return static_cast(0); @@ -176,7 +176,7 @@ namespace glm template GLM_FUNC_QUALIFIER genType atanh(genType x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'atanh' only accept floating-point input"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'atanh' only accept floating-point input"); if(std::abs(x) >= static_cast(1)) return 0; diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index 9c565ec6..19953bcb 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -528,6 +528,17 @@ # define GLM_CONFIG_UNRESTRICTED_GENTYPE GLM_DISABLE #endif +/////////////////////////////////////////////////////////////////////////////////// +// Allows using any scaler as float + +// #define GLM_FORCE_UNRESTRICTED_FLOAT + +#ifdef GLM_FORCE_UNRESTRICTED_FLOAT +# define GLM_CONFIG_UNRESTRICTED_FLOAT GLM_ENABLE +#else +# define GLM_CONFIG_UNRESTRICTED_FLOAT GLM_DISABLE +#endif + /////////////////////////////////////////////////////////////////////////////////// // Clip control, define GLM_FORCE_DEPTH_ZERO_TO_ONE before including GLM // to use a clip space between 0 to 1. diff --git a/glm/ext/quaternion_common.inl b/glm/ext/quaternion_common.inl index c5ecf5ae..7a189109 100644 --- a/glm/ext/quaternion_common.inl +++ b/glm/ext/quaternion_common.inl @@ -3,7 +3,7 @@ namespace glm template GLM_FUNC_QUALIFIER qua mix(qua const& x, qua const& y, T a) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'mix' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'mix' only accept floating-point inputs"); T const cosTheta = dot(x, y); @@ -28,7 +28,7 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua lerp(qua const& x, qua const& y, T a) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'lerp' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'lerp' only accept floating-point inputs"); // Lerp is only defined in [0, 1] assert(a >= static_cast(0)); @@ -40,7 +40,7 @@ namespace glm template GLM_FUNC_QUALIFIER qua slerp(qua const& x, qua const& y, T a) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'slerp' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'slerp' only accept floating-point inputs"); qua z = y; @@ -75,7 +75,7 @@ namespace glm template GLM_FUNC_QUALIFIER qua slerp(qua const& x, qua const& y, T a, S k) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'slerp' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'slerp' only accept floating-point inputs"); GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'slerp' only accept integer for spin count"); qua z = y; @@ -124,7 +124,7 @@ namespace glm template GLM_FUNC_QUALIFIER vec<4, bool, Q> isnan(qua const& q) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'isnan' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'isnan' only accept floating-point inputs"); return vec<4, bool, Q>(isnan(q.x), isnan(q.y), isnan(q.z), isnan(q.w)); } @@ -132,7 +132,7 @@ namespace glm template GLM_FUNC_QUALIFIER vec<4, bool, Q> isinf(qua const& q) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'isinf' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'isinf' only accept floating-point inputs"); return vec<4, bool, Q>(isinf(q.x), isinf(q.y), isinf(q.z), isinf(q.w)); } diff --git a/glm/ext/quaternion_geometric.inl b/glm/ext/quaternion_geometric.inl index 557a0cba..c586e802 100644 --- a/glm/ext/quaternion_geometric.inl +++ b/glm/ext/quaternion_geometric.inl @@ -3,7 +3,7 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR T dot(qua const& x, qua const& y) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'dot' accepts only floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'dot' accepts only floating-point inputs"); return detail::compute_dot, T, detail::is_aligned::value>::call(x, y); } diff --git a/glm/ext/scalar_common.inl b/glm/ext/scalar_common.inl index 2807a372..652ca92d 100644 --- a/glm/ext/scalar_common.inl +++ b/glm/ext/scalar_common.inl @@ -30,7 +30,7 @@ namespace glm template GLM_FUNC_QUALIFIER T fmin(T a, T b) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'fmin' only accept floating-point input"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'fmin' only accept floating-point input"); if (isnan(a)) return b; @@ -41,7 +41,7 @@ namespace glm template GLM_FUNC_QUALIFIER T fmin(T a, T b, T c) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'fmin' only accept floating-point input"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'fmin' only accept floating-point input"); if (isnan(a)) return fmin(b, c); @@ -55,7 +55,7 @@ namespace glm template GLM_FUNC_QUALIFIER T fmin(T a, T b, T c, T d) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'fmin' only accept floating-point input"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'fmin' only accept floating-point input"); if (isnan(a)) return fmin(b, c, d); @@ -75,7 +75,7 @@ namespace glm template GLM_FUNC_QUALIFIER T fmax(T a, T b) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'fmax' only accept floating-point input"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'fmax' only accept floating-point input"); if (isnan(a)) return b; @@ -86,7 +86,7 @@ namespace glm template GLM_FUNC_QUALIFIER T fmax(T a, T b, T c) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'fmax' only accept floating-point input"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'fmax' only accept floating-point input"); if (isnan(a)) return fmax(b, c); @@ -100,7 +100,7 @@ namespace glm template GLM_FUNC_QUALIFIER T fmax(T a, T b, T c, T d) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'fmax' only accept floating-point input"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'fmax' only accept floating-point input"); if (isnan(a)) return fmax(b, c, d); @@ -117,7 +117,7 @@ namespace glm template GLM_FUNC_QUALIFIER genType fclamp(genType x, genType minVal, genType maxVal) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'fclamp' only accept floating-point or integer inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'fclamp' only accept floating-point or integer inputs"); return fmin(fmax(x, minVal), maxVal); } @@ -153,7 +153,7 @@ namespace glm template GLM_FUNC_QUALIFIER int iround(genType const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'iround' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'iround' only accept floating-point inputs"); assert(static_cast(0.0) <= x); return static_cast(x + static_cast(0.5)); @@ -162,7 +162,7 @@ namespace glm template GLM_FUNC_QUALIFIER uint uround(genType const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'uround' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'uround' only accept floating-point inputs"); assert(static_cast(0.0) <= x); return static_cast(x + static_cast(0.5)); diff --git a/glm/ext/scalar_constants.inl b/glm/ext/scalar_constants.inl index b475adf8..10e02262 100644 --- a/glm/ext/scalar_constants.inl +++ b/glm/ext/scalar_constants.inl @@ -5,14 +5,14 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType epsilon() { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'epsilon' only accepts floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'epsilon' only accepts floating-point inputs"); return std::numeric_limits::epsilon(); } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType pi() { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'pi' only accepts floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'pi' only accepts floating-point inputs"); return static_cast(3.14159265358979323846264338327950288); } diff --git a/glm/ext/scalar_integer.inl b/glm/ext/scalar_integer.inl index efba9600..6135ef98 100644 --- a/glm/ext/scalar_integer.inl +++ b/glm/ext/scalar_integer.inl @@ -26,7 +26,7 @@ namespace detail { GLM_FUNC_QUALIFIER static vec call(vec const& x) { - GLM_STATIC_ASSERT(!std::numeric_limits::is_iec559, "'ceilPowerOfTwo' only accept integer scalar or vector inputs"); + GLM_STATIC_ASSERT(!std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'ceilPowerOfTwo' only accept integer scalar or vector inputs"); vec const Sign(sign(x)); @@ -48,7 +48,7 @@ namespace detail { GLM_FUNC_QUALIFIER static vec call(vec const& x) { - GLM_STATIC_ASSERT(!std::numeric_limits::is_iec559, "'ceilPowerOfTwo' only accept integer scalar or vector inputs"); + GLM_STATIC_ASSERT(!std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'ceilPowerOfTwo' only accept integer scalar or vector inputs"); vec v(x); diff --git a/glm/ext/scalar_reciprocal.inl b/glm/ext/scalar_reciprocal.inl index 570a406d..58a83f74 100644 --- a/glm/ext/scalar_reciprocal.inl +++ b/glm/ext/scalar_reciprocal.inl @@ -9,7 +9,7 @@ namespace glm template GLM_FUNC_QUALIFIER genType sec(genType angle) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'sec' only accept floating-point values"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'sec' only accept floating-point values"); return genType(1) / glm::cos(angle); } @@ -17,7 +17,7 @@ namespace glm template GLM_FUNC_QUALIFIER genType csc(genType angle) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'csc' only accept floating-point values"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'csc' only accept floating-point values"); return genType(1) / glm::sin(angle); } @@ -25,7 +25,7 @@ namespace glm template GLM_FUNC_QUALIFIER genType cot(genType angle) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'cot' only accept floating-point values"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'cot' only accept floating-point values"); genType const pi_over_2 = genType(3.1415926535897932384626433832795 / 2.0); return glm::tan(pi_over_2 - angle); @@ -35,7 +35,7 @@ namespace glm template GLM_FUNC_QUALIFIER genType asec(genType x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'asec' only accept floating-point values"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'asec' only accept floating-point values"); return acos(genType(1) / x); } @@ -43,7 +43,7 @@ namespace glm template GLM_FUNC_QUALIFIER genType acsc(genType x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'acsc' only accept floating-point values"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'acsc' only accept floating-point values"); return asin(genType(1) / x); } @@ -51,7 +51,7 @@ namespace glm template GLM_FUNC_QUALIFIER genType acot(genType x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'acot' only accept floating-point values"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'acot' only accept floating-point values"); genType const pi_over_2 = genType(3.1415926535897932384626433832795 / 2.0); return pi_over_2 - atan(x); @@ -61,7 +61,7 @@ namespace glm template GLM_FUNC_QUALIFIER genType sech(genType angle) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'sech' only accept floating-point values"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'sech' only accept floating-point values"); return genType(1) / glm::cosh(angle); } @@ -69,7 +69,7 @@ namespace glm template GLM_FUNC_QUALIFIER genType csch(genType angle) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'csch' only accept floating-point values"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'csch' only accept floating-point values"); return genType(1) / glm::sinh(angle); } @@ -77,7 +77,7 @@ namespace glm template GLM_FUNC_QUALIFIER genType coth(genType angle) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'coth' only accept floating-point values"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'coth' only accept floating-point values"); return glm::cosh(angle) / glm::sinh(angle); } @@ -85,7 +85,7 @@ namespace glm template GLM_FUNC_QUALIFIER genType asech(genType x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'asech' only accept floating-point values"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'asech' only accept floating-point values"); return acosh(genType(1) / x); } @@ -93,7 +93,7 @@ namespace glm template GLM_FUNC_QUALIFIER genType acsch(genType x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'acsch' only accept floating-point values"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'acsch' only accept floating-point values"); return asinh(genType(1) / x); } @@ -101,7 +101,7 @@ namespace glm template GLM_FUNC_QUALIFIER genType acoth(genType x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'acoth' only accept floating-point values"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'acoth' only accept floating-point values"); return atanh(genType(1) / x); } }//namespace glm diff --git a/glm/ext/scalar_ulp.inl b/glm/ext/scalar_ulp.inl index 308df150..c8fb863a 100644 --- a/glm/ext/scalar_ulp.inl +++ b/glm/ext/scalar_ulp.inl @@ -219,7 +219,7 @@ namespace glm template GLM_FUNC_QUALIFIER T nextFloat(T x, int ULPs) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'next_float' only accept floating-point input"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'next_float' only accept floating-point input"); assert(ULPs >= 0); T temp = x; @@ -257,7 +257,7 @@ namespace glm template GLM_FUNC_QUALIFIER T prevFloat(T x, int ULPs) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'prev_float' only accept floating-point input"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'prev_float' only accept floating-point input"); assert(ULPs >= 0); T temp = x; diff --git a/glm/ext/vector_reciprocal.inl b/glm/ext/vector_reciprocal.inl index 0d3c25fb..cb6eb6c5 100644 --- a/glm/ext/vector_reciprocal.inl +++ b/glm/ext/vector_reciprocal.inl @@ -9,7 +9,7 @@ namespace glm template GLM_FUNC_QUALIFIER vec sec(vec const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'sec' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'sec' only accept floating-point inputs"); return static_cast(1) / detail::functor1::call(cos, x); } @@ -17,7 +17,7 @@ namespace glm template GLM_FUNC_QUALIFIER vec csc(vec const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'csc' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'csc' only accept floating-point inputs"); return static_cast(1) / detail::functor1::call(sin, x); } @@ -25,7 +25,7 @@ namespace glm template GLM_FUNC_QUALIFIER vec cot(vec const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'cot' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'cot' only accept floating-point inputs"); T const pi_over_2 = static_cast(3.1415926535897932384626433832795 / 2.0); return detail::functor1::call(tan, pi_over_2 - x); } @@ -34,7 +34,7 @@ namespace glm template GLM_FUNC_QUALIFIER vec asec(vec const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'asec' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'asec' only accept floating-point inputs"); return detail::functor1::call(acos, static_cast(1) / x); } @@ -42,7 +42,7 @@ namespace glm template GLM_FUNC_QUALIFIER vec acsc(vec const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'acsc' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'acsc' only accept floating-point inputs"); return detail::functor1::call(asin, static_cast(1) / x); } @@ -50,7 +50,7 @@ namespace glm template GLM_FUNC_QUALIFIER vec acot(vec const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'acot' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'acot' only accept floating-point inputs"); T const pi_over_2 = static_cast(3.1415926535897932384626433832795 / 2.0); return pi_over_2 - detail::functor1::call(atan, x); } @@ -59,7 +59,7 @@ namespace glm template GLM_FUNC_QUALIFIER vec sech(vec const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'sech' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'sech' only accept floating-point inputs"); return static_cast(1) / detail::functor1::call(cosh, x); } @@ -67,7 +67,7 @@ namespace glm template GLM_FUNC_QUALIFIER vec csch(vec const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'csch' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'csch' only accept floating-point inputs"); return static_cast(1) / detail::functor1::call(sinh, x); } @@ -75,7 +75,7 @@ namespace glm template GLM_FUNC_QUALIFIER vec coth(vec const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'coth' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'coth' only accept floating-point inputs"); return glm::cosh(x) / glm::sinh(x); } @@ -83,7 +83,7 @@ namespace glm template GLM_FUNC_QUALIFIER vec asech(vec const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'asech' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'asech' only accept floating-point inputs"); return detail::functor1::call(acosh, static_cast(1) / x); } @@ -91,7 +91,7 @@ namespace glm template GLM_FUNC_QUALIFIER vec acsch(vec const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'acsch' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'acsch' only accept floating-point inputs"); return detail::functor1::call(asinh, static_cast(1) / x); } @@ -99,7 +99,7 @@ namespace glm template GLM_FUNC_QUALIFIER vec acoth(vec const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'acoth' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'acoth' only accept floating-point inputs"); return detail::functor1::call(atanh, static_cast(1) / x); } }//namespace glm diff --git a/glm/gtc/ulp.inl b/glm/gtc/ulp.inl index 4ecbd3f4..3598e7bd 100644 --- a/glm/gtc/ulp.inl +++ b/glm/gtc/ulp.inl @@ -35,7 +35,7 @@ namespace glm template GLM_FUNC_QUALIFIER T next_float(T x, int ULPs) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'next_float' only accept floating-point input"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'next_float' only accept floating-point input"); assert(ULPs >= 0); T temp = x; @@ -73,7 +73,7 @@ namespace glm template GLM_FUNC_QUALIFIER T prev_float(T x, int ULPs) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'prev_float' only accept floating-point input"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'prev_float' only accept floating-point input"); assert(ULPs >= 0); T temp = x; diff --git a/glm/gtx/common.inl b/glm/gtx/common.inl index 4ad2126d..ccde8c82 100644 --- a/glm/gtx/common.inl +++ b/glm/gtx/common.inl @@ -29,7 +29,7 @@ namespace detail template GLM_FUNC_QUALIFIER bool isdenormal(T const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'isdenormal' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'isdenormal' only accept floating-point inputs"); # if GLM_HAS_CXX11_STL return std::fpclassify(x) == FP_SUBNORMAL; @@ -44,7 +44,7 @@ namespace detail vec<1, T, Q> const& x ) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'isdenormal' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'isdenormal' only accept floating-point inputs"); return typename vec<1, T, Q>::bool_type( isdenormal(x.x)); @@ -56,7 +56,7 @@ namespace detail vec<2, T, Q> const& x ) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'isdenormal' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'isdenormal' only accept floating-point inputs"); return typename vec<2, T, Q>::bool_type( isdenormal(x.x), @@ -69,7 +69,7 @@ namespace detail vec<3, T, Q> const& x ) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'isdenormal' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'isdenormal' only accept floating-point inputs"); return typename vec<3, T, Q>::bool_type( isdenormal(x.x), @@ -83,7 +83,7 @@ namespace detail vec<4, T, Q> const& x ) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'isdenormal' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'isdenormal' only accept floating-point inputs"); return typename vec<4, T, Q>::bool_type( isdenormal(x.x), diff --git a/glm/gtx/exterior_product.inl b/glm/gtx/exterior_product.inl index d489142e..41169fef 100644 --- a/glm/gtx/exterior_product.inl +++ b/glm/gtx/exterior_product.inl @@ -10,7 +10,7 @@ namespace detail { GLM_FUNC_QUALIFIER GLM_CONSTEXPR static T call(vec<2, T, Q> const& v, vec<2, T, Q> const& u) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'cross' accepts only floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'cross' accepts only floating-point inputs"); return v.x * u.y - u.x * v.y; } diff --git a/glm/gtx/fast_square_root.inl b/glm/gtx/fast_square_root.inl index 4e6c6de9..827680c4 100644 --- a/glm/gtx/fast_square_root.inl +++ b/glm/gtx/fast_square_root.inl @@ -6,7 +6,7 @@ namespace glm template GLM_FUNC_QUALIFIER genType fastSqrt(genType x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'fastSqrt' only accept floating-point input"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'fastSqrt' only accept floating-point input"); return genType(1) / fastInverseSqrt(x); } @@ -34,7 +34,7 @@ namespace glm template GLM_FUNC_QUALIFIER genType fastLength(genType x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'fastLength' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'fastLength' only accept floating-point inputs"); return abs(x); } @@ -42,7 +42,7 @@ namespace glm template GLM_FUNC_QUALIFIER T fastLength(vec const& x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'fastLength' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'fastLength' only accept floating-point inputs"); return fastSqrt(dot(x, x)); } diff --git a/glm/gtx/norm.inl b/glm/gtx/norm.inl index 6db561b3..8cc84e7c 100644 --- a/glm/gtx/norm.inl +++ b/glm/gtx/norm.inl @@ -18,28 +18,28 @@ namespace detail template GLM_FUNC_QUALIFIER genType length2(genType x) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'length2' accepts only floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_CONFIG_UNRESTRICTED_SCALAR_TYPES, "'length2' accepts only floating-point inputs"); return x * x; } template GLM_FUNC_QUALIFIER T length2(vec const& v) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'length2' accepts only floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_CONFIG_UNRESTRICTED_SCALAR_TYPES, "'length2' accepts only floating-point inputs"); return detail::compute_length2::value>::call(v); } template GLM_FUNC_QUALIFIER T distance2(T p0, T p1) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'distance2' accepts only floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_CONFIG_UNRESTRICTED_SCALAR_TYPES, "'distance2' accepts only floating-point inputs"); return length2(p1 - p0); } template GLM_FUNC_QUALIFIER T distance2(vec const& p0, vec const& p1) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'distance2' accepts only floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_CONFIG_UNRESTRICTED_SCALAR_TYPES, "'distance2' accepts only floating-point inputs"); return length2(p1 - p0); } diff --git a/glm/gtx/vector_angle.inl b/glm/gtx/vector_angle.inl index 878160d9..e56ef0d6 100644 --- a/glm/gtx/vector_angle.inl +++ b/glm/gtx/vector_angle.inl @@ -16,14 +16,14 @@ namespace glm template GLM_FUNC_QUALIFIER T angle(vec const& x, vec const& y) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'angle' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'angle' only accept floating-point inputs"); return acos(clamp(dot(x, y), T(-1), T(1))); } template GLM_FUNC_QUALIFIER T orientedAngle(vec<2, T, Q> const& x, vec<2, T, Q> const& y) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'orientedAngle' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'orientedAngle' only accept floating-point inputs"); T const Angle(acos(clamp(dot(x, y), T(-1), T(1)))); T const partialCross = x.x * y.y - y.x * x.y; @@ -37,7 +37,7 @@ namespace glm template GLM_FUNC_QUALIFIER T orientedAngle(vec<3, T, Q> const& x, vec<3, T, Q> const& y, vec<3, T, Q> const& ref) { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'orientedAngle' only accept floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_FORCE_UNRESTRICTED_FLOAT, "'orientedAngle' only accept floating-point inputs"); T const Angle(acos(clamp(dot(x, y), T(-1), T(1)))); return mix(Angle, -Angle, dot(ref, cross(x, y)) < T(0)); diff --git a/readme.md b/readme.md index 040ed3f2..9960aa84 100644 --- a/readme.md +++ b/readme.md @@ -92,6 +92,7 @@ vcpkg install glm - Added `glm::iround` and `glm::uround` to *GLM_EXT_scalar_common* and *GLM_EXT_vector_common* - Added *GLM_EXT_matrix_integer* with tests - Added Github Actions +- Added GLM_FORCE_UNRESTRICTED_FLOAT to prevent static asserts when using other scalar types with function expecting floats. #### Improvements: - Added `constexpr` qualifier for `cross` product #1040