diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-04-20 23:53:38 +0200 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-04-22 16:45:45 +0200 |
commit | 109a07fd95a001f296e67857f941e9cfeb8c46e7 (patch) | |
tree | 1f2081f5b7286b509644f6a2766235aa2041fbee /src/Vector3.h | |
parent | Merge pull request #3150 from LogicParrot/worldTweaks (diff) | |
download | cuberite-109a07fd95a001f296e67857f941e9cfeb8c46e7.tar cuberite-109a07fd95a001f296e67857f941e9cfeb8c46e7.tar.gz cuberite-109a07fd95a001f296e67857f941e9cfeb8c46e7.tar.bz2 cuberite-109a07fd95a001f296e67857f941e9cfeb8c46e7.tar.lz cuberite-109a07fd95a001f296e67857f941e9cfeb8c46e7.tar.xz cuberite-109a07fd95a001f296e67857f941e9cfeb8c46e7.tar.zst cuberite-109a07fd95a001f296e67857f941e9cfeb8c46e7.zip |
Diffstat (limited to 'src/Vector3.h')
-rw-r--r-- | src/Vector3.h | 10 |
1 files 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<What> & 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<size_t>(a_Vector.y); + Hash <<= 16; 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); + Hash ^= static_cast<size_t>(a_Vector.z) << 8; return Hash; } }; |