diff --git a/src/body.rs b/src/body.rs index 24fdecad..f900da5f 100644 --- a/src/body.rs +++ b/src/body.rs @@ -8,7 +8,7 @@ pub struct Body { pub struct PhysicsState { pub body: Body, - //pub contacts: Vec, + pub contacts: Vec, pub time: TIME, pub strafe_tick_num: TIME, pub strafe_tick_den: TIME, @@ -21,6 +21,20 @@ pub struct PhysicsState { pub jump_trying: bool, } +pub struct RelativeCollision { + face: Face,//just an id + model: u32,//using id to avoid lifetimes +} + +impl RelativeCollision { + pub fn mesh(&self,models:&Vec) -> TreyMesh { + return models.get(self.model as usize).unwrap().face_mesh(self.face) + } + pub fn normal(&self,models:&Vec) -> glam::Vec3 { + return models.get(self.model as usize).unwrap().face_normal(self.face) + } +} + pub type TIME = i64; const CONTROL_JUMP:u32 = 0b01000000;//temp diff --git a/src/event.rs b/src/event.rs index d2260313..37fcf308 100644 --- a/src/event.rs +++ b/src/event.rs @@ -4,8 +4,8 @@ pub struct EventStruct { } pub enum EventEnum { - CollisionStart,//(Collideable),//Body::CollisionStart - CollisionEnd,//(Collideable),//Body::CollisionEnd + CollisionStart(crate::body::RelativeCollision),//Body::CollisionStart + CollisionEnd(crate::body::RelativeCollision),//Body::CollisionEnd StrafeTick, Jump, } diff --git a/src/main.rs b/src/main.rs index 59faf74b..8bba40c6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -307,6 +307,7 @@ impl strafe_client::framework::Example for Skybox { grounded: true, jump_trying: false, walkspeed: 18.0, + contacts: Vec::::new(), }; let camera_uniforms = camera.to_uniform_data(physics.extrapolate_position(0));