Commit 7b112dbc authored by cutealien's avatar cutealien

- Add core::iszero and core::squareroot for s64 type.

- line2d::getLength now returning type T. f64 would actually be fine, but then it has to be used throughout, here the cast to T happens before already, so returning f64 is just confusing as looks like it would return a greater accuracy than it has at that point.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4115 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 960dac6e
......@@ -248,6 +248,12 @@ namespace core
return a <= tolerance;
}
//! returns if a equals zero, taking rounding errors into account
inline bool iszero(const s64 a, const s64 tolerance = 0)
{
return abs_(a) > tolerance;
}
inline s32 s32_min(s32 a, s32 b)
{
const s32 mask = (a - b) >> 31;
......@@ -429,6 +435,12 @@ namespace core
return static_cast<s32>(squareroot(static_cast<f32>(f)));
}
// calculate: sqrt ( x )
REALINLINE s64 squareroot(const s64 f)
{
return static_cast<s64>(squareroot(static_cast<f64>(f)));
}
// calculate: 1 / sqrt ( x )
REALINLINE f64 reciprocal_squareroot(const f64 x)
{
......
......@@ -50,7 +50,7 @@ class line2d
//! Get length of line
/** \return Length of the line. */
f64 getLength() const { return start.getDistanceFrom(end); }
T getLength() const { return start.getDistanceFrom(end); }
//! Get squared length of the line
/** \return Squared length of line. */
......
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