mirror of
https://github.com/g-truc/glm.git
synced 2024-11-10 04:31:47 +00:00
- Fixed unexpected operator== behavior #723
This commit is contained in:
parent
c3c8b73c57
commit
c46981b4c3
@ -7,23 +7,6 @@
|
||||
namespace glm{
|
||||
namespace detail
|
||||
{
|
||||
template <typename T, bool isFloat>
|
||||
struct compute_equal
|
||||
{
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR static bool call(T a, T b)
|
||||
{
|
||||
return a == b;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct compute_equal<T, true>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR static bool call(T a, T b)
|
||||
{
|
||||
return detail::compute_abs<T, std::numeric_limits<T>::is_signed>::call(b - a) <= static_cast<T>(0);
|
||||
//return std::memcmp(&a, &b, sizeof(T)) == 0;
|
||||
}
|
||||
};
|
||||
}//namespace detail
|
||||
}//namespace glm
|
||||
|
@ -64,7 +64,7 @@ namespace glm
|
||||
|
||||
vec<L, bool, Q> Result GLM_BUG_VC_INIT;
|
||||
for(length_t i = 0; i < x.length(); ++i)
|
||||
Result[i] = detail::compute_equal<T, std::numeric_limits<T>::is_iec559>::call(x[i], y[i]);
|
||||
Result[i] = x[i] == y[i];
|
||||
return Result;
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ namespace glm
|
||||
|
||||
vec<L, bool, Q> Result GLM_BUG_VC_INIT;
|
||||
for(length_t i = 0; i < x.length(); ++i)
|
||||
Result[i] = !detail::compute_equal<T, std::numeric_limits<T>::is_iec559>::call(x[i], y[i]);
|
||||
Result[i] = x[i] != y[i];
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
@ -529,7 +529,7 @@ namespace glm
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(vec<1, T, Q> const& v1, vec<1, T, Q> const& v2)
|
||||
{
|
||||
return detail::compute_equal<T, std::numeric_limits<T>::is_iec559>::call(v1.x, v2.x);
|
||||
return v1.x == v2.x;
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
|
@ -875,9 +875,7 @@ namespace glm
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(vec<2, T, Q> const& v1, vec<2, T, Q> const& v2)
|
||||
{
|
||||
return
|
||||
detail::compute_equal<T, std::numeric_limits<T>::is_iec559>::call(v1.x, v2.x) &&
|
||||
detail::compute_equal<T, std::numeric_limits<T>::is_iec559>::call(v1.y, v2.y);
|
||||
return v1.x == v2.x && v1.y == v2.y;
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
|
@ -1023,10 +1023,7 @@ namespace glm
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR bool operator==(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2)
|
||||
{
|
||||
return
|
||||
detail::compute_equal<T, std::numeric_limits<T>::is_iec559>::call(v1.x, v2.x) &&
|
||||
detail::compute_equal<T, std::numeric_limits<T>::is_iec559>::call(v1.y, v2.y) &&
|
||||
detail::compute_equal<T, std::numeric_limits<T>::is_iec559>::call(v1.z, v2.z);
|
||||
return v1.x == v2.x && v1.y == v2.y && v1.z == v2.z;
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
|
@ -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<T, std::numeric_limits<T>::is_iec559>::call(v1.x, v2.x) &&
|
||||
detail::compute_equal<T, std::numeric_limits<T>::is_iec559>::call(v1.y, v2.y) &&
|
||||
detail::compute_equal<T, std::numeric_limits<T>::is_iec559>::call(v1.z, v2.z) &&
|
||||
detail::compute_equal<T, std::numeric_limits<T>::is_iec559>::call(v1.w, v2.w);
|
||||
return v1.x == v2.x && v1.y == v2.y && v1.z == v2.z && v1.w == v2.w;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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<float, std::numeric_limits<float>::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));
|
||||
|
||||
|
@ -600,7 +600,7 @@ namespace detail
|
||||
const T y = static_cast<T>(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<T, std::numeric_limits<T>::is_iec559>::call(y, static_cast<T>(0)) && detail::compute_equal<T, std::numeric_limits<T>::is_iec559>::call(x, static_cast<T>(0))) //avoid atan2(0,0) - handle singularity - Matiis
|
||||
if(y == static_cast<T>(0) && x == static_cast<T>(0)) //avoid atan2(0,0) - handle singularity - Matiis
|
||||
return static_cast<T>(static_cast<T>(2) * atan(q.x,q.w));
|
||||
|
||||
return static_cast<T>(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<T, std::numeric_limits<T>::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<T, std::numeric_limits<T>::is_iec559>::call(x[i], y[i]);
|
||||
Result[i] = x[i] != y[i];
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
@ -82,13 +82,13 @@ namespace detail
|
||||
if((ix>0x7f800000) || // x is nan
|
||||
(iy>0x7f800000)) // y is nan
|
||||
return x+y;
|
||||
if(compute_equal<float, std::numeric_limits<float>::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<float, true>::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<float, true>::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<double, true>::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<double, true>::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<double, true>::call(t, x))
|
||||
if(abs(t - x) > 0.0)
|
||||
{ // raise underflow flag
|
||||
GLM_INSERT_WORDS(y,hx,lx);
|
||||
return y;
|
||||
|
@ -50,7 +50,7 @@ namespace glm
|
||||
T const& y
|
||||
)
|
||||
{
|
||||
return detail::compute_equal<T, std::numeric_limits<T>::is_iec559>::call(x, y);
|
||||
return x == y;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@ -60,7 +60,7 @@ namespace glm
|
||||
T const& y
|
||||
)
|
||||
{
|
||||
return !detail::compute_equal<T, std::numeric_limits<T>::is_iec559>::call(x, y);
|
||||
return x != y;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER bool any
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user