Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions crates/bevy_ui/src/picking_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ pub fn ui_picking(
}

// The list of node entities hovered for each (camera, pointer) combo
let mut hit_nodes = HashMap::<(Entity, PointerId), Vec<(Entity, Vec2)>>::default();
let mut hit_nodes =
HashMap::<(Entity, PointerId), Vec<(Entity, Entity, Option<Pickable>, Vec2)>>::default();

// prepare an iterator that contains all the nodes that have the cursor in their rect,
// from the top node to the bottom one. this will also reset the interaction to `None`
Expand Down Expand Up @@ -210,6 +211,8 @@ pub fn ui_picking(
.or_default()
.push((
node_entity,
camera_entity,
node.pickable.cloned(),
node.transform.inverse().transform_point2(*cursor_position)
/ node.node.size(),
));
Expand All @@ -224,19 +227,13 @@ pub fn ui_picking(
let mut picks = Vec::new();
let mut depth = 0.0;

for (hovered_node, position) in hovered {
let node = node_query.get(*hovered_node).unwrap();

let Some(camera_entity) = node.target_camera.get() else {
continue;
};

for (hovered_node, camera_entity, pickable, position) in hovered {
picks.push((
node.entity,
HitData::new(camera_entity, depth, Some(position.extend(0.0)), None),
*hovered_node,
HitData::new(*camera_entity, depth, Some(position.extend(0.0)), None),
));

if let Some(pickable) = node.pickable {
if let Some(pickable) = pickable {
// If an entity has a `Pickable` component, we will use that as the source of truth.
if pickable.should_block_lower {
break;
Expand Down