forked from StrafesNET/strafe-client
runtime map loading!
This commit is contained in:
parent
6377885d6d
commit
14f3b4fb0d
@ -1,8 +1,9 @@
|
|||||||
#[derive(Clone)]
|
|
||||||
pub enum Instruction{
|
pub enum Instruction{
|
||||||
Render(crate::physics::PhysicsOutputState,crate::integer::Time,glam::IVec2),
|
Render(crate::physics::PhysicsOutputState,crate::integer::Time,glam::IVec2),
|
||||||
//UpdateModel(crate::graphics::ModelUpdate),
|
//UpdateModel(crate::graphics::ModelUpdate),
|
||||||
Resize(winit::dpi::PhysicalSize<u32>,crate::settings::UserSettings),
|
Resize(winit::dpi::PhysicalSize<u32>,crate::settings::UserSettings),
|
||||||
|
GenerateModels(crate::model::IndexedModelInstances),
|
||||||
|
ClearModels,
|
||||||
}
|
}
|
||||||
|
|
||||||
//Ideally the graphics thread worker description is:
|
//Ideally the graphics thread worker description is:
|
||||||
@ -23,6 +24,12 @@ pub fn new<'a>(
|
|||||||
)->crate::compat_worker::INWorker<'a,Instruction>{
|
)->crate::compat_worker::INWorker<'a,Instruction>{
|
||||||
crate::compat_worker::INWorker::new(move |ins:Instruction|{
|
crate::compat_worker::INWorker::new(move |ins:Instruction|{
|
||||||
match ins{
|
match ins{
|
||||||
|
Instruction::GenerateModels(indexed_model_instances)=>{
|
||||||
|
graphics.generate_models(&device,&queue,indexed_model_instances);
|
||||||
|
},
|
||||||
|
Instruction::ClearModels=>{
|
||||||
|
graphics.clear();
|
||||||
|
},
|
||||||
Instruction::Resize(size,user_settings)=>{
|
Instruction::Resize(size,user_settings)=>{
|
||||||
println!("Resizing to {:?}",size);
|
println!("Resizing to {:?}",size);
|
||||||
config.width=size.width.max(1);
|
config.width=size.width.max(1);
|
||||||
|
@ -734,6 +734,7 @@ impl PhysicsState {
|
|||||||
self.models.clear();
|
self.models.clear();
|
||||||
self.modes.clear();
|
self.modes.clear();
|
||||||
self.touching.clear();
|
self.touching.clear();
|
||||||
|
self.bvh=crate::bvh::BvhNode::default();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn output(&self)->PhysicsOutputState{
|
pub fn output(&self)->PhysicsOutputState{
|
||||||
|
@ -18,6 +18,8 @@ pub enum Instruction{
|
|||||||
Input(InputInstruction),
|
Input(InputInstruction),
|
||||||
Render,
|
Render,
|
||||||
Resize(winit::dpi::PhysicalSize<u32>,crate::settings::UserSettings),
|
Resize(winit::dpi::PhysicalSize<u32>,crate::settings::UserSettings),
|
||||||
|
GenerateModels(crate::model::IndexedModelInstances),
|
||||||
|
ClearModels,
|
||||||
//Graphics(crate::graphics_worker::Instruction),
|
//Graphics(crate::graphics_worker::Instruction),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,6 +63,8 @@ pub enum Instruction{
|
|||||||
&InputInstruction::Zoom(s)=>Some(PhysicsInputInstruction::SetZoom(s)),
|
&InputInstruction::Zoom(s)=>Some(PhysicsInputInstruction::SetZoom(s)),
|
||||||
InputInstruction::Reset=>Some(PhysicsInputInstruction::Reset),
|
InputInstruction::Reset=>Some(PhysicsInputInstruction::Reset),
|
||||||
},
|
},
|
||||||
|
Instruction::GenerateModels(_)=>Some(PhysicsInputInstruction::Idle),
|
||||||
|
Instruction::ClearModels=>Some(PhysicsInputInstruction::Idle),
|
||||||
Instruction::Resize(_,_)=>Some(PhysicsInputInstruction::Idle),
|
Instruction::Resize(_,_)=>Some(PhysicsInputInstruction::Idle),
|
||||||
Instruction::Render=>Some(PhysicsInputInstruction::Idle),
|
Instruction::Render=>Some(PhysicsInputInstruction::Idle),
|
||||||
}{
|
}{
|
||||||
@ -114,6 +118,15 @@ pub enum Instruction{
|
|||||||
Instruction::Resize(size,user_settings)=>{
|
Instruction::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(indexed_model_instances)=>{
|
||||||
|
physics.generate_models(&indexed_model_instances);
|
||||||
|
physics.spawn(indexed_model_instances.spawn_point);
|
||||||
|
graphics_worker.send(crate::graphics_worker::Instruction::GenerateModels(indexed_model_instances)).unwrap();
|
||||||
|
},
|
||||||
|
Instruction::ClearModels=>{
|
||||||
|
physics.clear();
|
||||||
|
graphics_worker.send(crate::graphics_worker::Instruction::ClearModels).unwrap();
|
||||||
|
},
|
||||||
_=>(),
|
_=>(),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -26,14 +26,11 @@ impl WindowContext<'_>{
|
|||||||
fn window_event(&mut self,time:crate::integer::Time,event: winit::event::WindowEvent) {
|
fn window_event(&mut self,time:crate::integer::Time,event: winit::event::WindowEvent) {
|
||||||
match event {
|
match event {
|
||||||
winit::event::WindowEvent::DroppedFile(path)=>{
|
winit::event::WindowEvent::DroppedFile(path)=>{
|
||||||
// let sender=self.sender.clone();//mpsc
|
//blocking because it's simpler...
|
||||||
// std::thread::spawn(move ||{
|
if let Some(indexed_model_instances)=crate::load_file(path){
|
||||||
// let indexed_model_instances=crate::load_file(path);
|
self.physics_thread.send(TimedInstruction{time,instruction:crate::physics_worker::Instruction::ClearModels}).unwrap();
|
||||||
// sender.send(Instruction::Die(indexed_model_instances));
|
self.physics_thread.send(TimedInstruction{time,instruction:crate::physics_worker::Instruction::GenerateModels(indexed_model_instances)}).unwrap();
|
||||||
// });
|
}
|
||||||
let indexed_model_instances=crate::load_file(path);
|
|
||||||
//self.physics=
|
|
||||||
println!("unimplemented");
|
|
||||||
},
|
},
|
||||||
winit::event::WindowEvent::Focused(state)=>{
|
winit::event::WindowEvent::Focused(state)=>{
|
||||||
//pause unpause
|
//pause unpause
|
||||||
|
Loading…
Reference in New Issue
Block a user