bevy_ecs_tilemap
bevy_ecs_tilemap copied to clipboard
Let `TileStorage` iterator have items that are `Entity` rather than `Option<Entity>`.
This works better in terms of the ergonomics, as the user only has to iterate over tiles that exist.
Part of the issue here that is sparse tilemaps require Option or a HashMap but the HashMap's random access is slow. Maybe something like this could be used:
https://crates.io/crates/sparsevec
I did some quick benchmarking with HashMap Tilemaps with different filling grades of the Tilemaps. I could not really find a big performance difference. The overhead of the HashMap easily compensates the wins in iterating. But more thorough benchmarks may be necessary. I think if one iterates very often over the tiles there may be some gains possible.
Edit: I also tested SparseVec with the same results.
I did some quick benchmarking with HashMap Tilemaps with different filling grades of the Tilemaps. I could not really find a big performance difference. The overhead of the HashMap easily compensates the wins in iterating. But more thorough benchmarks may be necessary. I think if one iterates very often over the tiles there may be some gains possible.
Edit: I also tested SparseVec with the same results.
I mainly found issues when dealing with very massive tile maps, but yeah we should maybe benchmark and see what kind of performance we can get. I think if we upscaled the accessing_tiles example to have say a 100k tiles it might be a good refection on how well it performs across different tile storages mediums.