Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename UI camera_entity fields #17243

Merged
merged 3 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(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_shadows(
color: drop_shadow.color.into(),
bounds: shadow_size + 6. * blur_radius,
clip: clip.map(|clip| clip.clip),
camera_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 @@ -512,7 +513,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 @@ -87,7 +87,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 @@ -106,7 +106,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 @@ -274,7 +272,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 @@ -294,7 +292,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 @@ -335,7 +333,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 @@ -385,7 +383,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 @@ -441,7 +439,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 @@ -465,7 +463,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 @@ -503,7 +501,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 @@ -631,7 +629,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 @@ -657,7 +655,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 @@ -712,7 +710,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 @@ -801,7 +799,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 @@ -896,7 +895,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 @@ -905,7 +904,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 @@ -624,11 +624,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 @@ -436,7 +436,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 @@ -446,7 +446,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
Loading