Added a Without<OverrideClip>
query filter to the picking systems' child_of_query
s.
Interactions were changed in the UI transform PR to walk up the tree recursively to check if the interaction hit a visible node. `OverrideClip` only affects the node's local clipping rect, so without this filter interactions can be incorrectly ignored if a node has clipped ancestors.
This commit is contained in:
parent
09ccedd244
commit
98a3b92c9a
@ -1,10 +1,12 @@
|
||||
use crate::{ui_transform::UiGlobalTransform, ComputedNode, ComputedNodeTarget, Node, UiStack};
|
||||
use crate::{
|
||||
ui_transform::UiGlobalTransform, ComputedNode, ComputedNodeTarget, Node, OverrideClip, UiStack,
|
||||
};
|
||||
use bevy_ecs::{
|
||||
change_detection::DetectChangesMut,
|
||||
entity::{ContainsEntity, Entity},
|
||||
hierarchy::ChildOf,
|
||||
prelude::{Component, With},
|
||||
query::QueryData,
|
||||
query::{Has, QueryData, Without},
|
||||
reflect::ReflectComponent,
|
||||
system::{Local, Query, Res},
|
||||
};
|
||||
@ -157,7 +159,7 @@ pub fn ui_focus_system(
|
||||
ui_stack: Res<UiStack>,
|
||||
mut node_query: Query<NodeQuery>,
|
||||
clipping_query: Query<(&ComputedNode, &UiGlobalTransform, &Node)>,
|
||||
child_of_query: Query<&ChildOf>,
|
||||
child_of_query: Query<&ChildOf, Without<OverrideClip>>,
|
||||
) {
|
||||
let primary_window = primary_window.iter().next();
|
||||
|
||||
@ -325,11 +327,12 @@ pub fn ui_focus_system(
|
||||
}
|
||||
|
||||
/// Walk up the tree child-to-parent checking that `point` is not clipped by any ancestor node.
|
||||
/// If `entity has an `OverrideClip` component it ignores any inherited clipping and returns true.
|
||||
pub fn clip_check_recursive(
|
||||
point: Vec2,
|
||||
entity: Entity,
|
||||
clipping_query: &Query<'_, '_, (&ComputedNode, &UiGlobalTransform, &Node)>,
|
||||
child_of_query: &Query<&ChildOf>,
|
||||
child_of_query: &Query<&ChildOf, Without<OverrideClip>>,
|
||||
) -> bool {
|
||||
if let Ok(child_of) = child_of_query.get(entity) {
|
||||
let parent = child_of.0;
|
||||
|
@ -109,7 +109,7 @@ pub fn ui_picking(
|
||||
node_query: Query<NodeQuery>,
|
||||
mut output: EventWriter<PointerHits>,
|
||||
clipping_query: Query<(&ComputedNode, &UiGlobalTransform, &Node)>,
|
||||
child_of_query: Query<&ChildOf>,
|
||||
child_of_query: Query<&ChildOf, Without<OverrideClip>>,
|
||||
) {
|
||||
// For each camera, the pointer and its position
|
||||
let mut pointer_pos_by_camera = HashMap::<Entity, HashMap<PointerId, Vec2>>::default();
|
||||
|
Loading…
Reference in New Issue
Block a user