diff --git a/src/backend/openxr/input.rs b/src/backend/openxr/input.rs index b174195..b80a467 100644 --- a/src/backend/openxr/input.rs +++ b/src/backend/openxr/input.rs @@ -316,13 +316,21 @@ impl OpenXrHand { .location_flags .contains(xr::SpaceLocationFlags::ORIENTATION_VALID) { - let (quat, pos) = unsafe { + let (cur_quat, cur_pos) = (Quat::from_affine3(&pointer.pose), pointer.pose.translation); + + let (new_quat, new_pos) = unsafe { ( transmute::(location.pose.orientation), transmute::(location.pose.position), ) }; - pointer.pose = Affine3A::from_rotation_translation(quat, pos); + pointer.raw_pose = Affine3A::from_rotation_translation(new_quat, new_pos); + pointer.pose = Affine3A::from_rotation_translation( + cur_quat.lerp(new_quat, session.config.pointer_lerp_factor), + cur_pos + .lerp(new_pos.into(), session.config.pointer_lerp_factor) + .into(), + ); } pointer.now.click = self diff --git a/src/backend/openxr/playspace.rs b/src/backend/openxr/playspace.rs index 74830c1..a7cbfee 100644 --- a/src/backend/openxr/playspace.rs +++ b/src/backend/openxr/playspace.rs @@ -55,7 +55,7 @@ impl PlayspaceMover { state: &AppState, monado: &mut Monado, ) { - for (_i, pointer) in state.input_state.pointers.iter().enumerate() { + for pointer in state.input_state.pointers.iter() { if pointer.now.space_reset { if !pointer.before.space_reset { log::info!("Space reset"); @@ -74,7 +74,7 @@ impl PlayspaceMover { } let new_hand = - Quat::from_affine3(&(data.pose * state.input_state.pointers[data.hand].pose)); + Quat::from_affine3(&(data.pose * state.input_state.pointers[data.hand].raw_pose)); let dq = new_hand * data.hand_pose.conjugate(); let rel_y = f32::atan2( @@ -131,7 +131,7 @@ impl PlayspaceMover { let new_hand = data .pose - .transform_point3a(state.input_state.pointers[data.hand].pose.translation); + .transform_point3a(state.input_state.pointers[data.hand].raw_pose.translation); let relative_pos = (new_hand - data.hand_pose) * state.session.config.space_drag_multiplier; @@ -159,7 +159,7 @@ impl PlayspaceMover { if pointer.now.space_drag { let hand_pos = self .last_transform - .transform_point3a(pointer.pose.translation); + .transform_point3a(pointer.raw_pose.translation); self.drag = Some(MoverData { pose: self.last_transform, hand: i, @@ -196,8 +196,8 @@ impl PlayspaceMover { self.rotate = None; } - let y1 = input.pointers[0].pose.translation.y; - let y2 = input.pointers[1].pose.translation.y; + let y1 = input.pointers[0].raw_pose.translation.y; + let y2 = input.pointers[1].raw_pose.translation.y; let delta = y1.min(y2) - 0.03; self.last_transform.translation.y += delta; self.apply_offset(self.last_transform, monado); diff --git a/src/config.rs b/src/config.rs index a494e90..cda55aa 100644 --- a/src/config.rs +++ b/src/config.rs @@ -121,6 +121,10 @@ pub fn def_point7() -> f32 { 0.7 } +pub fn def_point3() -> f32 { + 0.3 +} + fn def_osc_port() -> u16 { 9000 } @@ -263,6 +267,9 @@ pub struct GeneralConfig { #[serde(default = "def_false")] pub screen_render_down: bool, + + #[serde(default = "def_point3")] + pub pointer_lerp_factor: f32, } impl GeneralConfig {