From 782f1863b962b663300e4bf4e8a949f1bd5dd13e Mon Sep 17 00:00:00 2001 From: Torstein Grindvik <52322338+torsteingrindvik@users.noreply.github.com> Date: Wed, 15 Nov 2023 13:44:21 +0100 Subject: [PATCH] Make sure added image assets are checked in camera_system (#10556) # Objective Make sure a camera which has had its render target changed recomputes its info. On main, the following is possible: - System A has an inactive camera with render target set to the default `Image` (i.e. white 1x1 rgba texture) Later: - System B sets the same camera active and sets the `camera.target` to a newly created `Image` **Bug**: Since `camera_system` only checks `Modified` and not `Added` events, the size of the render target is not recomputed, which means the camera will render with 1x1 size even though the new target is an entirely different size. ## Solution - Ensure `camera_system` checks `Added` image assets events ## Changelog ### Fixed - Cameras which have their render targets changed to a newly created target with a different size than the previous target will now render properly --------- Signed-off-by: Torstein Grindvik Co-authored-by: Torstein Grindvik Co-authored-by: Afonso Lage --- crates/bevy_render/src/camera/camera.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/crates/bevy_render/src/camera/camera.rs b/crates/bevy_render/src/camera/camera.rs index be6349689b7cb..14f9ae72511fa 100644 --- a/crates/bevy_render/src/camera/camera.rs +++ b/crates/bevy_render/src/camera/camera.rs @@ -582,12 +582,9 @@ pub fn camera_system( let changed_image_handles: HashSet<&AssetId> = image_asset_events .read() - .filter_map(|event| { - if let AssetEvent::Modified { id } = event { - Some(id) - } else { - None - } + .filter_map(|event| match event { + AssetEvent::Modified { id } | AssetEvent::Added { id } => Some(id), + _ => None, }) .collect();