From ff54a034874b549100e5af6f59a5e43fe613ce31 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 8 Sep 2023 16:14:01 -0700 Subject: [PATCH] happy compiler happy programmer --- src/body.rs | 23 +++++++++++++---------- src/main.rs | 4 ++-- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/body.rs b/src/body.rs index 1f5dd196..74a9f430 100644 --- a/src/body.rs +++ b/src/body.rs @@ -23,7 +23,7 @@ pub struct PhysicsState { } #[derive(Clone,Copy)] -enum AabbFace{ +pub enum AabbFace{ Right,//+X Top, Back, @@ -32,7 +32,7 @@ enum AabbFace{ Front, } -struct Aabb { +pub struct Aabb { min: glam::Vec3, max: glam::Vec3, } @@ -46,37 +46,37 @@ impl Aabb { // [0.0f32, 1., 0.], // [0.0f32, -1., 0.], // ]; - const VERTEX_DATA_RIGHT: &'static [glam::Vec3; 4] = &[ + const VERTEX_DATA_RIGHT: [glam::Vec3; 4] = [ glam::vec3(1., -1., -1.), glam::vec3(1., 1., -1.), glam::vec3(1., 1., 1.), glam::vec3(1., -1., 1.), ]; - const VERTEX_DATA_TOP: &'static [glam::Vec3; 4] = &[ + const VERTEX_DATA_TOP: [glam::Vec3; 4] = [ glam::vec3(1., 1., -1.), glam::vec3(-1., 1., -1.), glam::vec3(-1., 1., 1.), glam::vec3(1., 1., 1.), ]; - const VERTEX_DATA_BACK: &'static [glam::Vec3; 4] = &[ + const VERTEX_DATA_BACK: [glam::Vec3; 4] = [ glam::vec3(-1., -1., 1.), glam::vec3(1., -1., 1.), glam::vec3(1., 1., 1.), glam::vec3(-1., 1., 1.), ]; - const VERTEX_DATA_LEFT: &'static [glam::Vec3; 4] = &[ + const VERTEX_DATA_LEFT: [glam::Vec3; 4] = [ glam::vec3(-1., -1., 1.), glam::vec3(-1., 1., 1.), glam::vec3(-1., 1., -1.), glam::vec3(-1., -1., -1.), ]; - const VERTEX_DATA_BOTTOM: &'static [glam::Vec3; 4] = &[ + const VERTEX_DATA_BOTTOM: [glam::Vec3; 4] = [ glam::vec3(1., -1., 1.), glam::vec3(-1., -1., 1.), glam::vec3(-1., -1., -1.), glam::vec3(1., -1., -1.), ]; - const VERTEX_DATA_FRONT: &'static [glam::Vec3; 4] = &[ + const VERTEX_DATA_FRONT: [glam::Vec3; 4] = [ glam::vec3(-1., 1., -1.), glam::vec3(1., 1., -1.), glam::vec3(1., -1., -1.), @@ -102,7 +102,7 @@ impl Aabb { AabbFace::Front => glam::vec3(0.,0.,-1.), } } - pub fn face_vertices(face:AabbFace) -> &'static [glam::Vec3;4] { + pub fn face_vertices(face:AabbFace) -> [glam::Vec3;4] { match face { AabbFace::Right => Self::VERTEX_DATA_RIGHT, AabbFace::Top => Self::VERTEX_DATA_TOP, @@ -124,7 +124,10 @@ pub struct Model { } impl Model { - pub fn face_vertices(&self,face:Face) -> &'static [glam::Vec3;4] { + pub fn new(transform:glam::Mat4) -> Self { + Self{transform} + } + pub fn face_vertices(&self,face:Face) -> [glam::Vec3;4] { Aabb::face_vertices(face) } pub fn face_mesh(&self,face:Face) -> TreyMesh { diff --git a/src/main.rs b/src/main.rs index 652a04fa..d1c9d650 100644 --- a/src/main.rs +++ b/src/main.rs @@ -307,8 +307,8 @@ impl strafe_client::framework::Example for Skybox { grounded: true, jump_trying: false, walkspeed: 18.0, - contacts: Vec::::new(), - models_cringe_clone: modeldatas.iter().map(|m|crate::body::Model{transform:m.transform}), + contacts: Vec::::new(), + models_cringe_clone: modeldatas.iter().map(|m|strafe_client::body::Model::new(m.transform)).collect(), }; let camera_uniforms = camera.to_uniform_data(physics.extrapolate_position(0));