diff --git a/glm/detail/compute_vector_relational.hpp b/glm/detail/compute_vector_relational.hpp index 20637a3c..e1cf3490 100644 --- a/glm/detail/compute_vector_relational.hpp +++ b/glm/detail/compute_vector_relational.hpp @@ -7,23 +7,6 @@ namespace glm{ namespace detail { - template - struct compute_equal - { - GLM_FUNC_QUALIFIER GLM_CONSTEXPR static bool call(T a, T b) - { - return a == b; - } - }; - template - struct compute_equal - { - GLM_FUNC_QUALIFIER GLM_CONSTEXPR static bool call(T a, T b) - { - return detail::compute_abs::is_signed>::call(b - a) <= static_cast(0); - //return std::memcmp(&a, &b, sizeof(T)) == 0; - } - }; }//namespace detail }//namespace glm diff --git a/glm/detail/func_vector_relational.inl b/glm/detail/func_vector_relational.inl index 1b256eda..85014396 100644 --- a/glm/detail/func_vector_relational.inl +++ b/glm/detail/func_vector_relational.inl @@ -64,7 +64,7 @@ namespace glm vec Result GLM_BUG_VC_INIT; for(length_t i = 0; i < x.length(); ++i) - Result[i] = detail::compute_equal::is_iec559>::call(x[i], y[i]); + Result[i] = x[i] == y[i]; return Result; } @@ -75,7 +75,7 @@ namespace glm vec Result GLM_BUG_VC_INIT; for(length_t i = 0; i < x.length(); ++i) - Result[i] = !detail::compute_equal::is_iec559>::call(x[i], y[i]); + Result[i] = x[i] != y[i]; return Result; } diff --git a/glm/detail/type_vec1.inl b/glm/detail/type_vec1.inl index 9f971501..dcb229bf 100644 --- a/glm/detail/type_vec1.inl +++ b/glm/detail/type_vec1.inl @@ -529,7 +529,7 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2) { - return detail::compute_equal::is_iec559>::call(v1.x, v2.x); + return v1.x == v2.x; } template diff --git a/glm/detail/type_vec2.inl b/glm/detail/type_vec2.inl index d1727a3e..8f924d79 100644 --- a/glm/detail/type_vec2.inl +++ b/glm/detail/type_vec2.inl @@ -875,9 +875,7 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2) { - return - detail::compute_equal::is_iec559>::call(v1.x, v2.x) && - detail::compute_equal::is_iec559>::call(v1.y, v2.y); + return v1.x == v2.x && v1.y == v2.y; } template diff --git a/glm/detail/type_vec3.inl b/glm/detail/type_vec3.inl index ca9707a9..6bfb03fc 100644 --- a/glm/detail/type_vec3.inl +++ b/glm/detail/type_vec3.inl @@ -1023,10 +1023,7 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2) { - return - detail::compute_equal::is_iec559>::call(v1.x, v2.x) && - detail::compute_equal::is_iec559>::call(v1.y, v2.y) && - detail::compute_equal::is_iec559>::call(v1.z, v2.z); + return v1.x == v2.x && v1.y == v2.y && v1.z == v2.z; } template diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index 2565d547..0055a45b 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -129,11 +129,7 @@ namespace detail { GLM_FUNC_QUALIFIER GLM_CONSTEXPR static bool call(vec<4, T, Q> const& v1, vec<4, T, Q> const& v2) { - return - detail::compute_equal::is_iec559>::call(v1.x, v2.x) && - detail::compute_equal::is_iec559>::call(v1.y, v2.y) && - detail::compute_equal::is_iec559>::call(v1.z, v2.z) && - detail::compute_equal::is_iec559>::call(v1.w, v2.w); + return v1.x == v2.x && v1.y == v2.y && v1.z == v2.z && v1.w == v2.w; } }; diff --git a/glm/gtc/packing.inl b/glm/gtc/packing.inl index eebdc1de..3105679f 100644 --- a/glm/gtc/packing.inl +++ b/glm/gtc/packing.inl @@ -620,7 +620,7 @@ namespace detail float const ExpSharedP = max(-15.f - 1.f, floor(log2(MaxColor))) + 1.0f + 15.f; float const MaxShared = floor(MaxColor / pow(2.0f, (ExpSharedP - 15.f - 9.f)) + 0.5f); - float const ExpShared = detail::compute_equal::is_iec559>::call(MaxShared, pow(2.0f, 9.0f)) ? ExpSharedP + 1.0f : ExpSharedP; + float const ExpShared = MaxShared == pow(2.0f, 9.0f) ? ExpSharedP + 1.0f : ExpSharedP; uvec3 const ColorComp(floor(Color / pow(2.f, (ExpShared - 15.f - 9.f)) + 0.5f)); diff --git a/glm/gtc/quaternion.inl b/glm/gtc/quaternion.inl index 0ea87f09..255744e3 100644 --- a/glm/gtc/quaternion.inl +++ b/glm/gtc/quaternion.inl @@ -600,7 +600,7 @@ namespace detail const T y = static_cast(2) * (q.y * q.z + q.w * q.x); const T x = q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z; - if(detail::compute_equal::is_iec559>::call(y, static_cast(0)) && detail::compute_equal::is_iec559>::call(x, static_cast(0))) //avoid atan2(0,0) - handle singularity - Matiis + if(y == static_cast(0) && x == static_cast(0)) //avoid atan2(0,0) - handle singularity - Matiis return static_cast(static_cast(2) * atan(q.x,q.w)); return static_cast(atan(y,x)); @@ -769,7 +769,7 @@ namespace detail { vec<4, bool, Q> Result; for(length_t i = 0; i < x.length(); ++i) - Result[i] = detail::compute_equal::is_iec559>::call(x[i], y[i]); + Result[i] = x[i] == y[i]; return Result; } @@ -778,7 +778,7 @@ namespace detail { vec<4, bool, Q> Result; for(length_t i = 0; i < x.length(); ++i) - Result[i] = !detail::compute_equal::is_iec559>::call(x[i], y[i]); + Result[i] = x[i] != y[i]; return Result; } diff --git a/glm/gtc/ulp.inl b/glm/gtc/ulp.inl index ed018d5e..b1954c7f 100644 --- a/glm/gtc/ulp.inl +++ b/glm/gtc/ulp.inl @@ -82,13 +82,13 @@ namespace detail if((ix>0x7f800000) || // x is nan (iy>0x7f800000)) // y is nan return x+y; - if(compute_equal::is_iec559>::call(x, y)) + if(x == y) return y; // x=y, return y if(ix==0) { // x == 0 GLM_SET_FLOAT_WORD(x,(hy&0x80000000)|1);// return +-minsubnormal t = x*x; - if(detail::compute_equal::call(t, x)) + if(abs(t - x) <= 0.0f) return t; else return x; // raise underflow flag @@ -113,7 +113,7 @@ namespace detail if(hy<0x00800000) // underflow { t = x*x; - if(!detail::compute_equal::call(t, x)) + if(abs(t - x) > 0.0f) { // raise underflow flag GLM_SET_FLOAT_WORD(y,hx); return y; @@ -137,13 +137,13 @@ namespace detail if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) || // x is nan ((iy>=0x7ff00000)&&((iy-0x7ff00000)|ly)!=0)) // y is nan return x+y; - if(detail::compute_equal::call(x, y)) + if(x == y) return y; // x=y, return y if((ix|lx)==0) { // x == 0 GLM_INSERT_WORDS(x, hy & 0x80000000, 1); // return +-minsubnormal t = x*x; - if(detail::compute_equal::call(t, x)) + if(abs(t - x) <= 0.0) return t; else return x; // raise underflow flag @@ -171,7 +171,7 @@ namespace detail if(hy<0x00100000) { // underflow t = x*x; - if(!detail::compute_equal::call(t, x)) + if(abs(t - x) > 0.0) { // raise underflow flag GLM_INSERT_WORDS(y,hx,lx); return y; diff --git a/glm/gtx/scalar_relational.inl b/glm/gtx/scalar_relational.inl index c616e07e..c6b26c2d 100644 --- a/glm/gtx/scalar_relational.inl +++ b/glm/gtx/scalar_relational.inl @@ -50,7 +50,7 @@ namespace glm T const& y ) { - return detail::compute_equal::is_iec559>::call(x, y); + return x == y; } template @@ -60,7 +60,7 @@ namespace glm T const& y ) { - return !detail::compute_equal::is_iec559>::call(x, y); + return x != y; } GLM_FUNC_QUALIFIER bool any diff --git a/readme.md b/readme.md index c338aa56..3be5887a 100644 --- a/readme.md +++ b/readme.md @@ -69,6 +69,7 @@ glm::mat4 camera(float Translate, glm::vec2 const& Rotate) - Fixed ortho #790 - Fixed Visual C++ 2013 warnings in vector relational code #782 - Fixed ICC build errors with constexpr #704 +- Fixed unexpected operator== behavior #723 ### [GLM 0.9.9.0](https://github.com/g-truc/glm/releases/tag/0.9.9.0) - 2018-05-22 #### Features: