Commit 3838470c authored by hybrid's avatar hybrid

Fixed a comparison bug when using 0 tolerance. Found by wolfpack and fixed by vitek.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@846 dfc29bdd-3216-0410-991c-e03cc46cb475
parent f46caaa2
...@@ -116,14 +116,14 @@ namespace core ...@@ -116,14 +116,14 @@ namespace core
//! point rounding errors into account //! point rounding errors into account
inline bool equals(const f32 a, const f32 b, const f32 tolerance = ROUNDING_ERROR_32) inline bool equals(const f32 a, const f32 b, const f32 tolerance = ROUNDING_ERROR_32)
{ {
return (a + tolerance > b) && (a - tolerance < b); return (a + tolerance >= b) && (a - tolerance <= b);
} }
//! returns if a float equals zero, taking floating //! returns if a float equals zero, taking floating
//! point rounding errors into account //! point rounding errors into account
inline bool iszero(const f32 a, const f32 tolerance = ROUNDING_ERROR_32) inline bool iszero(const f32 a, const f32 tolerance = ROUNDING_ERROR_32)
{ {
return fabs ( a ) < tolerance; return fabs ( a ) <= tolerance;
} }
inline s32 s32_min ( s32 a, s32 b) inline s32 s32_min ( s32 a, s32 b)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment