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

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

Merged
Merged
Changes from all 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
10 changes: 8 additions & 2 deletions crates/bevy_ui/src/render/ui_texture_slice_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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(),
Expand All @@ -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,
Expand Down