diff --git a/src/graphics.rs b/src/graphics.rs index 46cda5b..3f15497 100644 --- a/src/graphics.rs +++ b/src/graphics.rs @@ -1,3 +1,18 @@ +use std::borrow::Cow; +use wgpu::{util::DeviceExt,AstcBlock,AstcChannel}; +use crate::model_graphics::{GraphicsVertex,ModelGraphicsInstance}; + +#[derive(Clone)] +pub struct ModelUpdate{ + transform:Option, + color:Option, +} + +#[derive(Clone)] +pub enum GraphicsInstruction{ + UpdateModel(ModelUpdate), + Render, +} struct Entity { index_count: u32, diff --git a/src/main.rs b/src/main.rs index 96cff95..4d44215 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,4 @@ -use std::{borrow::Cow, time::Instant}; -use wgpu::{util::DeviceExt, AstcBlock, AstcChannel}; -use model_graphics::{GraphicsVertex,ModelGraphicsInstance}; +use std::time::Instant; use physics::{InputInstruction, PhysicsInstruction}; use instruction::{TimedInstruction, InstructionConsumer}; @@ -23,10 +21,18 @@ mod load_roblox; pub struct GlobalState{ start_time: std::time::Instant, manual_mouse_lock:bool, - mouse:physics::MouseState, + mouse:std::sync::Arc>, user_settings:settings::UserSettings, - graphics:graphics::GraphicsState, - physics_thread:worker::CompatWorker,physics::PhysicsOutputState,Box)->physics::PhysicsOutputState>>, + //Ideally the graphics thread worker description is: + /* + WorkerDescription{ + input:Immediate, + output:Realtime(PoolOrdering::Ordered(3)), + } + */ + //up to three frames in flight, dropping new frame requests when all three are busy, and dropping output frames when one renders out of order + graphics_thread:worker::INWorker, + physics_thread:worker::QNWorker>, } impl framework::Example for GlobalState { diff --git a/src/physics.rs b/src/physics.rs index 347d280..ff9667d 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -736,11 +736,11 @@ impl PhysicsState { self.touching.clear(); } - pub fn into_worker(mut self)->crate::worker::CompatWorker,PhysicsOutputState,Box)->PhysicsOutputState>>{ + pub fn into_worker(mut self)->crate::worker::CNWorker>{ let mut mouse_blocking=true; let mut last_mouse_time=self.next_mouse.time; let mut timeline=std::collections::VecDeque::new(); - crate::worker::CompatWorker::new(self.output(),Box::new(move |ins:TimedInstruction|{ + crate::worker::CNWorker::new(move |ins:TimedInstruction|{ if if let Some(phys_input)=match ins.instruction{ InputInstruction::MoveMouse(m)=>{ if mouse_blocking{ @@ -819,8 +819,7 @@ impl PhysicsState { }); } } - self.output() - })) + }) } pub fn output(&self)->PhysicsOutputState{