Skip to content

Commit

Permalink
Get rid of unnecessary mutable access in ui picking backend (#15630)
Browse files Browse the repository at this point in the history
## Solution

Yeet

## Testing

Tested the `simple_picking` example
  • Loading branch information
tim-blackbird authored Oct 3, 2024
1 parent 8bf5d99 commit 20dbf79
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions crates/bevy_ui/src/picking_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub fn ui_picking(
primary_window: Query<Entity, With<PrimaryWindow>>,
ui_scale: Res<UiScale>,
ui_stack: Res<UiStack>,
mut node_query: Query<NodeQuery>,
node_query: Query<NodeQuery>,
mut output: EventWriter<PointerHits>,
) {
// For each camera, the pointer and its position
Expand Down Expand Up @@ -119,7 +119,7 @@ pub fn ui_picking(
// reverse the iterator to traverse the tree from closest nodes to furthest
.rev()
{
let Ok(node) = node_query.get_mut(*node_entity) else {
let Ok(node) = node_query.get(*node_entity) else {
continue;
};

Expand Down Expand Up @@ -183,11 +183,10 @@ pub fn ui_picking(
for ((camera, pointer), hovered_nodes) in hit_nodes.iter() {
// As soon as a node with a `Block` focus policy is detected, the iteration will stop on it
// because it "captures" the interaction.
let mut iter = node_query.iter_many_mut(hovered_nodes.iter());
let mut picks = Vec::new();
let mut depth = 0.0;

while let Some(node) = iter.fetch_next() {
for node in node_query.iter_many(hovered_nodes) {
let Some(camera_entity) = node
.target_camera
.map(TargetCamera::entity)
Expand Down

0 comments on commit 20dbf79

Please sign in to comment.