Skip to content

Commit d76c782

Browse files
authored
Remove camera from UiBatch (#17663)
# Objective A `TransparentUI` phase's items all target the same camera so there is no need to store the current camera entity in `UiBatch` and ending the current `UiBatch` on camera changes is pointless as the camera doesn't change. ## Solution Remove the `camera` fields from `UiBatch`, `UiShadowsBatch` and `UiTextureSliceBatch`. Remove the camera changed check from `prepare_uinodes`. ## Testing The `multiple_windows` and `split_screen` examples both render UI elements to multiple cameras and can be used to test these changes. The UI material plugin already didn't store the camera entity per batch and worked fine without it.
1 parent 76e9bf9 commit d76c782

File tree

2 files changed

+0
-8
lines changed

2 files changed

+0
-8
lines changed

crates/bevy_ui/src/render/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,6 @@ pub(crate) const QUAD_INDICES: [usize; 6] = [0, 2, 3, 0, 1, 2];
936936
pub struct UiBatch {
937937
pub range: Range<u32>,
938938
pub image: AssetId<Image>,
939-
pub camera: Entity,
940939
}
941940

942941
/// The values here should match the values for the constants in `ui.wgsl`
@@ -1066,8 +1065,6 @@ pub fn prepare_uinodes(
10661065
|| (batch_image_handle != AssetId::default()
10671066
&& extracted_uinode.image != AssetId::default()
10681067
&& batch_image_handle != extracted_uinode.image)
1069-
|| existing_batch.as_ref().map(|(_, b)| b.camera)
1070-
!= Some(extracted_uinode.extracted_camera_entity)
10711068
{
10721069
if let Some(gpu_image) = gpu_images.get(extracted_uinode.image) {
10731070
batch_item_index = item_index;
@@ -1076,7 +1073,6 @@ pub fn prepare_uinodes(
10761073
let new_batch = UiBatch {
10771074
range: vertices_index..vertices_index,
10781075
image: extracted_uinode.image,
1079-
camera: extracted_uinode.extracted_camera_entity,
10801076
};
10811077

10821078
batches.push((item.entity(), new_batch));

crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ struct UiTextureSliceVertex {
8888
pub struct UiTextureSlicerBatch {
8989
pub range: Range<u32>,
9090
pub image: AssetId<Image>,
91-
pub camera: Entity,
9291
}
9392

9493
#[derive(Resource)]
@@ -446,8 +445,6 @@ pub fn prepare_ui_slices(
446445
|| (batch_image_handle != AssetId::default()
447446
&& texture_slices.image != AssetId::default()
448447
&& batch_image_handle != texture_slices.image)
449-
|| existing_batch.as_ref().map(|(_, b)| b.camera)
450-
!= Some(texture_slices.extracted_camera_entity)
451448
{
452449
if let Some(gpu_image) = gpu_images.get(texture_slices.image) {
453450
batch_item_index = item_index;
@@ -457,7 +454,6 @@ pub fn prepare_ui_slices(
457454
let new_batch = UiTextureSlicerBatch {
458455
range: vertices_index..vertices_index,
459456
image: texture_slices.image,
460-
camera: texture_slices.extracted_camera_entity,
461457
};
462458

463459
batches.push((item.entity(), new_batch));

0 commit comments

Comments
 (0)