From 54a21ae00b98fa16779b305792a994346f53dfb8 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 4 Oct 2023 20:39:42 -0700 Subject: [PATCH] time must advance! (2 bugs related to this) global.mouse.time physics.time --- src/main.rs | 8 ++++++-- src/physics.rs | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 40bf643..c0308c1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -994,9 +994,11 @@ impl framework::Example for GlobalState { //do not step the physics because the mouse polling rate is higher than the physics can run. //essentially the previous input will be overwritten until a true step runs //which is fine because they run all the time. + let delta=glam::ivec2(delta.0 as i32,delta.1 as i32); + self.mouse.pos+=delta; self.physics_thread.send(TimedInstruction{ time, - instruction:InputInstruction::MoveMouse(glam::ivec2(delta.0 as i32,delta.1 as i32)), + instruction:InputInstruction::MoveMouse(self.mouse.pos), }).unwrap(); }, winit::event::DeviceEvent::MouseWheel { @@ -1031,12 +1033,14 @@ impl framework::Example for GlobalState { queue: &wgpu::Queue, _spawner: &framework::Spawner, ) { + //ideally this would be scheduled to execute and finish right before the render. let time=self.start_time.elapsed().as_nanos() as i64; - self.physics_thread.send(TimedInstruction{ time, instruction:InputInstruction::Idle, }).unwrap(); + //update time lol + self.mouse.time=time; let mut encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None }); diff --git a/src/physics.rs b/src/physics.rs index adc8d40..7d79768 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -1136,14 +1136,14 @@ impl crate::instruction::InstructionEmitter for PhysicsState impl crate::instruction::InstructionConsumer for PhysicsState { fn process_instruction(&mut self, ins:TimedInstruction) { match &ins.instruction { - PhysicsInstruction::Input(InputInstruction::Idle)| - PhysicsInstruction::StrafeTick => (), - PhysicsInstruction::Input(InputInstruction::MoveMouse(_)) => (), + PhysicsInstruction::Input(InputInstruction::Idle) + |PhysicsInstruction::Input(InputInstruction::MoveMouse(_)) + |PhysicsInstruction::StrafeTick => (), _=>println!("{}|{:?}",ins.time,ins.instruction), } //selectively update body match &ins.instruction { - PhysicsInstruction::Input(InputInstruction::MoveMouse(_)) => (),//dodge time for mouse movement + //PhysicsInstruction::Input(InputInstruction::MoveMouse(_)) => (),//dodge time for mouse movement PhysicsInstruction::Input(_) |PhysicsInstruction::ReachWalkTargetVelocity |PhysicsInstruction::CollisionStart(_)