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>
This commit is contained in:
Viktor Gustavsson 2024-10-23 23:51:39 +02:00 committed by GitHub
parent c9a3f34f5d
commit 2cdad48b30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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<Query<&CalculatedClip>>,
mapping: Extract<Query<RenderEntity>>,
ui_children: UiChildren,
) {
let image = AssetId::<Image>::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(),