forked from StrafesNET/strafe-client
work
This commit is contained in:
parent
9c9d8f8f8f
commit
4655f43f5f
@ -3,4 +3,11 @@ struct Context{
|
|||||||
queue:wgpu::Queue,
|
queue:wgpu::Queue,
|
||||||
}
|
}
|
||||||
|
|
||||||
//??
|
impl Context{
|
||||||
|
pub fn new(user_settings:&crate::settings::UserSettings,indexed_model_instances:&crate::model::IndexedModelInstances){
|
||||||
|
let mut graphics=crate::graphics::GraphicsState::new();
|
||||||
|
graphics.load_user_settings(user_settings);
|
||||||
|
graphics.generate_models(indexed_model_instances);
|
||||||
|
}
|
||||||
|
//into_worker
|
||||||
|
}
|
@ -20,24 +20,18 @@ pub enum InputInstruction {
|
|||||||
//to be 1 instruction ahead to generate the next state for interpolation.
|
//to be 1 instruction ahead to generate the next state for interpolation.
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct RenderState{
|
pub struct Context{
|
||||||
physics:crate::physics::PhysicsState,
|
|
||||||
graphics:crate::graphics::GraphicsState,
|
|
||||||
}
|
}
|
||||||
impl RenderState{
|
impl Context{
|
||||||
pub fn new(user_settings:&crate::settings::UserSettings,indexed_model_instances:crate::model::IndexedModelInstances){
|
pub fn new(user_settings:&crate::settings::UserSettings,indexed_model_instances:&crate::model::IndexedModelInstances){
|
||||||
|
|
||||||
let mut physics=crate::physics::PhysicsState::default();
|
let mut physics=crate::physics::PhysicsState::default();
|
||||||
physics.spawn(indexed_model_instances.spawn_point);
|
physics.spawn(indexed_model_instances.spawn_point);
|
||||||
physics.load_user_settings(user_settings);
|
physics.load_user_settings(user_settings);
|
||||||
physics.generate_models(&indexed_model_instances);
|
physics.generate_models(&indexed_model_instances);
|
||||||
|
|
||||||
let mut graphics=Self::new_graphics_state();
|
|
||||||
graphics.load_user_settings(user_settings);
|
|
||||||
graphics.generate_models(indexed_model_instances);
|
|
||||||
//manual reset
|
|
||||||
}
|
}
|
||||||
pub fn into_worker(mut self)->crate::worker::QNWorker<TimedInstruction<InputInstruction>>{
|
pub fn into_worker(mut self)->crate::worker::QNWorker<TimedInstruction<InputInstruction>>{
|
||||||
|
let graphics_context=crate::graphics_context::Context::new();
|
||||||
|
let graphics_thread=graphics_context.into_worker();
|
||||||
let mut mouse_blocking=true;
|
let mut mouse_blocking=true;
|
||||||
let mut last_mouse_time=self.physics.next_mouse.time;
|
let mut last_mouse_time=self.physics.next_mouse.time;
|
||||||
let mut timeline=std::collections::VecDeque::new();
|
let mut timeline=std::collections::VecDeque::new();
|
||||||
@ -122,7 +116,7 @@ impl RenderState{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if render{
|
if render{
|
||||||
self.graphics.render();
|
graphics_thread.send(TimedInstruction{time:ins.time,instruction:crate::graphics_context::GraphicsInstruction::Render});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,8 @@ impl RunState {
|
|||||||
|
|
||||||
pub fn into_worker(self,mut setup_context:crate::setup_context::SetupContext)->crate::worker::QNWorker<TimedInstruction<RunInstruction>>{
|
pub fn into_worker(self,mut setup_context:crate::setup_context::SetupContext)->crate::worker::QNWorker<TimedInstruction<RunInstruction>>{
|
||||||
//create child context
|
//create child context
|
||||||
let physics_context=PhysicsContext::new(());
|
let physics_context=crate::physics_context::Context::new(indexed_models,&setup_context);//this needs all the context for graphics_context too
|
||||||
|
let physics_thread=physics_context.into_worker();
|
||||||
//
|
//
|
||||||
crate::worker::QNWorker::new(move |ins:TimedInstruction<RunInstruction>|{
|
crate::worker::QNWorker::new(move |ins:TimedInstruction<RunInstruction>|{
|
||||||
match ins.instruction{
|
match ins.instruction{
|
||||||
@ -207,8 +208,8 @@ impl RunState {
|
|||||||
RunInstruction::Resize(size)=>{
|
RunInstruction::Resize(size)=>{
|
||||||
setup_context.config.width=size.width.max(1);
|
setup_context.config.width=size.width.max(1);
|
||||||
setup_context.config.height=size.height.max(1);
|
setup_context.config.height=size.height.max(1);
|
||||||
self.graphics.resize(&setup_context.device,&setup_context.config);
|
|
||||||
setup_context.surface.configure(&setup_context.device,&setup_context.config);
|
setup_context.surface.configure(&setup_context.device,&setup_context.config);
|
||||||
|
physics_thread.send(TimedInstruction{time:ins.time,instruction:PhysicsInstruction::Resize(size)});
|
||||||
}
|
}
|
||||||
RunInstruction::Render=>{
|
RunInstruction::Render=>{
|
||||||
let frame=match setup_context.surface.get_current_texture(){
|
let frame=match setup_context.surface.get_current_texture(){
|
||||||
@ -225,7 +226,7 @@ impl RunState {
|
|||||||
..wgpu::TextureViewDescriptor::default()
|
..wgpu::TextureViewDescriptor::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
self.graphics.render(&view,&setup_context.device,&setup_context.queue);
|
physics_thread.send(TimedInstruction{time:ins.time,instruction:PhysicsInstruction::Render(view)});
|
||||||
|
|
||||||
frame.present();
|
frame.present();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user