bevy_ecs_tilemap icon indicating copy to clipboard operation
bevy_ecs_tilemap copied to clipboard

Let `TileStorage` iterator have items that are `Entity` rather than `Option<Entity>`.

Open bzm3r opened this issue 3 years ago • 3 comments

This works better in terms of the ergonomics, as the user only has to iterate over tiles that exist.

bzm3r avatar Sep 02 '22 17:09 bzm3r

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

StarArawn avatar Sep 02 '22 17:09 StarArawn

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.

Affinator avatar Sep 02 '22 18:09 Affinator

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.

StarArawn avatar Sep 02 '22 20:09 StarArawn