Trouv / bevy_ecs_ldtk

ECS-friendly ldtk plugin for bevy, leveraging bevy_ecs_tilemap
Other
641 stars 73 forks source link

Cache white-image for entire asset #172

Closed Trouv closed 1 year ago

Trouv commented 1 year ago

We had to create a white image for every level to support background colors and intgrid colors. The size of this image was previously kind of difficult to determine due to every level needing a minimum-sized image to encompass the entire level. The temporary solution was to just generate one for every level. This isn't ideal - it's a bit of wasted memory to store this many assets, especially when levels can get pretty big.

However, as of #171, we no longer need this white image for background layers, only intgrid colors. This means that the size of the image we need is just the maximum-sized intgrid layer in the asset. This is much easier to determine and create an image for early. I think we should create such an image as early as possible, maybe during asset loading (storing the handle on LdtkAsset).