From 428cfb5c21ec5a35252b967eb306d6ba9b8e11b3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 29 Jun 2014 22:41:31 +0100 Subject: Suggestions --- src/Vector3.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/Vector3.h') diff --git a/src/Vector3.h b/src/Vector3.h index 5faac1457..762fdfd71 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -274,6 +274,14 @@ public: return (a_X - x) / (a_OtherEnd.x - x); } + /** Clamps each value in the vector to within a specified range */ + inline void Clamp(T a_MinX, T a_MinY, T a_MinZ, T a_MaxX, T a_MaxY, T a_MaxZ) + { + x = Clamp(x, (T)copysign(a_MinX, x), (T)copysign(a_MaxX, x)); + y = Clamp(y, (T)copysign(a_MinY, y), (T)copysign(a_MaxY, y)); + z = Clamp(z, (T)copysign(a_MinZ, z), (T)copysign(a_MaxZ, z)); + } + /** The max difference between two coords for which the coords are assumed equal. */ static const double EPS; @@ -288,6 +296,12 @@ protected: { return (a_Value < 0) ? -a_Value : a_Value; } + + /** Clamp X to the specified range. */ + T Clamp(T a_Value, T a_Min, T a_Max) + { + return (a_Value < a_Min) ? a_Min : ((a_Value > a_Max) ? a_Max : a_Value); + } }; // tolua_end -- cgit v1.2.3 From 85fae0e521d3a2ea4f083ee2bc54ac7fbb357768 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 30 Jun 2014 19:21:21 +0100 Subject: Implemented Vector3<>::Floor() --- src/Vector3.h | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/Vector3.h') diff --git a/src/Vector3.h b/src/Vector3.h index 762fdfd71..b5ddc705a 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -134,6 +134,22 @@ public: z += a_Diff.z; } + /** Runs each value of the vector through std::floor() */ + inline void Floor(void) + { + x = (T)floor(x); + y = (T)floor(y); + z = (T)floor(z); + } + + /** Clamps each value in the vector to within a specified range */ + inline void Clamp(T a_MinX, T a_MinY, T a_MinZ, T a_MaxX, T a_MaxY, T a_MaxZ) + { + x = Clamp(x, (T)copysign(a_MinX, x), (T)copysign(a_MaxX, x)); + y = Clamp(y, (T)copysign(a_MinY, y), (T)copysign(a_MaxY, y)); + z = Clamp(z, (T)copysign(a_MinZ, z), (T)copysign(a_MaxZ, z)); + } + // tolua_end inline bool operator != (const Vector3 & a_Rhs) const @@ -274,14 +290,6 @@ public: return (a_X - x) / (a_OtherEnd.x - x); } - /** Clamps each value in the vector to within a specified range */ - inline void Clamp(T a_MinX, T a_MinY, T a_MinZ, T a_MaxX, T a_MaxY, T a_MaxZ) - { - x = Clamp(x, (T)copysign(a_MinX, x), (T)copysign(a_MaxX, x)); - y = Clamp(y, (T)copysign(a_MinY, y), (T)copysign(a_MaxY, y)); - z = Clamp(z, (T)copysign(a_MinZ, z), (T)copysign(a_MaxZ, z)); - } - /** The max difference between two coords for which the coords are assumed equal. */ static const double EPS; -- cgit v1.2.3 From 284c1c0514168e30338f2ad372b7e7f185dba0c4 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 1 Jul 2014 22:39:37 +0100 Subject: Vector clamping fixes Thank you, @madmaxoft. --- src/Vector3.h | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'src/Vector3.h') diff --git a/src/Vector3.h b/src/Vector3.h index b5ddc705a..faf7fe43c 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -135,19 +135,13 @@ public: } /** Runs each value of the vector through std::floor() */ - inline void Floor(void) + inline Vector3 Floor(void) const { - x = (T)floor(x); - y = (T)floor(y); - z = (T)floor(z); - } - - /** Clamps each value in the vector to within a specified range */ - inline void Clamp(T a_MinX, T a_MinY, T a_MinZ, T a_MaxX, T a_MaxY, T a_MaxZ) - { - x = Clamp(x, (T)copysign(a_MinX, x), (T)copysign(a_MaxX, x)); - y = Clamp(y, (T)copysign(a_MinY, y), (T)copysign(a_MaxY, y)); - z = Clamp(z, (T)copysign(a_MinZ, z), (T)copysign(a_MaxZ, z)); + return Vector3( + (T)floor(x), + (T)floor(y), + (T)floor(z) + ); } // tolua_end @@ -162,6 +156,16 @@ public: return Equals(a_Rhs); } + inline bool operator > (const Vector3 & a_Rhs) const + { + return (SqrLength() > a_Rhs.SqrLength()); + } + + inline bool operator < (const Vector3 & a_Rhs) const + { + return (SqrLength() < a_Rhs.SqrLength()); + } + inline void operator += (const Vector3 & a_Rhs) { x += a_Rhs.x; @@ -305,11 +309,6 @@ protected: return (a_Value < 0) ? -a_Value : a_Value; } - /** Clamp X to the specified range. */ - T Clamp(T a_Value, T a_Min, T a_Max) - { - return (a_Value < a_Min) ? a_Min : ((a_Value > a_Max) ? a_Max : a_Value); - } }; // tolua_end -- cgit v1.2.3 From 79e558be349c40ed40b5eefefd29f563a570e404 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 4 Jul 2014 17:42:40 +0100 Subject: Suggestions --- src/Vector3.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/Vector3.h') diff --git a/src/Vector3.h b/src/Vector3.h index faf7fe43c..f350ede2a 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -135,12 +135,12 @@ public: } /** Runs each value of the vector through std::floor() */ - inline Vector3 Floor(void) const + inline Vector3 Floor(void) const { - return Vector3( - (T)floor(x), - (T)floor(y), - (T)floor(z) + return Vector3i( + (int)floor(x), + (int)floor(y), + (int)floor(z) ); } -- cgit v1.2.3 From 25e986220662247cfeefe4a496da959f409859e9 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 4 Jul 2014 17:49:44 +0100 Subject: Compile fix --- 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 f350ede2a..9e855b8af 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -137,7 +137,7 @@ public: /** Runs each value of the vector through std::floor() */ inline Vector3 Floor(void) const { - return Vector3i( + return Vector3( (int)floor(x), (int)floor(y), (int)floor(z) -- cgit v1.2.3 From ce670accc9740ad5f096658be9b0a39b4aabf0cc Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 10 Jul 2014 12:37:21 +0200 Subject: Fixed Vector3.h compilation in MSVC2008. --- src/Vector3.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/Vector3.h') diff --git a/src/Vector3.h b/src/Vector3.h index 9e855b8af..0a0968c59 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -316,6 +316,15 @@ protected: +template <> Vector3 Vector3::Floor(void) const +{ + return *this; +} + + + + + template const double Vector3::EPS = 0.000001; -- cgit v1.2.3 From db759891578c1cf4ce7f6d577b73fd1981ed502e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 10 Jul 2014 12:46:09 +0200 Subject: Fixed a missing "inline" keyword. --- 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 0a0968c59..c175bf135 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -316,7 +316,7 @@ protected: -template <> Vector3 Vector3::Floor(void) const +template <> inline Vector3 Vector3::Floor(void) const { return *this; } -- cgit v1.2.3 From 7fff12bfacbb4bef1c02cea0ec10fdc9a6fb64e4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 19:13:23 +0200 Subject: Fixed spaces around single-line comments. There should be at least two spaces in front and one space after //-style comments. --- 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 c175bf135..1dcb38f64 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -3,7 +3,7 @@ -#define _USE_MATH_DEFINES // Enable non-standard math defines (MSVC) +#define _USE_MATH_DEFINES // Enable non-standard math defines (MSVC) #include #include #include -- cgit v1.2.3