pop_buffered_instruction can be accomplished with mem::replace
This commit is contained in:
parent
93277c042b
commit
33ccefc411
@ -194,16 +194,17 @@ impl MouseInterpolator{
|
||||
match ins{
|
||||
// could check if self.is_first_ready()
|
||||
StepInstruction::Pop=>self.physics_timeline.pop_front(),
|
||||
StepInstruction::Timeout=>replace_with::replace_with_or_abort_and_return(&mut self.buffer_state,|buffer_state|{
|
||||
StepInstruction::Timeout=>{
|
||||
let buffer_state=core::mem::replace(&mut self.buffer_state,BufferState::Unbuffered);
|
||||
match buffer_state{
|
||||
BufferState::Unbuffered=>(None,BufferState::Unbuffered),
|
||||
BufferState::Unbuffered=>None,
|
||||
BufferState::Initializing(_time,mouse_state)
|
||||
|BufferState::Buffered(_time,mouse_state)=>{
|
||||
// convert to BufferState::Unbuffered
|
||||
// use the first instruction which should be a mouse instruction
|
||||
// to push a ReplaceMouse instruction
|
||||
// duplicate the current mouse
|
||||
(Some(TimedInstruction{
|
||||
Some(TimedInstruction{
|
||||
// This should be simulation_timer.time(timeout)
|
||||
// but the timer is not accessible from this scope
|
||||
// and it's just here to say that the mouse isn't moving anyways.
|
||||
@ -211,10 +212,10 @@ impl MouseInterpolator{
|
||||
instruction:PhysicsInputInstruction::Mouse(
|
||||
MouseInstruction::SetNextMouse(mouse_state)
|
||||
),
|
||||
}),BufferState::Unbuffered)
|
||||
})
|
||||
},
|
||||
}
|
||||
}),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user