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),
|
||||
}
|
||||
pub struct MouseInterpolator{
|
||||
queue:std::collections::VecDeque<TimedInstruction<Instruction>>,
|
||||
queue:std::collections::VecDeque<TimedInstruction<InputInstruction>>,
|
||||
}
|
||||
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<InputInstruction>){
|
||||
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: 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{
|
||||
Instruction::Passthrough(passthrough_instruction)=>passthrough_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;
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user