master #4

Merged
BRNSystems merged 17 commits from Mirrorlandia_minetest/irrlicht:master into master 2024-01-28 00:16:35 +01:00
2 changed files with 31 additions and 34 deletions
Showing only changes of commit 345285786f - Show all commits

@ -75,36 +75,37 @@ public:
return *(&X+index); return *(&X+index);
} }
//! sort in order X, Y. Equality with rounding tolerance. //! sort in order X, Y.
bool operator<=(const vector2d<T>&other) const bool operator<=(const vector2d<T>&other) const
{ {
return (X<other.X || core::equals(X, other.X)) || return !(*this > other);
(core::equals(X, other.X) && (Y<other.Y || core::equals(Y, other.Y)));
} }
//! sort in order X, Y. Equality with rounding tolerance. //! sort in order X, Y.
bool operator>=(const vector2d<T>&other) const bool operator>=(const vector2d<T>&other) const
{ {
return (X>other.X || core::equals(X, other.X)) || return !(*this < other);
(core::equals(X, other.X) && (Y>other.Y || core::equals(Y, other.Y)));
} }
//! sort in order X, Y. Difference must be above rounding tolerance. //! sort in order X, Y.
bool operator<(const vector2d<T>&other) const bool operator<(const vector2d<T>&other) const
{ {
return (X<other.X && !core::equals(X, other.X)) || return X < other.X || (X == other.X && Y < other.Y);
(core::equals(X, other.X) && Y<other.Y && !core::equals(Y, other.Y));
} }
//! sort in order X, Y. Difference must be above rounding tolerance. //! sort in order X, Y.
bool operator>(const vector2d<T>&other) const bool operator>(const vector2d<T>&other) const
{ {
return (X>other.X && !core::equals(X, other.X)) || return X > other.X || (X == other.X && Y > other.Y);
(core::equals(X, other.X) && Y>other.Y && !core::equals(Y, other.Y));
} }
bool operator==(const vector2d<T>& other) const { return equals(other); } bool operator==(const vector2d<T>& other) const {
bool operator!=(const vector2d<T>& other) const { return !equals(other); } return X == other.X && Y == other.Y;
}
bool operator!=(const vector2d<T>& other) const {
return !(*this == other);
}
// functions // functions

@ -68,52 +68,48 @@ namespace core
return *(&X+index); return *(&X+index);
} }
//! sort in order X, Y, Z. Equality with rounding tolerance. //! sort in order X, Y, Z.
bool operator<=(const vector3d<T>&other) const bool operator<=(const vector3d<T>&other) const
{ {
return (X<other.X || core::equals(X, other.X)) || return !(*this > other);
(core::equals(X, other.X) && (Y<other.Y || core::equals(Y, other.Y))) ||
(core::equals(X, other.X) && core::equals(Y, other.Y) && (Z<other.Z || core::equals(Z, other.Z)));
} }
//! sort in order X, Y, Z. Equality with rounding tolerance. //! sort in order X, Y, Z.
bool operator>=(const vector3d<T>&other) const bool operator>=(const vector3d<T>&other) const
{ {
return (X>other.X || core::equals(X, other.X)) || return !(*this < other);
(core::equals(X, other.X) && (Y>other.Y || core::equals(Y, other.Y))) ||
(core::equals(X, other.X) && core::equals(Y, other.Y) && (Z>other.Z || core::equals(Z, other.Z)));
} }
//! sort in order X, Y, Z. Difference must be above rounding tolerance. //! sort in order X, Y, Z.
bool operator<(const vector3d<T>&other) const bool operator<(const vector3d<T>&other) const
{ {
return (X<other.X && !core::equals(X, other.X)) || return X < other.X || (X == other.X && Y < other.Y) ||
(core::equals(X, other.X) && Y<other.Y && !core::equals(Y, other.Y)) || (X == other.X && Y == other.Y && Z < other.Z);
(core::equals(X, other.X) && core::equals(Y, other.Y) && Z<other.Z && !core::equals(Z, other.Z));
} }
//! sort in order X, Y, Z. Difference must be above rounding tolerance. //! sort in order X, Y, Z.
bool operator>(const vector3d<T>&other) const bool operator>(const vector3d<T>&other) const
{ {
return (X>other.X && !core::equals(X, other.X)) || return X > other.X || (X == other.X && Y > other.Y) ||
(core::equals(X, other.X) && Y>other.Y && !core::equals(Y, other.Y)) || (X == other.X && Y == other.Y && Z > other.Z);
(core::equals(X, other.X) && core::equals(Y, other.Y) && Z>other.Z && !core::equals(Z, other.Z));
} }
//! use weak float compare
bool operator==(const vector3d<T>& other) const bool operator==(const vector3d<T>& other) const
{ {
return this->equals(other); return X == other.X && Y == other.Y && Z == other.Z;
} }
bool operator!=(const vector3d<T>& other) const bool operator!=(const vector3d<T>& other) const
{ {
return !this->equals(other); return !(*this == other);
} }
// functions // functions
//! returns if this vector equals the other one, taking floating point rounding errors into account //! Checks if this vector equals the other one.
/** Takes floating point rounding errors into account.
\param other Vector to compare with.
\return True if the two vector are (almost) equal, else false. */
bool equals(const vector3d<T>& other) const bool equals(const vector3d<T>& other) const
{ {
return core::equals(X, other.X) && core::equals(Y, other.Y) && core::equals(Z, other.Z); return core::equals(X, other.X) && core::equals(Y, other.Y) && core::equals(Z, other.Z);