summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2016-04-22 17:39:56 +0200
committerLogicParrot <LogicParrot@users.noreply.github.com>2016-04-22 17:39:56 +0200
commitdeacd253707cc8b4c27aa10869acd60ee929c424 (patch)
tree1f2081f5b7286b509644f6a2766235aa2041fbee /src
parentMerge pull request #3150 from LogicParrot/worldTweaks (diff)
parentUpdated vector hashing bit operations (diff)
downloadcuberite-deacd253707cc8b4c27aa10869acd60ee929c424.tar
cuberite-deacd253707cc8b4c27aa10869acd60ee929c424.tar.gz
cuberite-deacd253707cc8b4c27aa10869acd60ee929c424.tar.bz2
cuberite-deacd253707cc8b4c27aa10869acd60ee929c424.tar.lz
cuberite-deacd253707cc8b4c27aa10869acd60ee929c424.tar.xz
cuberite-deacd253707cc8b4c27aa10869acd60ee929c424.tar.zst
cuberite-deacd253707cc8b4c27aa10869acd60ee929c424.zip
Diffstat (limited to 'src')
-rw-r--r--src/Vector3.h10
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;
}
};