From bd7710d7c11a3ce30b06d3b0b172baccafad5303 Mon Sep 17 00:00:00 2001 From: Steven French Date: Mon, 19 Aug 2024 14:44:44 +1200 Subject: [PATCH 1/3] wrap min/max calls in brackets --- glm/ext/quaternion_exponential.inl | 2 +- glm/gtx/component_wise.inl | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/glm/ext/quaternion_exponential.inl b/glm/ext/quaternion_exponential.inl index 8a9d774b39..26c4ab14be 100644 --- a/glm/ext/quaternion_exponential.inl +++ b/glm/ext/quaternion_exponential.inl @@ -60,7 +60,7 @@ namespace glm //VectorMagnitude to 0. here; we could use denorm_int() compiling a //project with unsafe maths optimizations might make the comparison //always false, even when VectorMagnitude is 0. - if (VectorMagnitude < std::numeric_limits::min()) { + if (VectorMagnitude < (std::numeric_limits::min)()) { //Equivalent to raising a real number to a power return qua::wxyz(pow(x.w, y), 0, 0, 0); } diff --git a/glm/gtx/component_wise.inl b/glm/gtx/component_wise.inl index f8217b2efe..a2eac83fbf 100644 --- a/glm/gtx/component_wise.inl +++ b/glm/gtx/component_wise.inl @@ -16,8 +16,8 @@ namespace detail { GLM_FUNC_QUALIFIER static vec call(vec const& v) { - floatType const Min = static_cast(std::numeric_limits::min()); - floatType const Max = static_cast(std::numeric_limits::max()); + floatType const Min = static_cast((std::numeric_limits::min)()); + floatType const Max = static_cast((std::numeric_limits::max)()); return (vec(v) - Min) / (Max - Min) * static_cast(2) - static_cast(1); } }; @@ -27,7 +27,7 @@ namespace detail { GLM_FUNC_QUALIFIER static vec call(vec const& v) { - return vec(v) / static_cast(std::numeric_limits::max()); + return vec(v) / static_cast((std::numeric_limits::max)()); } }; @@ -49,7 +49,7 @@ namespace detail { GLM_FUNC_QUALIFIER static vec call(vec const& v) { - floatType const Max = static_cast(std::numeric_limits::max()) + static_cast(0.5); + floatType const Max = static_cast((std::numeric_limits::max)()) + static_cast(0.5); vec const Scaled(v * Max); vec const Result(Scaled - static_cast(0.5)); return Result; @@ -61,7 +61,7 @@ namespace detail { GLM_FUNC_QUALIFIER static vec call(vec const& v) { - return vec(vec(v) * static_cast(std::numeric_limits::max())); + return vec(vec(v) * static_cast((std::numeric_limits::max)())); } }; From d4d46dd8ca4db6fecf6bd65a8c7d5d1012393e77 Mon Sep 17 00:00:00 2001 From: Steven French Date: Mon, 19 Aug 2024 15:01:06 +1200 Subject: [PATCH 2/3] some more min/max wrappings --- glm/ext/scalar_common.hpp | 20 ++++++++++---------- glm/ext/scalar_common.inl | 16 ++++++++-------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/glm/ext/scalar_common.hpp b/glm/ext/scalar_common.hpp index df04b6b809..0a0f759a05 100644 --- a/glm/ext/scalar_common.hpp +++ b/glm/ext/scalar_common.hpp @@ -31,7 +31,7 @@ namespace glm /// /// @see ext_scalar_common template - GLM_FUNC_DECL T min(T a, T b, T c); + GLM_FUNC_DECL T (min)(T a, T b, T c); /// Returns the minimum component-wise values of 4 inputs /// @@ -39,7 +39,7 @@ namespace glm /// /// @see ext_scalar_common template - GLM_FUNC_DECL T min(T a, T b, T c, T d); + GLM_FUNC_DECL T (min)(T a, T b, T c, T d); /// Returns the maximum component-wise values of 3 inputs /// @@ -47,7 +47,7 @@ namespace glm /// /// @see ext_scalar_common template - GLM_FUNC_DECL T max(T a, T b, T c); + GLM_FUNC_DECL T (max)(T a, T b, T c); /// Returns the maximum component-wise values of 4 inputs /// @@ -55,7 +55,7 @@ namespace glm /// /// @see ext_scalar_common template - GLM_FUNC_DECL T max(T a, T b, T c, T d); + GLM_FUNC_DECL T (max)(T a, T b, T c, T d); /// Returns the minimum component-wise values of 2 inputs. If one of the two arguments is NaN, the value of the other argument is returned. /// @@ -64,7 +64,7 @@ namespace glm /// @see std::fmin documentation /// @see ext_scalar_common template - GLM_FUNC_DECL T fmin(T a, T b); + GLM_FUNC_DECL T (fmin)(T a, T b); /// Returns the minimum component-wise values of 3 inputs. If one of the two arguments is NaN, the value of the other argument is returned. /// @@ -73,7 +73,7 @@ namespace glm /// @see std::fmin documentation /// @see ext_scalar_common template - GLM_FUNC_DECL T fmin(T a, T b, T c); + GLM_FUNC_DECL T (fmin)(T a, T b, T c); /// Returns the minimum component-wise values of 4 inputs. If one of the two arguments is NaN, the value of the other argument is returned. /// @@ -82,7 +82,7 @@ namespace glm /// @see std::fmin documentation /// @see ext_scalar_common template - GLM_FUNC_DECL T fmin(T a, T b, T c, T d); + GLM_FUNC_DECL T (fmin)(T a, T b, T c, T d); /// Returns the maximum component-wise values of 2 inputs. If one of the two arguments is NaN, the value of the other argument is returned. /// @@ -91,7 +91,7 @@ namespace glm /// @see std::fmax documentation /// @see ext_scalar_common template - GLM_FUNC_DECL T fmax(T a, T b); + GLM_FUNC_DECL T (fmax)(T a, T b); /// Returns the maximum component-wise values of 3 inputs. If one of the two arguments is NaN, the value of the other argument is returned. /// @@ -100,7 +100,7 @@ namespace glm /// @see std::fmax documentation /// @see ext_scalar_common template - GLM_FUNC_DECL T fmax(T a, T b, T C); + GLM_FUNC_DECL T (fmax)(T a, T b, T C); /// Returns the maximum component-wise values of 4 inputs. If one of the two arguments is NaN, the value of the other argument is returned. /// @@ -109,7 +109,7 @@ namespace glm /// @see std::fmax documentation /// @see ext_scalar_common template - GLM_FUNC_DECL T fmax(T a, T b, T C, T D); + GLM_FUNC_DECL T (fmax)(T a, T b, T C, T D); /// Returns min(max(x, minVal), maxVal) for each component in x. If one of the two arguments is NaN, the value of the other argument is returned. /// diff --git a/glm/ext/scalar_common.inl b/glm/ext/scalar_common.inl index 3d09fef0cb..a24db5ffdb 100644 --- a/glm/ext/scalar_common.inl +++ b/glm/ext/scalar_common.inl @@ -1,27 +1,27 @@ namespace glm { template - GLM_FUNC_QUALIFIER T min(T a, T b, T c) + GLM_FUNC_QUALIFIER T (min)(T a, T b, T c) { - return glm::min(glm::min(a, b), c); + return (glm::min)((glm::min)(a, b), c); } template - GLM_FUNC_QUALIFIER T min(T a, T b, T c, T d) + GLM_FUNC_QUALIFIER T (min)(T a, T b, T c, T d) { - return glm::min(glm::min(a, b), glm::min(c, d)); + return (glm::min)((glm::min)(a, b), (glm::min)(c, d)); } template - GLM_FUNC_QUALIFIER T max(T a, T b, T c) + GLM_FUNC_QUALIFIER T (max)(T a, T b, T c) { - return glm::max(glm::max(a, b), c); + return (glm::max)((glm::max)(a, b), c); } template - GLM_FUNC_QUALIFIER T max(T a, T b, T c, T d) + GLM_FUNC_QUALIFIER T (max)(T a, T b, T c, T d) { - return glm::max(glm::max(a, b), glm::max(c, d)); + return (glm::max)((glm::max)(a, b), (glm::max)(c, d)); } # if GLM_HAS_CXX11_STL From 99d02397831216b5c9282fdf01f080c46738b6d6 Mon Sep 17 00:00:00 2001 From: Steven French Date: Mon, 19 Aug 2024 15:14:37 +1200 Subject: [PATCH 3/3] some more min/max wrappings 2 --- glm/ext/scalar_common.inl | 48 +++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/glm/ext/scalar_common.inl b/glm/ext/scalar_common.inl index a24db5ffdb..97edcf5157 100644 --- a/glm/ext/scalar_common.inl +++ b/glm/ext/scalar_common.inl @@ -39,33 +39,33 @@ namespace glm # endif template - 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::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 - 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::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 - GLM_FUNC_QUALIFIER T fmax(T a, T b) + GLM_FUNC_QUALIFIER T (fmax)(T a, T b) { GLM_STATIC_ASSERT(std::numeric_limits::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 - 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::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 - 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::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::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