diff options
author | Alexander Harkness <bearbin@gmail.com> | 2015-05-19 19:43:19 +0200 |
---|---|---|
committer | Alexander Harkness <bearbin@gmail.com> | 2015-05-19 19:43:19 +0200 |
commit | cbb425f027a7b51c4aed5d3399b26cf325c4c8ce (patch) | |
tree | 6a35f2c9c44b7d3d5142635178bf1ec9ca5e428c /src/Vector3.h | |
parent | Updated Core. (diff) | |
parent | Merge pull request #2057 from Seadragon91/master (diff) | |
download | cuberite-cbb425f027a7b51c4aed5d3399b26cf325c4c8ce.tar cuberite-cbb425f027a7b51c4aed5d3399b26cf325c4c8ce.tar.gz cuberite-cbb425f027a7b51c4aed5d3399b26cf325c4c8ce.tar.bz2 cuberite-cbb425f027a7b51c4aed5d3399b26cf325c4c8ce.tar.lz cuberite-cbb425f027a7b51c4aed5d3399b26cf325c4c8ce.tar.xz cuberite-cbb425f027a7b51c4aed5d3399b26cf325c4c8ce.tar.zst cuberite-cbb425f027a7b51c4aed5d3399b26cf325c4c8ce.zip |
Diffstat (limited to 'src/Vector3.h')
-rw-r--r-- | src/Vector3.h | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/Vector3.h b/src/Vector3.h index c5431438e..346bc1bbb 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -78,6 +78,20 @@ public: ); } + inline bool HasNonZeroLength(void) const + { + #ifdef __clang__ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wfloat-equal" + #endif + + return ((x != 0) || (y != 0) || (z != 0)); + + #ifdef __clang__ + #pragma clang diagnostic pop + #endif + } + inline double Length(void) const { return sqrt(static_cast<double>(x * x + y * y + z * z)); @@ -119,13 +133,19 @@ public: inline bool Equals(const Vector3<T> & a_Rhs) const { - // Perform a bitwise comparison of the contents - we want to know whether this object is exactly equal + // Perform a strict comparison of the contents - we want to know whether this object is exactly equal // To perform EPS-based comparison, use the EqualsEps() function - return ( - (memcmp(&x, &a_Rhs.x, sizeof(x)) == 0) && - (memcmp(&y, &a_Rhs.y, sizeof(y)) == 0) && - (memcmp(&z, &a_Rhs.z, sizeof(z)) == 0) - ); + + #ifdef __clang__ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wfloat-equal" + #endif + + return !((x != a_Rhs.x) || (y != a_Rhs.y) || (z != a_Rhs.z)); + + #ifdef __clang__ + #pragma clang diagnostic pop + #endif } inline bool EqualsEps(const Vector3<T> & a_Rhs, T a_Eps) const |