Spatial Hashing.

Started by
10 comments, last by swiftcoder 6 years, 10 months ago

Much like a normal hash map, there's no particular requirement that a bucket in a spatial hash represent exactly one location in the world. It is required that nearby objects hash to the same bucket, but not that all objects in the same bucket are nearby to one another.

You can trivially define the buckets to repeat across the world (i.e. by adding a modulo to your hash function), and then when checking for nearby objects, you first find the matching bucket, and then check the actual distance of each object in the bucket.

This matches the behaviour of a normal hash map a little more closely, and removes the need for arbitrarily large cells, or other complicated datastructures.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

This topic is closed to new replies.

Advertisement