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:
		
							parent
							
								
									c9a3f34f5d
								
							
						
					
					
						commit
						2cdad48b30
					
				| @ -5,8 +5,9 @@ mod ui_material_pipeline; | |||||||
| pub mod ui_texture_slice_pipeline; | pub mod ui_texture_slice_pipeline; | ||||||
| 
 | 
 | ||||||
| use crate::{ | use crate::{ | ||||||
|     BackgroundColor, BorderColor, CalculatedClip, ComputedNode, DefaultUiCamera, Display, Node, |     experimental::UiChildren, BackgroundColor, BorderColor, CalculatedClip, ComputedNode, | ||||||
|     Outline, ResolvedBorderRadius, TargetCamera, UiAntiAlias, UiBoxShadowSamples, UiImage, UiScale, |     DefaultUiCamera, Outline, ResolvedBorderRadius, TargetCamera, UiAntiAlias, UiBoxShadowSamples, | ||||||
|  |     UiImage, UiScale, | ||||||
| }; | }; | ||||||
| use bevy_app::prelude::*; | use bevy_app::prelude::*; | ||||||
| use bevy_asset::{load_internal_asset, AssetEvent, AssetId, Assets, Handle}; | 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_core_pipeline::{core_2d::Camera2d, core_3d::Camera3d}; | ||||||
| use bevy_ecs::entity::{EntityHashMap, EntityHashSet}; | use bevy_ecs::entity::{EntityHashMap, EntityHashSet}; | ||||||
| use bevy_ecs::prelude::*; | use bevy_ecs::prelude::*; | ||||||
| use bevy_hierarchy::Parent; |  | ||||||
| use bevy_math::{FloatOrd, Mat4, Rect, URect, UVec4, Vec2, Vec3, Vec3Swizzles, Vec4Swizzles}; | use bevy_math::{FloatOrd, Mat4, Rect, URect, UVec4, Vec2, Vec3, Vec3Swizzles, Vec4Swizzles}; | ||||||
| use bevy_render::render_phase::ViewSortedRenderPhases; | use bevy_render::render_phase::ViewSortedRenderPhases; | ||||||
| use bevy_render::sync_world::MainEntity; | use bevy_render::sync_world::MainEntity; | ||||||
| @ -42,6 +42,7 @@ use bevy_render::{ | |||||||
| use bevy_sprite::TextureAtlasLayout; | use bevy_sprite::TextureAtlasLayout; | ||||||
| use bevy_sprite::{BorderRect, ImageScaleMode, SpriteAssetEvents, TextureAtlas}; | use bevy_sprite::{BorderRect, ImageScaleMode, SpriteAssetEvents, TextureAtlas}; | ||||||
| 
 | 
 | ||||||
|  | use crate::{Display, Node}; | ||||||
| use bevy_text::{ComputedTextBlock, PositionedGlyph, TextColor, TextLayoutInfo}; | use bevy_text::{ComputedTextBlock, PositionedGlyph, TextColor, TextLayoutInfo}; | ||||||
| use bevy_transform::components::GlobalTransform; | use bevy_transform::components::GlobalTransform; | ||||||
| use bevy_utils::HashMap; | use bevy_utils::HashMap; | ||||||
| @ -406,11 +407,11 @@ pub fn extract_uinode_borders( | |||||||
|             Option<&CalculatedClip>, |             Option<&CalculatedClip>, | ||||||
|             Option<&TargetCamera>, |             Option<&TargetCamera>, | ||||||
|             AnyOf<(&BorderColor, &Outline)>, |             AnyOf<(&BorderColor, &Outline)>, | ||||||
|             Option<&Parent>, |  | ||||||
|         )>, |         )>, | ||||||
|     >, |     >, | ||||||
|     parent_clip_query: Extract<Query<&CalculatedClip>>, |     parent_clip_query: Extract<Query<&CalculatedClip>>, | ||||||
|     mapping: Extract<Query<RenderEntity>>, |     mapping: Extract<Query<RenderEntity>>, | ||||||
|  |     ui_children: UiChildren, | ||||||
| ) { | ) { | ||||||
|     let image = AssetId::<Image>::default(); |     let image = AssetId::<Image>::default(); | ||||||
| 
 | 
 | ||||||
| @ -423,7 +424,6 @@ pub fn extract_uinode_borders( | |||||||
|         maybe_clip, |         maybe_clip, | ||||||
|         maybe_camera, |         maybe_camera, | ||||||
|         (maybe_border_color, maybe_outline), |         (maybe_border_color, maybe_outline), | ||||||
|         maybe_parent, |  | ||||||
|     ) in &uinode_query |     ) in &uinode_query | ||||||
|     { |     { | ||||||
|         let Some(camera_entity) = maybe_camera |         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()) |         if let Some(outline) = maybe_outline.filter(|outline| !outline.color.is_fully_transparent()) | ||||||
|         { |         { | ||||||
|             let outline_size = computed_node.outlined_node_size(); |             let outline_size = computed_node.outlined_node_size(); | ||||||
|             let parent_clip = |             let parent_clip = ui_children | ||||||
|                 maybe_parent.and_then(|parent| parent_clip_query.get(parent.get()).ok()); |                 .get_parent(entity) | ||||||
|  |                 .and_then(|parent| parent_clip_query.get(parent).ok()); | ||||||
| 
 | 
 | ||||||
|             extracted_uinodes.uinodes.insert( |             extracted_uinodes.uinodes.insert( | ||||||
|                 commands.spawn(TemporaryRenderEntity).id(), |                 commands.spawn(TemporaryRenderEntity).id(), | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Viktor Gustavsson
						Viktor Gustavsson