From 719c702b95b3a4cd0c6cbd2a706f658a73bdcb11 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 10 Jan 2025 22:01:02 -0800 Subject: [PATCH] actually need ReplaceMouse because of OS level issue The operating system does not report the timestamp at which it checks that the mouse was not moving, so the mouse interpolation will necessarily be incorrect for up to 1 polling period. The alternative is to guess / make up a timestamp, but I don't want to do this. --- lib/common/src/physics.rs | 1 + strafe-client/src/physics.rs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib/common/src/physics.rs b/lib/common/src/physics.rs index aa041ab..dc6be13 100644 --- a/lib/common/src/physics.rs +++ b/lib/common/src/physics.rs @@ -4,6 +4,7 @@ pub type Time=crate::integer::Time; #[derive(Clone,Debug)] pub enum Instruction{ + ReplaceMouse(crate::mouse::MouseState,crate::mouse::MouseState), SetNextMouse(crate::mouse::MouseState), SetMoveRight(bool), SetMoveUp(bool), diff --git a/strafe-client/src/physics.rs b/strafe-client/src/physics.rs index f94fbe7..16bbe48 100644 --- a/strafe-client/src/physics.rs +++ b/strafe-client/src/physics.rs @@ -1759,6 +1759,7 @@ fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedI |PhysicsInputInstruction::Idle=>false, //these controls only update the body if you are on the ground PhysicsInputInstruction::SetNextMouse(..) + |PhysicsInputInstruction::ReplaceMouse(..) |PhysicsInputInstruction::SetMoveForward(..) |PhysicsInputInstruction::SetMoveLeft(..) |PhysicsInputInstruction::SetMoveBack(..) @@ -1788,6 +1789,10 @@ fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedI state.camera.move_mouse(state.input_state.mouse_delta()); state.input_state.set_next_mouse(m); }, + PhysicsInputInstruction::ReplaceMouse(m0,m1)=>{ + state.camera.move_mouse(m0.pos-state.input_state.mouse.pos); + state.input_state.replace_mouse(m0,m1); + }, PhysicsInputInstruction::SetMoveForward(s)=>state.input_state.set_control(Controls::MoveForward,s), PhysicsInputInstruction::SetMoveLeft(s)=>state.input_state.set_control(Controls::MoveLeft,s), PhysicsInputInstruction::SetMoveBack(s)=>state.input_state.set_control(Controls::MoveBackward,s),