SOFTLEASH / DOCUMENTATION
Spatial Hash
Divide space into cells to make nearby-object queries easier to reason about.
A working outline. The snippets below use plain LÖVE and Lua, not the final SoftLEASH API.
Overview
A spatial hash groups objects into a grid of cells. Instead of checking every object against every other object, a system can first inspect the cells close to the query.
Use this outline for cell sizing, insertion, movement, and region queries. Add a diagram showing which cells are visited for a particular lookup.
LÖVE example
A small, plain LÖVE example for the draft. Replace this snippet with the documented SoftLEASH API and a focused use case later.
What to document next
Choosing a useful cell size.
Keeping moving objects in the correct cells.
Point, rectangle, and neighboring-cell queries.
