forked from StrafesNET/strafe-client
asd
This commit is contained in:
parent
fbb2ba369c
commit
9ecfe26a0c
@ -27,14 +27,33 @@ pub enum PassthroughInstruction{
|
|||||||
//Graphics(crate::graphics_worker::Instruction),
|
//Graphics(crate::graphics_worker::Instruction),
|
||||||
}
|
}
|
||||||
pub struct MouseInterpolator{
|
pub struct MouseInterpolator{
|
||||||
queue:std::collections::VecDeque<TimedInstruction<Instruction>>,
|
queue:std::collections::VecDeque<TimedInstruction<InputInstruction>>,
|
||||||
}
|
}
|
||||||
impl MouseInterpolator{
|
impl MouseInterpolator{
|
||||||
fn handle_instruction(&mut self,physics:&mut crate::physics::PhysicsContext,ins:InputInstruction,time:Time){
|
fn handle_instruction(&mut self,physics:&mut crate::physics::PhysicsContext,ins:TimedInstruction<InputInstruction>){
|
||||||
//design is completely inverted
|
self.queue.push_back(ins);
|
||||||
//immediately add the instruction to the queue
|
//We just pushed an element.
|
||||||
//if there are two mouse instructions or more than 10ms between the first and last
|
//The first element is guaranteed to exist.
|
||||||
//processs dems instructions
|
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: 10ms<ins.time-time break and do something else
|
||||||
|
true
|
||||||
|
},
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let mut mouse1=None;
|
||||||
|
for ins in iter{
|
||||||
|
//fill mouse0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +65,10 @@ pub fn new(mut physics:crate::physics::PhysicsContext,mut graphics_worker:crate:
|
|||||||
let passthrough_instruction=match ins.instruction{
|
let passthrough_instruction=match ins.instruction{
|
||||||
Instruction::Passthrough(passthrough_instruction)=>passthrough_instruction,
|
Instruction::Passthrough(passthrough_instruction)=>passthrough_instruction,
|
||||||
Instruction::Interpolate(input_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;
|
return;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user