Skip to content

Commit

Permalink
Rename UI camera_entity fields (#17243)
Browse files Browse the repository at this point in the history
# 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`.
  • Loading branch information
ickshonpe authored Jan 12, 2025
1 parent 447108b commit 8ac1f8c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
11 changes: 6 additions & 5 deletions crates/bevy_ui/src/render/box_shadow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ pub struct ExtractedBoxShadow {
pub transform: Mat4,
pub bounds: Vec2,
pub clip: Option<Rect>,
pub camera_entity: Entity,
pub extracted_camera_entity: Entity,
pub color: LinearRgba,
pub radius: ResolvedBorderRadius,
pub blur_radius: f32,
Expand Down Expand Up @@ -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;
};

Expand Down Expand Up @@ -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,
Expand All @@ -348,7 +348,8 @@ pub fn queue_shadows(
) {
let draw_function = draw_functions.read().id::<DrawBoxShadows>();
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;
};
Expand Down Expand Up @@ -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,
},
));

Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ui/src/render/debug_overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand All @@ -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(),
Expand Down
33 changes: 16 additions & 17 deletions crates/bevy_ui/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,8 @@ pub struct ExtractedUiNode {
pub rect: Rect,
pub image: AssetId<Image>,
pub clip: Option<Rect>,
// 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,
}
Expand Down Expand Up @@ -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;
};

Expand All @@ -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(),
Expand Down Expand Up @@ -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;
};

Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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;
};

Expand All @@ -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(),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -629,7 +627,7 @@ pub fn extract_text_sections(
)>,
>,
text_styles: Extract<Query<&TextColor>>,
mapping: Extract<Query<&RenderEntity>>,
mapping: Extract<Query<RenderEntity>>,
) {
let mut start = 0;
let mut end = 1;
Expand All @@ -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;
};

Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -798,7 +796,8 @@ pub fn queue_uinodes(
) {
let draw_function = draw_functions.read().id::<DrawUi>();
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;
};
Expand Down Expand Up @@ -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;
Expand All @@ -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));
Expand Down
10 changes: 5 additions & 5 deletions crates/bevy_ui/src/render/ui_material_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ pub struct ExtractedUiMaterialNode<M: UiMaterial> {
// 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,
}

Expand Down Expand Up @@ -384,7 +384,7 @@ pub fn extract_ui_material_nodes<M: UiMaterial>(
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;
};

Expand Down Expand Up @@ -417,7 +417,7 @@ pub fn extract_ui_material_nodes<M: UiMaterial>(
},
border,
clip: clip.map(|clip| clip.clip),
camera_entity,
extracted_camera_entity,
main_entity: entity.into(),
},
);
Expand Down Expand Up @@ -622,11 +622,11 @@ pub fn queue_ui_material_nodes<M: UiMaterial>(
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;
};
Expand Down
12 changes: 6 additions & 6 deletions crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ pub struct ExtractedUiTextureSlice {
pub atlas_rect: Option<Rect>,
pub image: AssetId<Image>,
pub clip: Option<Rect>,
pub camera_entity: Entity,
pub extracted_camera_entity: Entity,
pub color: LinearRgba,
pub image_scale_mode: SpriteImageMode,
pub flip_x: bool,
Expand Down Expand Up @@ -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;
};

Expand Down Expand Up @@ -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,
Expand All @@ -349,7 +349,7 @@ pub fn queue_ui_slices(
) {
let draw_function = draw_functions.read().id::<DrawUiTextureSlices>();
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;
};

Expand Down Expand Up @@ -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;
Expand All @@ -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));
Expand Down

0 comments on commit 8ac1f8c

Please sign in to comment.