summaryrefslogtreecommitdiffstats
path: root/src/Vector3.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Vector3.h28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/Vector3.h b/src/Vector3.h
index 279fe5cd7..168071469 100644
--- a/src/Vector3.h
+++ b/src/Vector3.h
@@ -235,12 +235,6 @@ public:
return *this;
}
- /** Provides a hash of a vector's contents */
- size_t operator()(const Vector3<T> & a_Vector) const
- {
- return ((std::hash<T>()(a_Vector.x) ^ (std::hash<T>()(a_Vector.y) << 1)) ^ std::hash<T>()(a_Vector.z));
- }
-
// tolua_begin
inline Vector3<T> operator + (const Vector3<T>& a_Rhs) const
@@ -390,6 +384,28 @@ template <> inline Vector3<int> Vector3<int>::Floor(void) const
+template <typename What>
+class VectorHasher
+{
+public:
+ /** Provides a hash of a vector's contents */
+ size_t operator()(const Vector3<What> & a_Vector) const
+ {
+ // Guaranteed to have no hash collisions for any 128x128x128 area
+ size_t Hash = 0;
+ Hash ^= static_cast<size_t>(a_Vector.x);
+ Hash <<= 8;
+ Hash ^= static_cast<size_t>(a_Vector.y);
+ Hash <<= 8;
+ Hash ^= static_cast<size_t>(a_Vector.z);
+ return Hash;
+ }
+};
+
+
+
+
+
template <typename T>
const double Vector3<T>::EPS = 0.000001;