Locus is a Two-dimensional, unbounded, sparse, efficient, grid spatial hash for Pico-8.
by kikito


The library uses a grid of squared cells and keeps track of which objects "touch" each cell.
This is useful in several scenarios:
- It can tell "Which objects are in a given rectangular section" quite efficiently
- This is useful for collision detection; instead of checking n-to-n interactions, locus can be used to restrict the amount of objects to be checked, sometimes dramatically reducing the number of checks.
- Given that the query area is rectangular, locus can be used to optimize the draw stage, by "only rendering objects that intersect with the screen"
More Info about the API, FAQ and so on @ github:
https://github.com/kikito/locus.p8
The cart above shows the main features of locus:
- Addition and updating of objects in locus
- Querying locus for updating objects
- Querying locus for drawing objects on the screen
It does not show deletion or filtering, but hopefully the docs on github clarify how to do that.
Feedback most welcome!
[Please log in to post a comment]