A simple, lightweight spatial hash for Lua.
Creates a new spatial hash; if cellsize
is not specified a default value of
64
is used.
Adds an object with the given bounding box to the spatial hash.
Updates the object's bounding box.
Removes the object from the spatial hash.
Removes all objects from the spatial hash.
For each object which overlaps with the given bounding box or object, the
function fn
is called. The first argument passed to fn
is the overlapping
object, followed by any additional arguments passed to each()
.
Returns information about the spatial hash which can be useful for debugging. Available options and their arguments are as follows:
Opt | Args | Description |
---|---|---|
entities |
Returns the total number of entities | |
cells |
Returns the total number of cells | |
cell |
x , y |
Returns the number of entities in the cell |
This library is free software; you can redistribute it and/or modify it under the terms of the MIT license. See LICENSE for details.