Skip to content

Commit

Permalink
Fix touch missing pointers (#319)
Browse files Browse the repository at this point in the history
* Add unique text to missing pointer errors

* Fix pointer not found errors cause by loop break
  • Loading branch information
aevyrie authored Jun 12, 2024
1 parent 391cfb4 commit ee11589
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
23 changes: 16 additions & 7 deletions crates/bevy_picking_core/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ pub fn pointer_events(
if let PressDirection::Up = press_event.direction {
let Some(location) = pointer_location(press_event.pointer_id) else {
error!(
"Unable to get location for pointer {:?}",
press_event.pointer_id
"Unable to get location for pointer {:?} during event {:?}",
press_event.pointer_id, press_event
);
continue;
};
Expand All @@ -271,8 +271,8 @@ pub fn pointer_events(
if let PressDirection::Down = press_event.direction {
let Some(location) = pointer_location(press_event.pointer_id) else {
error!(
"Unable to get location for pointer {:?}",
press_event.pointer_id
"Unable to get location for pointer {:?} during event {:?}",
press_event.pointer_id, press_event
);
continue;
};
Expand All @@ -298,7 +298,10 @@ pub fn pointer_events(
.any(|e| e.contains_key(&hovered_entity))
{
let Some(location) = pointer_location(pointer_id) else {
error!("Unable to get location for pointer {:?}", pointer_id);
error!(
"Unable to get location for pointer {:?} during pointer over",
pointer_id
);
continue;
};
pointer_over.send(Pointer::new(
Expand All @@ -322,7 +325,10 @@ pub fn pointer_events(
.any(|e| e.contains_key(&hovered_entity))
{
let Some(location) = pointer_location(pointer_id) else {
error!("Unable to get location for pointer {:?}", pointer_id);
error!(
"Unable to get location for pointer {:?} during pointer out",
pointer_id
);
continue;
};
pointer_out.send(Pointer::new(
Expand Down Expand Up @@ -466,7 +472,10 @@ pub fn send_click_and_drag_events(
continue;
};
let Some(location) = pointer_location(press.pointer_id) else {
error!("Unable to get location for pointer {:?}", press.pointer_id);
error!(
"Unable to get location for pointer {:?} during event {:?}",
press.pointer_id, press
);
continue;
};

Expand Down
9 changes: 3 additions & 6 deletions crates/bevy_picking_input/src/touch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ use bevy_hierarchy::DespawnRecursiveExt;
use bevy_input::touch::{TouchInput, TouchPhase};
use bevy_math::Vec2;
use bevy_render::camera::RenderTarget;
use bevy_utils::{
tracing::{debug, info},
HashMap, HashSet,
};
use bevy_utils::{tracing::debug, HashMap, HashSet};
use bevy_window::{PrimaryWindow, WindowRef};

use bevy_picking_core::{
Expand Down Expand Up @@ -46,7 +43,7 @@ pub fn touch_pick_events(
};
match touch.phase {
TouchPhase::Started => {
info!("Spawning pointer {:?}", pointer);
debug!("Spawning pointer {:?}", pointer);
commands.spawn((
PointerCoreBundle::new(pointer).with_location(location.clone()),
#[cfg(feature = "selection")]
Expand All @@ -61,7 +58,7 @@ pub fn touch_pick_events(
// Send a move event only if it isn't the same as the last one
if let Some(last_touch) = location_cache.get(&touch.id) {
if last_touch == touch {
break;
continue;
}
input_moves.send(InputMove::new(
pointer,
Expand Down

0 comments on commit ee11589

Please sign in to comment.