Update the UI texture slice pipeline to work with the retained render world changes (#15578)

# Objective

Update the UI's texture slice extraction to work with the changes from
the retained render world PR (#15320).
This commit is contained in:
ickshonpe 2024-10-01 23:02:02 +01:00 committed by GitHub
parent 54006b107b
commit f53af2846c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -18,6 +18,7 @@ use bevy_render::{
renderer::{RenderDevice, RenderQueue},
texture::{BevyDefault, GpuImage, Image, TRANSPARENT_IMAGE_HANDLE},
view::*,
world_sync::{RenderEntity, TemporaryRenderEntity},
Extract, ExtractSchedule, Render, RenderSet,
};
use bevy_sprite::{
@ -258,6 +259,7 @@ pub fn extract_ui_texture_slices(
Option<&TextureAtlas>,
)>,
>,
mapping: Extract<Query<&RenderEntity>>,
) {
for (uinode, transform, view_visibility, clip, camera, image, image_scale_mode, atlas) in
&slicers_query
@ -267,6 +269,10 @@ pub fn extract_ui_texture_slices(
continue;
};
let Ok(&camera_entity) = mapping.get(camera_entity) else {
continue;
};
// Skip invisible images
if !view_visibility.get()
|| image.color.is_fully_transparent()
@ -291,7 +297,7 @@ pub fn extract_ui_texture_slices(
};
extracted_ui_slicers.slices.insert(
commands.spawn_empty().id(),
commands.spawn(TemporaryRenderEntity).id(),
ExtractedUiTextureSlice {
stack_index: uinode.stack_index,
transform: transform.compute_matrix(),
@ -302,7 +308,7 @@ pub fn extract_ui_texture_slices(
},
clip: clip.map(|clip| clip.clip),
image: image.texture.id(),
camera_entity,
camera_entity: camera_entity.id(),
image_scale_mode: image_scale_mode.clone(),
atlas_rect,
flip_x: image.flip_x,