Skip to content

Commit 2cdad48

Browse files
villorcart
andauthored
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 <mcanders1@gmail.com>
1 parent c9a3f34 commit 2cdad48

File tree

1 file changed

+8
-7
lines changed
  • crates/bevy_ui/src/render

1 file changed

+8
-7
lines changed

crates/bevy_ui/src/render/mod.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ mod ui_material_pipeline;
55
pub mod ui_texture_slice_pipeline;
66

77
use crate::{
8-
BackgroundColor, BorderColor, CalculatedClip, ComputedNode, DefaultUiCamera, Display, Node,
9-
Outline, ResolvedBorderRadius, TargetCamera, UiAntiAlias, UiBoxShadowSamples, UiImage, UiScale,
8+
experimental::UiChildren, BackgroundColor, BorderColor, CalculatedClip, ComputedNode,
9+
DefaultUiCamera, Outline, ResolvedBorderRadius, TargetCamera, UiAntiAlias, UiBoxShadowSamples,
10+
UiImage, UiScale,
1011
};
1112
use bevy_app::prelude::*;
1213
use bevy_asset::{load_internal_asset, AssetEvent, AssetId, Assets, Handle};
@@ -16,7 +17,6 @@ use bevy_core_pipeline::core_3d::graph::{Core3d, Node3d};
1617
use bevy_core_pipeline::{core_2d::Camera2d, core_3d::Camera3d};
1718
use bevy_ecs::entity::{EntityHashMap, EntityHashSet};
1819
use bevy_ecs::prelude::*;
19-
use bevy_hierarchy::Parent;
2020
use bevy_math::{FloatOrd, Mat4, Rect, URect, UVec4, Vec2, Vec3, Vec3Swizzles, Vec4Swizzles};
2121
use bevy_render::render_phase::ViewSortedRenderPhases;
2222
use bevy_render::sync_world::MainEntity;
@@ -42,6 +42,7 @@ use bevy_render::{
4242
use bevy_sprite::TextureAtlasLayout;
4343
use bevy_sprite::{BorderRect, ImageScaleMode, SpriteAssetEvents, TextureAtlas};
4444

45+
use crate::{Display, Node};
4546
use bevy_text::{ComputedTextBlock, PositionedGlyph, TextColor, TextLayoutInfo};
4647
use bevy_transform::components::GlobalTransform;
4748
use bevy_utils::HashMap;
@@ -406,11 +407,11 @@ pub fn extract_uinode_borders(
406407
Option<&CalculatedClip>,
407408
Option<&TargetCamera>,
408409
AnyOf<(&BorderColor, &Outline)>,
409-
Option<&Parent>,
410410
)>,
411411
>,
412412
parent_clip_query: Extract<Query<&CalculatedClip>>,
413413
mapping: Extract<Query<RenderEntity>>,
414+
ui_children: UiChildren,
414415
) {
415416
let image = AssetId::<Image>::default();
416417

@@ -423,7 +424,6 @@ pub fn extract_uinode_borders(
423424
maybe_clip,
424425
maybe_camera,
425426
(maybe_border_color, maybe_outline),
426-
maybe_parent,
427427
) in &uinode_query
428428
{
429429
let Some(camera_entity) = maybe_camera
@@ -480,8 +480,9 @@ pub fn extract_uinode_borders(
480480
if let Some(outline) = maybe_outline.filter(|outline| !outline.color.is_fully_transparent())
481481
{
482482
let outline_size = computed_node.outlined_node_size();
483-
let parent_clip =
484-
maybe_parent.and_then(|parent| parent_clip_query.get(parent.get()).ok());
483+
let parent_clip = ui_children
484+
.get_parent(entity)
485+
.and_then(|parent| parent_clip_query.get(parent).ok());
485486

486487
extracted_uinodes.uinodes.insert(
487488
commands.spawn(TemporaryRenderEntity).id(),

0 commit comments

Comments
 (0)