From d7dc08092a5cc79c4076af5fc8be2b9218813f48 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 30 Jul 2024 20:15:39 -0700 Subject: [PATCH] hehehehehe --- src/physics_worker.rs | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/src/physics_worker.rs b/src/physics_worker.rs index e95f7ed..ab91cc8 100644 --- a/src/physics_worker.rs +++ b/src/physics_worker.rs @@ -29,6 +29,27 @@ pub enum PassthroughInstruction{ pub struct MouseInterpolator{ queue:std::collections::VecDeque>, } +fn drain_queue(physics:&mut crate::physics::PhysicsContext,iterable:impl IntoIterator>){ + for ins in iterable{ + let physics_input=match &ins.instruction{ + InputInstruction::MoveMouse(_)=>panic!("Queue was confirmed to contain no MoveMouse events1"), + &InputInstruction::MoveForward(s)=>PhysicsInputInstruction::SetMoveForward(s), + &InputInstruction::MoveLeft(s)=>PhysicsInputInstruction::SetMoveLeft(s), + &InputInstruction::MoveBack(s)=>PhysicsInputInstruction::SetMoveBack(s), + &InputInstruction::MoveRight(s)=>PhysicsInputInstruction::SetMoveRight(s), + &InputInstruction::MoveUp(s)=>PhysicsInputInstruction::SetMoveUp(s), + &InputInstruction::MoveDown(s)=>PhysicsInputInstruction::SetMoveDown(s), + &InputInstruction::Jump(s)=>PhysicsInputInstruction::SetJump(s), + &InputInstruction::Zoom(s)=>PhysicsInputInstruction::SetZoom(s), + InputInstruction::Reset=>PhysicsInputInstruction::Reset, + InputInstruction::PracticeFly=>PhysicsInputInstruction::PracticeFly, + }; + physics.run_input_instruction(TimedInstruction{ + time:ins.time, + instruction:physics_input, + }); + } +} impl MouseInterpolator{ fn handle_instruction(&mut self,physics:&mut crate::physics::PhysicsContext,ins:TimedInstruction){ let is_inserting_mouse_instruction=matches!(ins.instruction,InputInstruction::MoveMouse(_)); @@ -59,15 +80,23 @@ impl MouseInterpolator{ _=>if Time::from_millis(10)