forked from StrafesNET/strafe-client
redo data structures
This commit is contained in:
parent
d1f78b6e18
commit
fbb2ba369c
@ -16,7 +16,10 @@ pub enum InputInstruction{
|
||||
PracticeFly,
|
||||
}
|
||||
pub enum Instruction{
|
||||
Input(InputInstruction),
|
||||
Passthrough(PassthroughInstruction),
|
||||
Interpolate(InputInstruction),
|
||||
}
|
||||
pub enum PassthroughInstruction{
|
||||
Render,
|
||||
Resize(winit::dpi::PhysicalSize<u32>,crate::settings::UserSettings),
|
||||
GenerateModels(strafesnet_common::map::CompleteMap),
|
||||
@ -27,7 +30,7 @@ pub struct MouseInterpolator{
|
||||
queue:std::collections::VecDeque<TimedInstruction<Instruction>>,
|
||||
}
|
||||
impl MouseInterpolator{
|
||||
fn handle_instruction(&mut self,physics:&mut crate::physics::PhysicsContext,ins:TimedInstruction<Instruction>){
|
||||
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
|
||||
@ -40,20 +43,26 @@ pub fn new(mut physics:crate::physics::PhysicsContext,mut graphics_worker:crate:
|
||||
queue:std::collections::VecDeque::new(),
|
||||
};
|
||||
crate::compat_worker::QNWorker::new(move |ins:TimedInstruction<Instruction>|{
|
||||
let instruction=interpolator.handle_instruction(&mut physics,ins);
|
||||
match instruction{
|
||||
Instruction::Render=>{
|
||||
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);
|
||||
return;
|
||||
},
|
||||
};
|
||||
match passthrough_instruction{
|
||||
PassthroughInstruction::Render=>{
|
||||
graphics_worker.send(crate::graphics_worker::Instruction::Render(physics.output(),ins.time,physics.get_next_mouse().pos)).unwrap();
|
||||
},
|
||||
Instruction::Resize(size,user_settings)=>{
|
||||
PassthroughInstruction::Resize(size,user_settings)=>{
|
||||
graphics_worker.send(crate::graphics_worker::Instruction::Resize(size,user_settings)).unwrap();
|
||||
},
|
||||
Instruction::GenerateModels(map)=>{
|
||||
PassthroughInstruction::GenerateModels(map)=>{
|
||||
physics.generate_models(&map);
|
||||
physics.spawn();
|
||||
graphics_worker.send(crate::graphics_worker::Instruction::GenerateModels(map)).unwrap();
|
||||
},
|
||||
Instruction::ClearModels=>{
|
||||
PassthroughInstruction::ClearModels=>{
|
||||
physics.clear();
|
||||
graphics_worker.send(crate::graphics_worker::Instruction::ClearModels).unwrap();
|
||||
},
|
||||
|
@ -115,7 +115,7 @@ impl WindowContext<'_>{
|
||||
}{
|
||||
self.physics_thread.send(TimedInstruction{
|
||||
time,
|
||||
instruction:crate::physics_worker::Instruction::Input(input_instruction),
|
||||
instruction:crate::physics_worker::Instruction::Interpolate(input_instruction),
|
||||
}).unwrap();
|
||||
}
|
||||
},
|
||||
@ -143,7 +143,7 @@ impl WindowContext<'_>{
|
||||
self.mouse.pos+=delta;
|
||||
self.physics_thread.send(TimedInstruction{
|
||||
time,
|
||||
instruction:crate::physics_worker::Instruction::Input(InputInstruction::MoveMouse(self.mouse.pos)),
|
||||
instruction:crate::physics_worker::Instruction::Interpolate(InputInstruction::MoveMouse(self.mouse.pos)),
|
||||
}).unwrap();
|
||||
},
|
||||
winit::event::DeviceEvent::MouseWheel {
|
||||
@ -153,7 +153,7 @@ impl WindowContext<'_>{
|
||||
if false{//self.physics.style.use_scroll{
|
||||
self.physics_thread.send(TimedInstruction{
|
||||
time,
|
||||
instruction:crate::physics_worker::Instruction::Input(InputInstruction::Jump(true)),//activates the immediate jump path, but the style modifier prevents controls&CONTROL_JUMP bit from being set to auto jump
|
||||
instruction:crate::physics_worker::Instruction::Interpolate(InputInstruction::Jump(true)),//activates the immediate jump path, but the style modifier prevents controls&CONTROL_JUMP bit from being set to auto jump
|
||||
}).unwrap();
|
||||
}
|
||||
}
|
||||
@ -218,7 +218,9 @@ impl<'a> WindowContextSetup<'a>{
|
||||
window_context.physics_thread.send(
|
||||
TimedInstruction{
|
||||
time:ins.time,
|
||||
instruction:crate::physics_worker::Instruction::Resize(size,window_context.user_settings.clone())
|
||||
instruction:crate::physics_worker::Instruction::Passthrough(
|
||||
crate::physics_worker::PassthroughInstruction::Resize(size,window_context.user_settings.clone())
|
||||
)
|
||||
}
|
||||
).unwrap();
|
||||
}
|
||||
@ -226,7 +228,9 @@ impl<'a> WindowContextSetup<'a>{
|
||||
window_context.physics_thread.send(
|
||||
TimedInstruction{
|
||||
time:ins.time,
|
||||
instruction:crate::physics_worker::Instruction::Render
|
||||
instruction:crate::physics_worker::Instruction::Passthrough(
|
||||
crate::physics_worker::PassthroughInstruction::Render
|
||||
)
|
||||
}
|
||||
).unwrap();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user