From 8ac1f8ccdcb48e765fd942a917844b022f382a20 Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Sun, 12 Jan 2025 05:32:08 +0000 Subject: [PATCH] Rename UI `camera_entity` fields (#17243) # Objective The `camera_entity` field on the extracted uinode structs holds the render world entity that has the extracted camera components corresponding to the target camera world entity. It should be renamed so that it's clear it isn't the target camera world entity itself. ## Solution Rename the `camera_entity` field on each of the extracted UI item structs to `extracted_camera_entity`. --- crates/bevy_ui/src/render/box_shadow.rs | 11 ++++--- crates/bevy_ui/src/render/debug_overlay.rs | 4 +-- crates/bevy_ui/src/render/mod.rs | 33 +++++++++---------- .../src/render/ui_material_pipeline.rs | 10 +++--- .../src/render/ui_texture_slice_pipeline.rs | 12 +++---- 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/crates/bevy_ui/src/render/box_shadow.rs b/crates/bevy_ui/src/render/box_shadow.rs index 0d0aa7c9be..b2c968d275 100644 --- a/crates/bevy_ui/src/render/box_shadow.rs +++ b/crates/bevy_ui/src/render/box_shadow.rs @@ -219,7 +219,7 @@ pub struct ExtractedBoxShadow { pub transform: Mat4, pub bounds: Vec2, pub clip: Option, - pub camera_entity: Entity, + pub extracted_camera_entity: Entity, pub color: LinearRgba, pub radius: ResolvedBorderRadius, pub blur_radius: f32, @@ -259,7 +259,7 @@ pub fn extract_shadows( continue; }; - let Ok(render_entity) = mapping.get(camera_entity) else { + let Ok(extracted_camera_entity) = mapping.get(camera_entity) else { continue; }; @@ -326,7 +326,7 @@ pub fn extract_shadows( color: drop_shadow.color.into(), bounds: shadow_size + 6. * blur_radius, clip: clip.map(|clip| clip.clip), - camera_entity: render_entity, + extracted_camera_entity, radius, blur_radius, size: shadow_size, @@ -348,7 +348,8 @@ pub fn queue_shadows( ) { let draw_function = draw_functions.read().id::(); for (entity, extracted_shadow) in extracted_box_shadows.box_shadows.iter() { - let Ok((view_entity, view, shadow_samples)) = views.get(extracted_shadow.camera_entity) + let Ok((view_entity, view, shadow_samples)) = + views.get(extracted_shadow.extracted_camera_entity) else { continue; }; @@ -511,7 +512,7 @@ pub fn prepare_shadows( item.entity(), UiShadowsBatch { range: vertices_index..vertices_index + 6, - camera: box_shadow.camera_entity, + camera: box_shadow.extracted_camera_entity, }, )); diff --git a/crates/bevy_ui/src/render/debug_overlay.rs b/crates/bevy_ui/src/render/debug_overlay.rs index 328d8042b7..b4f7c0ac5d 100644 --- a/crates/bevy_ui/src/render/debug_overlay.rs +++ b/crates/bevy_ui/src/render/debug_overlay.rs @@ -86,7 +86,7 @@ pub fn extract_debug_overlay( continue; }; - let Ok(render_camera_entity) = mapping.get(camera_entity) else { + let Ok(extracted_camera_entity) = mapping.get(camera_entity) else { continue; }; @@ -105,7 +105,7 @@ pub fn extract_debug_overlay( .filter(|_| !debug_options.show_clipped) .map(|clip| clip.clip), image: AssetId::default(), - camera_entity: render_camera_entity, + extracted_camera_entity, item: ExtractedUiItem::Node { atlas_scaling: None, transform: transform.compute_matrix(), diff --git a/crates/bevy_ui/src/render/mod.rs b/crates/bevy_ui/src/render/mod.rs index c087254ab8..745213899e 100644 --- a/crates/bevy_ui/src/render/mod.rs +++ b/crates/bevy_ui/src/render/mod.rs @@ -193,10 +193,8 @@ pub struct ExtractedUiNode { pub rect: Rect, pub image: AssetId, pub clip: Option, - // Camera to render this UI node to. By the time it is extracted, - // it is defaulted to a single camera if only one exists. - // Nodes with ambiguous camera will be ignored. - pub camera_entity: Entity, + /// Render world entity of the extracted camera corresponding to this node's target camera. + pub extracted_camera_entity: Entity, pub item: ExtractedUiItem, pub main_entity: MainEntity, } @@ -273,7 +271,7 @@ pub fn extract_uinode_background_colors( continue; }; - let Ok(render_camera_entity) = mapping.get(camera_entity) else { + let Ok(extracted_camera_entity) = mapping.get(camera_entity) else { continue; }; @@ -293,7 +291,7 @@ pub fn extract_uinode_background_colors( }, clip: clip.map(|clip| clip.clip), image: AssetId::default(), - camera_entity: render_camera_entity, + extracted_camera_entity, item: ExtractedUiItem::Node { atlas_scaling: None, transform: transform.compute_matrix(), @@ -333,7 +331,7 @@ pub fn extract_uinode_images( continue; }; - let Ok(render_camera_entity) = mapping.get(camera_entity) else { + let Ok(extracted_camera_entity) = mapping.get(camera_entity) else { continue; }; @@ -383,7 +381,7 @@ pub fn extract_uinode_images( rect, clip: clip.map(|clip| clip.clip), image: image.image.id(), - camera_entity: render_camera_entity, + extracted_camera_entity, item: ExtractedUiItem::Node { atlas_scaling, transform: transform.compute_matrix(), @@ -439,7 +437,7 @@ pub fn extract_uinode_borders( continue; }; - let Ok(render_camera_entity) = mapping.get(camera_entity) else { + let Ok(extracted_camera_entity) = mapping.get(camera_entity) else { continue; }; @@ -463,7 +461,7 @@ pub fn extract_uinode_borders( }, image, clip: maybe_clip.map(|clip| clip.clip), - camera_entity: render_camera_entity, + extracted_camera_entity, item: ExtractedUiItem::Node { atlas_scaling: None, transform: global_transform.compute_matrix(), @@ -501,7 +499,7 @@ pub fn extract_uinode_borders( }, image, clip: parent_clip.map(|clip| clip.clip), - camera_entity: render_camera_entity, + extracted_camera_entity, item: ExtractedUiItem::Node { transform: global_transform.compute_matrix(), atlas_scaling: None, @@ -629,7 +627,7 @@ pub fn extract_text_sections( )>, >, text_styles: Extract>, - mapping: Extract>, + mapping: Extract>, ) { let mut start = 0; let mut end = 1; @@ -655,7 +653,7 @@ pub fn extract_text_sections( continue; } - let Ok(&render_camera_entity) = mapping.get(camera_entity) else { + let Ok(extracted_camera_entity) = mapping.get(camera_entity) else { continue; }; @@ -710,7 +708,7 @@ pub fn extract_text_sections( color, image: atlas_info.texture.id(), clip: clip.map(|clip| clip.clip), - camera_entity: render_camera_entity.id(), + extracted_camera_entity, rect, item: ExtractedUiItem::Glyphs { range: start..end }, main_entity: entity.into(), @@ -798,7 +796,8 @@ pub fn queue_uinodes( ) { let draw_function = draw_functions.read().id::(); for (entity, extracted_uinode) in extracted_uinodes.uinodes.iter() { - let Ok((view_entity, view, ui_anti_alias)) = views.get(extracted_uinode.camera_entity) + let Ok((view_entity, view, ui_anti_alias)) = + views.get(extracted_uinode.extracted_camera_entity) else { continue; }; @@ -892,7 +891,7 @@ pub fn prepare_uinodes( && extracted_uinode.image != AssetId::default() && batch_image_handle != extracted_uinode.image) || existing_batch.as_ref().map(|(_, b)| b.camera) - != Some(extracted_uinode.camera_entity) + != Some(extracted_uinode.extracted_camera_entity) { if let Some(gpu_image) = gpu_images.get(extracted_uinode.image) { batch_item_index = item_index; @@ -901,7 +900,7 @@ pub fn prepare_uinodes( let new_batch = UiBatch { range: vertices_index..vertices_index, image: extracted_uinode.image, - camera: extracted_uinode.camera_entity, + camera: extracted_uinode.extracted_camera_entity, }; batches.push((item.entity(), new_batch)); diff --git a/crates/bevy_ui/src/render/ui_material_pipeline.rs b/crates/bevy_ui/src/render/ui_material_pipeline.rs index b8e1a7564a..b5d93c1cc6 100644 --- a/crates/bevy_ui/src/render/ui_material_pipeline.rs +++ b/crates/bevy_ui/src/render/ui_material_pipeline.rs @@ -341,7 +341,7 @@ pub struct ExtractedUiMaterialNode { // Camera to render this UI node to. By the time it is extracted, // it is defaulted to a single camera if only one exists. // Nodes with ambiguous camera will be ignored. - pub camera_entity: Entity, + pub extracted_camera_entity: Entity, pub main_entity: MainEntity, } @@ -384,7 +384,7 @@ pub fn extract_ui_material_nodes( continue; }; - let Ok(camera_entity) = render_entity_lookup.get(camera_entity) else { + let Ok(extracted_camera_entity) = render_entity_lookup.get(camera_entity) else { continue; }; @@ -417,7 +417,7 @@ pub fn extract_ui_material_nodes( }, border, clip: clip.map(|clip| clip.clip), - camera_entity, + extracted_camera_entity, main_entity: entity.into(), }, ); @@ -622,11 +622,11 @@ pub fn queue_ui_material_nodes( let Some(material) = render_materials.get(extracted_uinode.material) else { continue; }; - let Ok(view) = views.get(extracted_uinode.camera_entity) else { + let Ok(view) = views.get(extracted_uinode.extracted_camera_entity) else { continue; }; let Some(transparent_phase) = - transparent_render_phases.get_mut(&extracted_uinode.camera_entity) + transparent_render_phases.get_mut(&extracted_uinode.extracted_camera_entity) else { continue; }; diff --git a/crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs b/crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs index f2d5eb243e..3d605a576e 100644 --- a/crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs +++ b/crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs @@ -230,7 +230,7 @@ pub struct ExtractedUiTextureSlice { pub atlas_rect: Option, pub image: AssetId, pub clip: Option, - pub camera_entity: Entity, + pub extracted_camera_entity: Entity, pub color: LinearRgba, pub image_scale_mode: SpriteImageMode, pub flip_x: bool, @@ -269,7 +269,7 @@ pub fn extract_ui_texture_slices( continue; }; - let Ok(camera_entity) = mapping.get(camera_entity) else { + let Ok(extracted_camera_entity) = mapping.get(camera_entity) else { continue; }; @@ -326,7 +326,7 @@ pub fn extract_ui_texture_slices( }, clip: clip.map(|clip| clip.clip), image: image.image.id(), - camera_entity, + extracted_camera_entity, image_scale_mode, atlas_rect, flip_x: image.flip_x, @@ -349,7 +349,7 @@ pub fn queue_ui_slices( ) { let draw_function = draw_functions.read().id::(); for (entity, extracted_slicer) in extracted_ui_slicers.slices.iter() { - let Ok((view_entity, view)) = views.get(extracted_slicer.camera_entity) else { + let Ok((view_entity, view)) = views.get(extracted_slicer.extracted_camera_entity) else { continue; }; @@ -435,7 +435,7 @@ pub fn prepare_ui_slices( && texture_slices.image != AssetId::default() && batch_image_handle != texture_slices.image) || existing_batch.as_ref().map(|(_, b)| b.camera) - != Some(texture_slices.camera_entity) + != Some(texture_slices.extracted_camera_entity) { if let Some(gpu_image) = gpu_images.get(texture_slices.image) { batch_item_index = item_index; @@ -445,7 +445,7 @@ pub fn prepare_ui_slices( let new_batch = UiTextureSlicerBatch { range: vertices_index..vertices_index, image: texture_slices.image, - camera: texture_slices.camera_entity, + camera: texture_slices.extracted_camera_entity, }; batches.push((item.entity(), new_batch));