bevy_ecs_tilemap icon indicating copy to clipboard operation
bevy_ecs_tilemap copied to clipboard

Track changed Image assets and use them to update image caches.

Open andriyDev opened this issue 1 year ago • 15 comments

Previously, since the bind groups do not get updated every frame, modified image assets would not be rebound. This caused hot reloading to no longer work. Similarly, the TextureArrayCache (when not using atlas) would not invalidate modified assets, so the textures would become out-of-date.

Note there can be other reasons that an asset can be modified, so this should keep the assets more up-to-date in general.

Fixes #430.

andriyDev avatar May 22 '23 00:05 andriyDev

Rebased onto main to fix cargo clippy which was broken at HEAD at the time.

andriyDev avatar Jun 11 '23 17:06 andriyDev

Can it be merged to main? This commit fixes the issue with updating texture on a map.

gerasim13 avatar Jul 07 '23 16:07 gerasim13

I will rebase this once #440 goes through. I still need a review though for the overall structure of this solution.

andriyDev avatar Jul 16 '23 20:07 andriyDev

I've rebased this onto main after #440. I tested this with a little example and it still works.

andriyDev avatar Jul 22 '23 02:07 andriyDev

@StarArawn Is there anything I should change?

andriyDev avatar Jul 25 '23 02:07 andriyDev

@StarArawn can it be merged?

gerasim13 avatar Aug 19 '23 14:08 gerasim13

@rparrett can you review this for me?

StarArawn avatar Sep 23 '23 14:09 StarArawn

@andriyDev is it possible to use https://docs.rs/bevy/latest/bevy/render/render_asset/struct.ExtractedAssets.html instead of doing the manual collecting/extraction?

rparrett avatar Sep 23 '23 15:09 rparrett

It seems like the answer to the above is probably no.

Sorry, but I don't think I can provide a meaningful review. I don't think I'll be able to get up-to-speed on this area of bevy_ecs_tilemap / bevy any time soon.

But this does fix hot reloading for me and doesn't seem to cause other issues as far as I can tell.

rparrett avatar Sep 23 '23 16:09 rparrett

In theory I think I could extract the EventReader<AssetEvent<Image>> resource, then do the collection in a render system, but since we need the modified images in queue_material_tilemap_meshes and remove_modified_textures, we'd still need the ModifiedImageHandles resource. It's not clear to me that that would be worth it? But if that seems nicer, I can make that change!

andriyDev avatar Sep 23 '23 16:09 andriyDev

Looks like CI is just failing due to new let-else formatting in rust 1.72 in an unrelated file.

rparrett avatar Sep 23 '23 17:09 rparrett

What should I do in regards to https://github.com/StarArawn/bevy_ecs_tilemap/pull/431#issuecomment-1732363616 ? I'm happy to change it if that looks cleaner. They both look roughly the same to me.

andriyDev avatar Sep 23 '23 21:09 andriyDev

They both look roughly the same to me.

I agree. Seems fine as-is IMO.

rparrett avatar Sep 23 '23 21:09 rparrett

@andriyDev Can we get the conflicts fixed up so we can get this merged in? :+1:

StarArawn avatar Dec 17 '23 04:12 StarArawn

Alright I rebased onto main. I also used AssetIds in place of Handles, since AssetIds seem to be the more "canonical" identifier for assets. I tested this locally and it still works for hot reloading!

@StarArawn I think this is good to go :)

andriyDev avatar Dec 17 '23 22:12 andriyDev

Hey @andriyDev, could I bug you to update the branch again? It looks like a relatively straightforward rebase. We should be in a better position to try to get this merged now.

If not, I'd be happy to adopt the PR.

rparrett avatar Aug 01 '24 02:08 rparrett

Sorry for the ping, I've gone ahead and adopted this over here: #547

rparrett avatar Aug 01 '24 03:08 rparrett

Merged the adopted PR. Thanks @andriyDev.

rparrett avatar Aug 01 '24 13:08 rparrett