diff --git a/src/instruction.rs b/src/instruction.rs index ece33d3..3508b93 100644 --- a/src/instruction.rs +++ b/src/instruction.rs @@ -1,11 +1,11 @@ #[derive(Debug)] pub struct TimedInstruction { - pub time: crate::body::TIME, + pub time: crate::physics::TIME, pub instruction: I, } pub trait InstructionEmitter { - fn next_instruction(&self, time_limit:crate::body::TIME) -> Option>; + fn next_instruction(&self, time_limit:crate::physics::TIME) -> Option>; } pub trait InstructionConsumer { fn process_instruction(&mut self, instruction:TimedInstruction); @@ -13,11 +13,11 @@ pub trait InstructionConsumer { //PROPER PRIVATE FIELDS!!! pub struct InstructionCollector { - time: crate::body::TIME, + time: crate::physics::TIME, instruction: Option, } impl InstructionCollector { - pub fn new(time:crate::body::TIME) -> Self { + pub fn new(time:crate::physics::TIME) -> Self { Self{ time, instruction:None diff --git a/src/main.rs b/src/main.rs index c69e46d..53c14e2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,17 +1,17 @@ use std::{borrow::Cow, time::Instant}; use wgpu::{util::DeviceExt, AstcBlock, AstcChannel}; use model::{Vertex,ModelInstance,ModelGraphicsInstance}; -use body::{InputInstruction, PhysicsInstruction}; +use physics::{InputInstruction, PhysicsInstruction}; use instruction::{TimedInstruction, InstructionConsumer}; -mod body; mod model; mod zeroes; +mod worker; +mod physics; mod framework; mod primitives; mod instruction; mod load_roblox; -mod worker; struct Entity { index_count: u32, @@ -67,7 +67,7 @@ pub struct GlobalState{ start_time: std::time::Instant, manual_mouse_lock:bool, graphics:GraphicsState, - physics:body::PhysicsState, + physics:physics::PhysicsState, } impl GlobalState{ @@ -103,7 +103,7 @@ impl GlobalState{ for model in &indexed_models.models{ //make aabb and run vertices to get realistic bounds for model_instance in &model.instances{ - if let Some(model_physics)=body::ModelPhysics::from_model(model,model_instance){ + if let Some(model_physics)=physics::ModelPhysics::from_model(model,model_instance){ let model_id=self.physics.models.len() as u32; self.physics.models.push(model_physics); for attr in &model_instance.temp_indexing{ @@ -408,7 +408,7 @@ fn get_instances_buffer_data(instances:&[ModelGraphicsInstance]) -> Vec { raw } -fn to_uniform_data(camera: &body::Camera, pos: glam::Vec3) -> [f32; 16 * 3 + 4] { +fn to_uniform_data(camera: &physics::Camera, pos: glam::Vec3) -> [f32; 16 * 3 + 4] { let proj=camera.proj(); let proj_inv = proj.inverse(); let view=camera.view(pos); @@ -582,21 +582,21 @@ impl framework::Example for GlobalState { source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("shader.wgsl"))), }); - let physics = body::PhysicsState { + let physics = physics::PhysicsState { spawn_point:glam::vec3(0.0,50.0,0.0), - body: body::Body::with_pva(glam::vec3(0.0,50.0,0.0),glam::vec3(0.0,0.0,0.0),glam::vec3(0.0,-100.0,0.0)), + body: physics::Body::with_pva(glam::vec3(0.0,50.0,0.0),glam::vec3(0.0,0.0,0.0),glam::vec3(0.0,-100.0,0.0)), time: 0, - style:body::StyleModifiers::default(), + style:physics::StyleModifiers::default(), grounded: false, contacts: std::collections::HashMap::new(), intersects: std::collections::HashMap::new(), models: Vec::new(), - walk: body::WalkState::new(), - camera: body::Camera::from_offset(glam::vec3(0.0,4.5-2.5,0.0),(config.width as f32)/(config.height as f32)), - mouse_interpolation: body::MouseInterpolationState::new(), + walk: physics::WalkState::new(), + camera: physics::Camera::from_offset(glam::vec3(0.0,4.5-2.5,0.0),(config.width as f32)/(config.height as f32)), + mouse_interpolation: physics::MouseInterpolationState::new(), controls: 0, - world:body::WorldState{}, - game:body::GameMechanicsState::default(), + world:physics::WorldState{}, + game:physics::GameMechanicsState::default(), modes:Vec::new(), mode_from_mode_id:std::collections::HashMap::new(), }; @@ -921,7 +921,7 @@ impl framework::Example for GlobalState { let time=self.physics.time; instruction::InstructionConsumer::process_instruction(&mut self.physics, instruction::TimedInstruction{ time, - instruction: body::PhysicsInstruction::Input(body::InputInstruction::Reset), + instruction: PhysicsInstruction::Input(InputInstruction::Reset), }); }else{ println!("No modeldatas were generated"); diff --git a/src/body.rs b/src/physics.rs similarity index 100% rename from src/body.rs rename to src/physics.rs diff --git a/src/worker.rs b/src/worker.rs index 2e457cf..a28b77b 100644 --- a/src/worker.rs +++ b/src/worker.rs @@ -51,15 +51,15 @@ impl Worker { fn test_worker() { println!("hiiiii"); // Create the worker thread - let worker = Worker::new(crate::body::Body::with_pva(glam::Vec3::ZERO,glam::Vec3::ZERO,glam::Vec3::ZERO), - |_|crate::body::Body::with_pva(glam::Vec3::ONE,glam::Vec3::ONE,glam::Vec3::ONE) + let worker = Worker::new(crate::physics::Body::with_pva(glam::Vec3::ZERO,glam::Vec3::ZERO,glam::Vec3::ZERO), + |_|crate::physics::Body::with_pva(glam::Vec3::ONE,glam::Vec3::ONE,glam::Vec3::ONE) ); // Send tasks to the worker for i in 0..5 { let task = crate::instruction::TimedInstruction{ time:0, - instruction:crate::body::PhysicsInstruction::StrafeTick, + instruction:crate::physics::PhysicsInstruction::StrafeTick, }; worker.send(task).unwrap(); } @@ -73,7 +73,7 @@ fn test_worker() { // Send a new task let task = crate::instruction::TimedInstruction{ time:0, - instruction:crate::body::PhysicsInstruction::StrafeTick, + instruction:crate::physics::PhysicsInstruction::StrafeTick, }; worker.send(task).unwrap();