From 9ecfe26a0c7fd22aec108d17a1b5485035cb8e6c Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 30 Jul 2024 18:00:20 -0700 Subject: [PATCH] asd --- src/physics_worker.rs | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/src/physics_worker.rs b/src/physics_worker.rs index 6aca31e..e7c278c 100644 --- a/src/physics_worker.rs +++ b/src/physics_worker.rs @@ -27,14 +27,33 @@ pub enum PassthroughInstruction{ //Graphics(crate::graphics_worker::Instruction), } pub struct MouseInterpolator{ - queue:std::collections::VecDeque>, + queue:std::collections::VecDeque>, } impl MouseInterpolator{ - fn handle_instruction(&mut self,physics:&mut crate::physics::PhysicsContext,ins:InputInstruction,time:Time){ - //design is completely inverted - //immediately add the instruction to the queue - //if there are two mouse instructions or more than 10ms between the first and last - //processs dems instructions + fn handle_instruction(&mut self,physics:&mut crate::physics::PhysicsContext,ins:TimedInstruction){ + self.queue.push_back(ins); + //We just pushed an element. + //The first element is guaranteed to exist. + let t0=self.queue[0].time; + let mut iter=self.queue.iter(); + //find a mouse input + let mouse0=None; + iter.take_while(|&ins|{ + match ins.instruction{ + InputInstruction::MoveMouse(m)=>{ + mouse0=Some(m); + false + }, + _=>{ + //TODO: 10mspassthrough_instruction, Instruction::Interpolate(input_instruction)=>{ - interpolator.handle_instruction(&mut physics,input_instruction,ins.time); + interpolator.handle_instruction(&mut physics,TimedInstruction{ + instruction:input_instruction, + time:ins.time, + }); return; }, };