Skip to content

Commit fe7f98f

Browse files
rafalhakimakinai
andauthored
Fix deactivated camera still being used in render world (#15946)
# Objective Switch to retained render world causes the extracted cameras in render world to not be removed until camera in main world is despawned. When extracting data from main world inactive cameras are skipped. Therefore camera that was active and became inactive has a retained `ExtractedCamera` component from previous frames (when it was active) and is processed the same way as if it were active (there is no `active` field on `ExtractedCamera`). This breakes switching between cameras in `render_primitives` example. Fixes #15822 ## Solution Fix it by removing `ExtractedCamera` and related components from inactive cameras. Note that despawning inactive camera seems to be bad option because they are spawned using `SyncToRenderWorld` component. ## Testing Switching camera in `render_primitives` example now works correctly. --------- Co-authored-by: akimakinai <[email protected]>
1 parent d15d901 commit fe7f98f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

crates/bevy_render/src/camera/camera.rs

+10
Original file line numberDiff line numberDiff line change
@@ -1054,8 +1054,18 @@ pub fn extract_cameras(
10541054
) in query.iter()
10551055
{
10561056
if !camera.is_active {
1057+
commands.entity(render_entity).remove::<(
1058+
ExtractedCamera,
1059+
ExtractedView,
1060+
RenderVisibleEntities,
1061+
TemporalJitter,
1062+
RenderLayers,
1063+
Projection,
1064+
GpuCulling,
1065+
)>();
10571066
continue;
10581067
}
1068+
10591069
let color_grading = color_grading.unwrap_or(&ColorGrading::default()).clone();
10601070

10611071
if let (

0 commit comments

Comments
 (0)