primary pointer is the one that was last clicked

This commit is contained in:
galister
2024-02-04 15:51:09 +01:00
parent 82f53e6668
commit 6bc708714c
2 changed files with 19 additions and 4 deletions

View File

@@ -87,6 +87,10 @@ impl InputState {
}
}
if hand.now.click {
hand.last_click = Instant::now();
}
if hand.now.click_modifier_right {
hand.interaction.mode = PointerMode::Right;
continue;
@@ -157,6 +161,7 @@ pub struct Pointer {
pub pose: Affine3A,
pub now: PointerState,
pub before: PointerState,
pub last_click: Instant,
pub(super) interaction: InteractionState,
}
@@ -168,6 +173,7 @@ impl Pointer {
pose: Affine3A::IDENTITY,
now: Default::default(),
before: Default::default(),
last_click: Instant::now(),
interaction: Default::default(),
}
}
@@ -249,10 +255,15 @@ pub fn interact<O>(
where
O: Default,
{
[
interact_hand(0, overlays, app),
interact_hand(1, overlays, app),
]
if app.input_state.pointers[1].last_click > app.input_state.pointers[0].last_click {
let right = interact_hand(1, overlays, app);
let left = interact_hand(0, overlays, app);
[left, right]
} else {
let left = interact_hand(0, overlays, app);
let right = interact_hand(1, overlays, app);
[left, right]
}
}
fn interact_hand<O>(

View File

@@ -1,6 +1,8 @@
use std::f32::consts::PI;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use std::thread::sleep;
use std::time::Duration;
use glam::{Affine3A, Vec3, Vec3A, Vec4};
use idmap::IdMap;
@@ -81,6 +83,8 @@ impl LinePool {
};
data.data.sort_order = 69;
sleep(Duration::from_millis(50));
data.initialize(overlay, app);
data.upload_texture(overlay, &app.graphics);