TimedInstruction::set_time

This commit is contained in:
Quaternions 2025-01-15 03:22:19 -08:00
parent fbacef83b9
commit c2d6af8bda
2 changed files with 10 additions and 6 deletions

View File

@ -5,6 +5,14 @@ pub struct TimedInstruction<I,T>{
pub time:Time<T>, pub time:Time<T>,
pub instruction:I, pub instruction:I,
} }
impl<I,T> TimedInstruction<I,T>{
pub fn set_time<TimeInner>(self,new_time:Time<TimeInner>)->TimedInstruction<I,TimeInner>{
TimedInstruction{
time:new_time,
instruction:self.instruction,
}
}
}
/// Ensure all emitted instructions are processed before consuming external instructions /// Ensure all emitted instructions are processed before consuming external instructions
pub trait InstructionEmitter<I>{ pub trait InstructionEmitter<I>{

View File

@ -181,12 +181,8 @@ impl InstructionConsumer<Instruction<'_>> for Session{
impl InstructionConsumer<StepInstruction> for Session{ impl InstructionConsumer<StepInstruction> for Session{
type TimeInner=SessionTimeInner; type TimeInner=SessionTimeInner;
fn process_instruction(&mut self,ins:TimedInstruction<StepInstruction,Self::TimeInner>){ fn process_instruction(&mut self,ins:TimedInstruction<StepInstruction,Self::TimeInner>){
// ins.time ignored??? let time=self.simulation.timer.time(ins.time);
let ins_retimed=TimedInstruction{ if let Some(instruction)=self.mouse_interpolator.pop_buffered_instruction(ins.set_time(time)){
time:self.simulation.timer.time(ins.time),
instruction:ins.instruction,
};
if let Some(instruction)=self.mouse_interpolator.pop_buffered_instruction(ins_retimed){
self.simulation.physics.run_input_instruction(instruction); self.simulation.physics.run_input_instruction(instruction);
} }
} }