This commit is contained in:
Quaternions 2024-07-30 19:35:51 -07:00
parent 7f68fd9b21
commit d898d7cf67

View File

@ -58,8 +58,15 @@ impl MouseInterpolator{
}, },
_=>if Time::from_millis(10)<ins1.time-ins0.time{ _=>if Time::from_millis(10)<ins1.time-ins0.time{
//we have passed more than 10ms of instructions and have not seen a mouse event. //we have passed more than 10ms of instructions and have not seen a mouse event.
let consume_count=self.queue.len()-iter.len();
//drop the iterator so we can consume the queue up to this point //drop the iterator so we can consume the queue up to this point
std::mem::drop(iter); std::mem::drop(iter);
//run an event to extrapolate no movement from
let last_mouse=physics.get_next_mouse();
physics.run_input_instruction(TimedInstruction{
time:last_mouse.time,
instruction:PhysicsInputInstruction::SetNextMouse(MouseState{time:ins1.time,pos:last_mouse.pos}),
});
//make a new iterator starting from the new beginning and loop like nothing happened //make a new iterator starting from the new beginning and loop like nothing happened
iter=self.queue.iter(); iter=self.queue.iter();
continue 'outer; continue 'outer;
@ -98,6 +105,10 @@ impl MouseInterpolator{
time:ins0.time, time:ins0.time,
instruction:physics_input, instruction:physics_input,
}); });
//drop it and pop it! consume one element and continue the loop
std::mem::drop(iter);
self.queue.pop_front();
iter=self.queue.iter();
}, },
None=>{ None=>{
//if mouse0 is never found and the loop ends, we can drain the entire queue //if mouse0 is never found and the loop ends, we can drain the entire queue