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{
|
||||
Render(crate::physics::PhysicsOutputState,crate::integer::Time,glam::IVec2),
|
||||
//UpdateModel(crate::graphics::ModelUpdate),
|
||||
Resize(winit::dpi::PhysicalSize<u32>,crate::settings::UserSettings),
|
||||
GenerateModels(crate::model::IndexedModelInstances),
|
||||
ClearModels,
|
||||
}
|
||||
|
||||
//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::new(move |ins:Instruction|{
|
||||
match ins{
|
||||
Instruction::GenerateModels(indexed_model_instances)=>{
|
||||
graphics.generate_models(&device,&queue,indexed_model_instances);
|
||||
},
|
||||
Instruction::ClearModels=>{
|
||||
graphics.clear();
|
||||
},
|
||||
Instruction::Resize(size,user_settings)=>{
|
||||
println!("Resizing to {:?}",size);
|
||||
config.width=size.width.max(1);
|
||||
|
@ -734,6 +734,7 @@ impl PhysicsState {
|
||||
self.models.clear();
|
||||
self.modes.clear();
|
||||
self.touching.clear();
|
||||
self.bvh=crate::bvh::BvhNode::default();
|
||||
}
|
||||
|
||||
pub fn output(&self)->PhysicsOutputState{
|
||||
|
@ -18,6 +18,8 @@ pub enum Instruction{
|
||||
Input(InputInstruction),
|
||||
Render,
|
||||
Resize(winit::dpi::PhysicalSize<u32>,crate::settings::UserSettings),
|
||||
GenerateModels(crate::model::IndexedModelInstances),
|
||||
ClearModels,
|
||||
//Graphics(crate::graphics_worker::Instruction),
|
||||
}
|
||||
|
||||
@ -61,6 +63,8 @@ pub enum Instruction{
|
||||
&InputInstruction::Zoom(s)=>Some(PhysicsInputInstruction::SetZoom(s)),
|
||||
InputInstruction::Reset=>Some(PhysicsInputInstruction::Reset),
|
||||
},
|
||||
Instruction::GenerateModels(_)=>Some(PhysicsInputInstruction::Idle),
|
||||
Instruction::ClearModels=>Some(PhysicsInputInstruction::Idle),
|
||||
Instruction::Resize(_,_)=>Some(PhysicsInputInstruction::Idle),
|
||||
Instruction::Render=>Some(PhysicsInputInstruction::Idle),
|
||||
}{
|
||||
@ -114,6 +118,15 @@ pub enum Instruction{
|
||||
Instruction::Resize(size,user_settings)=>{
|
||||
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) {
|
||||
match event {
|
||||
winit::event::WindowEvent::DroppedFile(path)=>{
|
||||
// let sender=self.sender.clone();//mpsc
|
||||
// std::thread::spawn(move ||{
|
||||
// let indexed_model_instances=crate::load_file(path);
|
||||
// sender.send(Instruction::Die(indexed_model_instances));
|
||||
// });
|
||||
let indexed_model_instances=crate::load_file(path);
|
||||
//self.physics=
|
||||
println!("unimplemented");
|
||||
//blocking because it's simpler...
|
||||
if let Some(indexed_model_instances)=crate::load_file(path){
|
||||
self.physics_thread.send(TimedInstruction{time,instruction:crate::physics_worker::Instruction::ClearModels}).unwrap();
|
||||
self.physics_thread.send(TimedInstruction{time,instruction:crate::physics_worker::Instruction::GenerateModels(indexed_model_instances)}).unwrap();
|
||||
}
|
||||
},
|
||||
winit::event::WindowEvent::Focused(state)=>{
|
||||
//pause unpause
|
||||
|
Loading…
Reference in New Issue
Block a user