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,
|
PracticeFly,
|
||||||
}
|
}
|
||||||
pub enum Instruction{
|
pub enum Instruction{
|
||||||
Input(InputInstruction),
|
Passthrough(PassthroughInstruction),
|
||||||
|
Interpolate(InputInstruction),
|
||||||
|
}
|
||||||
|
pub enum PassthroughInstruction{
|
||||||
Render,
|
Render,
|
||||||
Resize(winit::dpi::PhysicalSize<u32>,crate::settings::UserSettings),
|
Resize(winit::dpi::PhysicalSize<u32>,crate::settings::UserSettings),
|
||||||
GenerateModels(strafesnet_common::map::CompleteMap),
|
GenerateModels(strafesnet_common::map::CompleteMap),
|
||||||
@ -27,7 +30,7 @@ pub struct MouseInterpolator{
|
|||||||
queue:std::collections::VecDeque<TimedInstruction<Instruction>>,
|
queue:std::collections::VecDeque<TimedInstruction<Instruction>>,
|
||||||
}
|
}
|
||||||
impl MouseInterpolator{
|
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
|
//design is completely inverted
|
||||||
//immediately add the instruction to the queue
|
//immediately add the instruction to the queue
|
||||||
//if there are two mouse instructions or more than 10ms between the first and last
|
//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(),
|
queue:std::collections::VecDeque::new(),
|
||||||
};
|
};
|
||||||
crate::compat_worker::QNWorker::new(move |ins:TimedInstruction<Instruction>|{
|
crate::compat_worker::QNWorker::new(move |ins:TimedInstruction<Instruction>|{
|
||||||
let instruction=interpolator.handle_instruction(&mut physics,ins);
|
let passthrough_instruction=match ins.instruction{
|
||||||
match instruction{
|
Instruction::Passthrough(passthrough_instruction)=>passthrough_instruction,
|
||||||
Instruction::Render=>{
|
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();
|
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();
|
graphics_worker.send(crate::graphics_worker::Instruction::Resize(size,user_settings)).unwrap();
|
||||||
},
|
},
|
||||||
Instruction::GenerateModels(map)=>{
|
PassthroughInstruction::GenerateModels(map)=>{
|
||||||
physics.generate_models(&map);
|
physics.generate_models(&map);
|
||||||
physics.spawn();
|
physics.spawn();
|
||||||
graphics_worker.send(crate::graphics_worker::Instruction::GenerateModels(map)).unwrap();
|
graphics_worker.send(crate::graphics_worker::Instruction::GenerateModels(map)).unwrap();
|
||||||
},
|
},
|
||||||
Instruction::ClearModels=>{
|
PassthroughInstruction::ClearModels=>{
|
||||||
physics.clear();
|
physics.clear();
|
||||||
graphics_worker.send(crate::graphics_worker::Instruction::ClearModels).unwrap();
|
graphics_worker.send(crate::graphics_worker::Instruction::ClearModels).unwrap();
|
||||||
},
|
},
|
||||||
|
@ -115,7 +115,7 @@ impl WindowContext<'_>{
|
|||||||
}{
|
}{
|
||||||
self.physics_thread.send(TimedInstruction{
|
self.physics_thread.send(TimedInstruction{
|
||||||
time,
|
time,
|
||||||
instruction:crate::physics_worker::Instruction::Input(input_instruction),
|
instruction:crate::physics_worker::Instruction::Interpolate(input_instruction),
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -143,7 +143,7 @@ impl WindowContext<'_>{
|
|||||||
self.mouse.pos+=delta;
|
self.mouse.pos+=delta;
|
||||||
self.physics_thread.send(TimedInstruction{
|
self.physics_thread.send(TimedInstruction{
|
||||||
time,
|
time,
|
||||||
instruction:crate::physics_worker::Instruction::Input(InputInstruction::MoveMouse(self.mouse.pos)),
|
instruction:crate::physics_worker::Instruction::Interpolate(InputInstruction::MoveMouse(self.mouse.pos)),
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
},
|
},
|
||||||
winit::event::DeviceEvent::MouseWheel {
|
winit::event::DeviceEvent::MouseWheel {
|
||||||
@ -153,7 +153,7 @@ impl WindowContext<'_>{
|
|||||||
if false{//self.physics.style.use_scroll{
|
if false{//self.physics.style.use_scroll{
|
||||||
self.physics_thread.send(TimedInstruction{
|
self.physics_thread.send(TimedInstruction{
|
||||||
time,
|
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();
|
}).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -218,7 +218,9 @@ impl<'a> WindowContextSetup<'a>{
|
|||||||
window_context.physics_thread.send(
|
window_context.physics_thread.send(
|
||||||
TimedInstruction{
|
TimedInstruction{
|
||||||
time:ins.time,
|
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();
|
).unwrap();
|
||||||
}
|
}
|
||||||
@ -226,7 +228,9 @@ impl<'a> WindowContextSetup<'a>{
|
|||||||
window_context.physics_thread.send(
|
window_context.physics_thread.send(
|
||||||
TimedInstruction{
|
TimedInstruction{
|
||||||
time:ins.time,
|
time:ins.time,
|
||||||
instruction:crate::physics_worker::Instruction::Render
|
instruction:crate::physics_worker::Instruction::Passthrough(
|
||||||
|
crate::physics_worker::PassthroughInstruction::Render
|
||||||
|
)
|
||||||
}
|
}
|
||||||
).unwrap();
|
).unwrap();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user