From d2002383cbd2b9a12310ffc4d4bfa9aa56695da0 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 16 Jan 2025 00:09:43 -0800 Subject: [PATCH] idle is special --- lib/common/src/physics.rs | 6 +++--- strafe-client/src/mouse_interpolator.rs | 4 ++++ strafe-client/src/physics.rs | 4 ++-- strafe-client/src/physics_worker.rs | 6 ++---- strafe-client/src/session.rs | 4 ++++ 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/common/src/physics.rs b/lib/common/src/physics.rs index f8173fa..169427d 100644 --- a/lib/common/src/physics.rs +++ b/lib/common/src/physics.rs @@ -10,9 +10,11 @@ pub enum Instruction{ SetControl(SetControlInstruction), Mode(ModeInstruction), Misc(MiscInstruction), + /// Idle: there were no input events, but the simulation is safe to advance to this timestep + Idle, } impl Instruction{ - pub const IDLE:Self=Self::Misc(MiscInstruction::Idle); + pub const IDLE:Self=Self::Idle; } #[derive(Clone,Debug)] pub enum MouseInstruction{ @@ -47,8 +49,6 @@ pub enum ModeInstruction{ } #[derive(Clone,Debug)] pub enum MiscInstruction{ - /// Idle: there were no input events, but the simulation is safe to advance to this timestep - Idle, PracticeFly, SetSensitivity(crate::integer::Ratio64Vec2), } diff --git a/strafe-client/src/mouse_interpolator.rs b/strafe-client/src/mouse_interpolator.rs index 2898a56..a6f4b0e 100644 --- a/strafe-client/src/mouse_interpolator.rs +++ b/strafe-client/src/mouse_interpolator.rs @@ -22,6 +22,7 @@ pub(crate) enum Instruction{ SetControl(SetControlInstruction), Mode(ModeInstruction), Misc(MiscInstruction), + Idle, } #[derive(Clone,Debug)] enum UnbufferedInstruction{ @@ -38,6 +39,7 @@ pub(crate) enum NonMouseInstruction{ SetControl(SetControlInstruction), Mode(ModeInstruction), Misc(MiscInstruction), + Idle, } impl From for UnbufferedInstruction{ #[inline] @@ -47,6 +49,7 @@ impl From for UnbufferedInstruction{ Instruction::SetControl(set_control_instruction)=>UnbufferedInstruction::NonMouse(NonMouseInstruction::SetControl(set_control_instruction)), Instruction::Mode(mode_instruction)=>UnbufferedInstruction::NonMouse(NonMouseInstruction::Mode(mode_instruction)), Instruction::Misc(misc_instruction)=>UnbufferedInstruction::NonMouse(NonMouseInstruction::Misc(misc_instruction)), + Instruction::Idle=>UnbufferedInstruction::NonMouse(NonMouseInstruction::Idle), } } } @@ -59,6 +62,7 @@ impl From for PhysicsInstruction{ NonMouseInstruction::SetControl(set_control_instruction)=>PhysicsInstruction::SetControl(set_control_instruction), NonMouseInstruction::Mode(mode_instruction)=>PhysicsInstruction::Mode(mode_instruction), NonMouseInstruction::Misc(misc_instruction)=>PhysicsInstruction::Misc(misc_instruction), + NonMouseInstruction::Idle=>PhysicsInstruction::Idle, }, } } diff --git a/strafe-client/src/physics.rs b/strafe-client/src/physics.rs index 7cc397d..6ac96ef 100644 --- a/strafe-client/src/physics.rs +++ b/strafe-client/src/physics.rs @@ -1739,7 +1739,7 @@ fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedI Instruction::Misc(MiscInstruction::SetSensitivity(..)) |Instruction::Mode(_) |Instruction::SetControl(SetControlInstruction::SetZoom(..)) - |Instruction::Misc(MiscInstruction::Idle)=>false, + |Instruction::Idle=>false, //these controls only update the body if you are on the ground Instruction::Mouse(_) |Instruction::SetControl(_)=>{ @@ -1837,7 +1837,7 @@ fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedI } b_refresh_walk_target=false; }, - Instruction::Misc(MiscInstruction::Idle)=>{ + Instruction::Idle=>{ //literally idle! b_refresh_walk_target=false; }, diff --git a/strafe-client/src/physics_worker.rs b/strafe-client/src/physics_worker.rs index 3acc292..c991381 100644 --- a/strafe-client/src/physics_worker.rs +++ b/strafe-client/src/physics_worker.rs @@ -17,8 +17,6 @@ pub enum Instruction{ ChangeMap(strafesnet_common::map::CompleteMap), } -const SESSION_INSTRUCTION_IDLE:SessionInstruction=SessionInstruction::Input(SessionInputInstruction::Misc(strafesnet_common::physics::MiscInstruction::Idle)); - pub fn new<'a>( mut graphics_worker:crate::compat_worker::INWorker<'a,crate::graphics_worker::Instruction>, user_settings:crate::settings::UserSettings, @@ -56,13 +54,13 @@ pub fn new<'a>( run_session_instruction!(ins.time,SessionInstruction::Playback(unbuffered_instruction)); }, Instruction::Render=>{ - run_session_instruction!(ins.time,SESSION_INSTRUCTION_IDLE); + run_session_instruction!(ins.time,SessionInstruction::Idle); if let Some(frame_state)=session.get_frame_state(ins.time){ run_graphics_worker_instruction!(GraphicsInstruction::Render(frame_state)); } }, Instruction::Resize(physical_size)=>{ - run_session_instruction!(ins.time,SESSION_INSTRUCTION_IDLE); + run_session_instruction!(ins.time,SessionInstruction::Idle); let user_settings=session.user_settings().clone(); run_graphics_worker_instruction!(GraphicsInstruction::Resize(physical_size,user_settings)); }, diff --git a/strafe-client/src/session.rs b/strafe-client/src/session.rs index ec3a3ae..145f474 100644 --- a/strafe-client/src/session.rs +++ b/strafe-client/src/session.rs @@ -21,6 +21,7 @@ pub enum Instruction<'a>{ Control(SessionControlInstruction), Playback(SessionPlaybackInstruction), ChangeMap(&'a strafesnet_common::map::CompleteMap), + Idle, } pub enum SessionInputInstruction{ @@ -258,6 +259,9 @@ impl InstructionConsumer> for Session{ run_mouse_interpolator_instruction!(MouseInterpolatorInstruction::Misc(MiscInstruction::SetSensitivity(self.user_settings().calculate_sensitivity()))); run_mouse_interpolator_instruction!(MouseInterpolatorInstruction::Mode(ModeInstruction::Spawn(ModeId::MAIN,StageId::FIRST))); }, + Instruction::Idle=>{ + run_mouse_interpolator_instruction!(MouseInterpolatorInstruction::Idle); + } }; // process all emitted output instructions