From 2cdad48b306935ea156ca51b2dcbab0cf041a718 Mon Sep 17 00:00:00 2001 From: Viktor Gustavsson Date: Wed, 23 Oct 2024 23:51:39 +0200 Subject: [PATCH] Ensure ghost nodes are skipped when getting parent clipping rect (#16058) # Objective - Follow up on #16044 - `extract_uinode_borders` uses `bevy_hierarchy` directly instead of going through the traversal utilities, meaning it won't handle `GhostNode`s properly. ## Solution - Replaced the use of `bevy_hierarchy::Parent` with `UIChildren::get_parent` ## Testing - Ran the `overflow` example, clipping looks ok. --- --------- Co-authored-by: Carter Anderson --- crates/bevy_ui/src/render/mod.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/crates/bevy_ui/src/render/mod.rs b/crates/bevy_ui/src/render/mod.rs index e3663f92c7..5ab1f62cf1 100644 --- a/crates/bevy_ui/src/render/mod.rs +++ b/crates/bevy_ui/src/render/mod.rs @@ -5,8 +5,9 @@ mod ui_material_pipeline; pub mod ui_texture_slice_pipeline; use crate::{ - BackgroundColor, BorderColor, CalculatedClip, ComputedNode, DefaultUiCamera, Display, Node, - Outline, ResolvedBorderRadius, TargetCamera, UiAntiAlias, UiBoxShadowSamples, UiImage, UiScale, + experimental::UiChildren, BackgroundColor, BorderColor, CalculatedClip, ComputedNode, + DefaultUiCamera, Outline, ResolvedBorderRadius, TargetCamera, UiAntiAlias, UiBoxShadowSamples, + UiImage, UiScale, }; use bevy_app::prelude::*; use bevy_asset::{load_internal_asset, AssetEvent, AssetId, Assets, Handle}; @@ -16,7 +17,6 @@ use bevy_core_pipeline::core_3d::graph::{Core3d, Node3d}; use bevy_core_pipeline::{core_2d::Camera2d, core_3d::Camera3d}; use bevy_ecs::entity::{EntityHashMap, EntityHashSet}; use bevy_ecs::prelude::*; -use bevy_hierarchy::Parent; use bevy_math::{FloatOrd, Mat4, Rect, URect, UVec4, Vec2, Vec3, Vec3Swizzles, Vec4Swizzles}; use bevy_render::render_phase::ViewSortedRenderPhases; use bevy_render::sync_world::MainEntity; @@ -42,6 +42,7 @@ use bevy_render::{ use bevy_sprite::TextureAtlasLayout; use bevy_sprite::{BorderRect, ImageScaleMode, SpriteAssetEvents, TextureAtlas}; +use crate::{Display, Node}; use bevy_text::{ComputedTextBlock, PositionedGlyph, TextColor, TextLayoutInfo}; use bevy_transform::components::GlobalTransform; use bevy_utils::HashMap; @@ -406,11 +407,11 @@ pub fn extract_uinode_borders( Option<&CalculatedClip>, Option<&TargetCamera>, AnyOf<(&BorderColor, &Outline)>, - Option<&Parent>, )>, >, parent_clip_query: Extract>, mapping: Extract>, + ui_children: UiChildren, ) { let image = AssetId::::default(); @@ -423,7 +424,6 @@ pub fn extract_uinode_borders( maybe_clip, maybe_camera, (maybe_border_color, maybe_outline), - maybe_parent, ) in &uinode_query { let Some(camera_entity) = maybe_camera @@ -480,8 +480,9 @@ pub fn extract_uinode_borders( if let Some(outline) = maybe_outline.filter(|outline| !outline.color.is_fully_transparent()) { let outline_size = computed_node.outlined_node_size(); - let parent_clip = - maybe_parent.and_then(|parent| parent_clip_query.get(parent.get()).ok()); + let parent_clip = ui_children + .get_parent(entity) + .and_then(|parent| parent_clip_query.get(parent).ok()); extracted_uinodes.uinodes.insert( commands.spawn(TemporaryRenderEntity).id(),