Keyslam / Inky

A GUI Framework for LÖVE
MIT License
48 stars 4 forks source link

Performance improvement: Spatial hash #3

Closed Keyslam closed 1 year ago

Keyslam commented 1 year ago

By using the same mechanic as the lifetime hooks (#2), and keeping track of when an element moves, it's possible to add and remove an element from a spatial hash. This can make overlap checks significantly faster. UI doesn't tend to change a whole lot every frame, so the performance benefit will probably outweigh the cost of maintaining a spatial hash for complex UI's. For simple UI's it is not necessary.

I propose using a spatial hash is opt-in per scene:

scene:useSpatialhash(boolean)
Keyslam commented 1 year ago

Resolved by https://github.com/Keyslam/Inky/commit/c09e7191008cb7542f3540c995176cff09f48ec3