1
0

Updated vector hashing bit operations

This commit is contained in:
LogicParrot 2016-04-21 00:53:38 +03:00
parent 4348b2f5a4
commit 109a07fd95

View File

@ -396,13 +396,11 @@ public:
/** Provides a hash of a vector's contents */ /** Provides a hash of a vector's contents */
size_t operator()(const Vector3<What> & a_Vector) const size_t operator()(const Vector3<What> & a_Vector) const
{ {
// Guaranteed to have no hash collisions for any 128x128x128 area // Guaranteed to have non repeating hashes for any 128x128x128 area
size_t Hash = 0; size_t Hash = static_cast<size_t>(a_Vector.y);
Hash <<= 16;
Hash ^= static_cast<size_t>(a_Vector.x); Hash ^= static_cast<size_t>(a_Vector.x);
Hash <<= 8; Hash ^= static_cast<size_t>(a_Vector.z) << 8;
Hash ^= static_cast<size_t>(a_Vector.y);
Hash <<= 8;
Hash ^= static_cast<size_t>(a_Vector.z);
return Hash; return Hash;
} }
}; };