time must advance! (2 bugs related to this)

global.mouse.time
physics.time
This commit is contained in:
Quaternions 2023-10-04 20:39:42 -07:00
parent dd61c64ddd
commit 54a21ae00b
2 changed files with 10 additions and 6 deletions

View File

@ -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 });

View File

@ -1136,14 +1136,14 @@ impl crate::instruction::InstructionEmitter<PhysicsInstruction> for PhysicsState
impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsState {
fn process_instruction(&mut self, ins:TimedInstruction<PhysicsInstruction>) {
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(_)