From 109a07fd95a001f296e67857f941e9cfeb8c46e7 Mon Sep 17 00:00:00 2001 From: LogicParrot Date: Thu, 21 Apr 2016 00:53:38 +0300 Subject: Updated vector hashing bit operations --- src/Vector3.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Vector3.h b/src/Vector3.h index c4b72fd57..19ab0b021 100644 --- a/src/Vector3.h +++ b/src/Vector3.h @@ -396,13 +396,11 @@ public: /** Provides a hash of a vector's contents */ size_t operator()(const Vector3 & a_Vector) const { - // Guaranteed to have no hash collisions for any 128x128x128 area - size_t Hash = 0; + // Guaranteed to have non repeating hashes for any 128x128x128 area + size_t Hash = static_cast(a_Vector.y); + Hash <<= 16; Hash ^= static_cast(a_Vector.x); - Hash <<= 8; - Hash ^= static_cast(a_Vector.y); - Hash <<= 8; - Hash ^= static_cast(a_Vector.z); + Hash ^= static_cast(a_Vector.z) << 8; return Hash; } }; -- cgit v1.2.3