From 797e3130d2ae721688b53dbaa2831d441ba0138a Mon Sep 17 00:00:00 2001 From: Woazboat Date: Tue, 28 Apr 2015 02:47:36 +0200 Subject: Check for zero length vector in Trace Added hasNonZeroLength member function to Vector3 --- src/Vector3.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/Vector3.h') diff --git a/src/Vector3.h b/src/Vector3.h index 36f277ba4..f1fb2d257 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -78,6 +78,11 @@ public: ); } + inline bool hasNonZeroLength(void) const + { + return ((x != 0) || (y != 0) || (z != 0)); + } + inline double Length(void) const { return sqrt(static_cast(x * x + y * y + z * z)); -- cgit v1.2.3 From 2f264dba7168f0e3519b3b53148442001642e309 Mon Sep 17 00:00:00 2001 From: Woazboat Date: Tue, 28 Apr 2015 02:54:45 +0200 Subject: Changed Vector3 Equals function to avoid using memcmp --- src/Vector3.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/Vector3.h') diff --git a/src/Vector3.h b/src/Vector3.h index f1fb2d257..ede6cc851 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -126,11 +126,7 @@ public: { // Perform a bitwise 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) - ); + return !((x != a_Rhs.x) || (y != a_Rhs.y) || (z != a_Rhs.z)); } inline bool EqualsEps(const Vector3 & a_Rhs, T a_Eps) const -- cgit v1.2.3 From 2359fc67055cadd369f6c52805778531efd47ecd Mon Sep 17 00:00:00 2001 From: Woazboat Date: Wed, 29 Apr 2015 00:27:15 +0200 Subject: Fix HasNonZeroLength name now 100% more cs compliant --- src/Vector3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Vector3.h') diff --git a/src/Vector3.h b/src/Vector3.h index ede6cc851..6164721da 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -78,7 +78,7 @@ public: ); } - inline bool hasNonZeroLength(void) const + inline bool HasNonZeroLength(void) const { return ((x != 0) || (y != 0) || (z != 0)); } -- cgit v1.2.3