summaryrefslogtreecommitdiffstats
path: root/src/Vector3.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Vector3.h')
-rw-r--r--src/Vector3.h42
1 files changed, 36 insertions, 6 deletions
diff --git a/src/Vector3.h b/src/Vector3.h
index 1f3f6b955..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
@@ -244,6 +264,15 @@ public:
);
}
+ inline Vector3<T> operator / (const Vector3<T> & a_Rhs)
+ {
+ return Vector3<T>(
+ x / a_Rhs.x,
+ y / a_Rhs.y,
+ z / a_Rhs.z
+ );
+ }
+
inline Vector3<T> operator * (T a_v) const
{
return Vector3<T>(
@@ -345,6 +374,7 @@ protected:
+
template <> inline Vector3<int> Vector3<int>::Floor(void) const
{
return *this;