diff --git a/src/body.rs b/src/body.rs index 811165d..a370a86 100644 --- a/src/body.rs +++ b/src/body.rs @@ -91,7 +91,8 @@ impl MouseInterpolationState { pub struct PhysicsState { pub body: Body, pub hitbox_size: glam::Vec3, - pub contacts: Vec, + pub contacts: std::collections::HashSet::, + //pub intersections: Vec, //temp pub models_cringe_clone: Vec, pub temp_control_dir: glam::Vec3, @@ -111,7 +112,7 @@ pub struct PhysicsState { pub jump_trying: bool, } -#[derive(Clone,Copy)] +#[derive(Clone,Copy,Hash,Eq,PartialEq)] pub enum AabbFace{ Right,//+X Top, @@ -256,6 +257,8 @@ impl Model { } //need non-face (full model) variant for CanCollide false objects +//OR have a separate list from contacts for model intersection +#[derive(Eq, Hash, PartialEq)] pub struct RelativeCollision { face: TreyMeshFace,//just an id model: u32,//using id to avoid lifetimes @@ -651,6 +654,7 @@ impl crate::instruction::InstructionConsumer for PhysicsStat }, _ => (), } + self.contacts.insert(c); }, PhysicsInstruction::CollisionEnd(c) => { //check ground @@ -661,6 +665,7 @@ impl crate::instruction::InstructionConsumer for PhysicsStat }, _ => (), } + self.contacts.remove(&c); }, PhysicsInstruction::StrafeTick => { //let control_dir=self.get_control_dir();//this should respect your mouse interpolation settings diff --git a/src/main.rs b/src/main.rs index 9873075..211ebbb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -304,7 +304,7 @@ impl strafe_client::framework::Example for Skybox { jump_trying: false, temp_control_dir: glam::Vec3::ZERO, walkspeed: 18.0, - contacts: Vec::::new(), + contacts: std::collections::HashSet::new(), models_cringe_clone: modeldatas.iter().map(|m|strafe_client::body::Model::new(m.transform)).collect(), walk_target_velocity: glam::Vec3::ZERO, hitbox_size: glam::vec3(2.0,5.0,2.0),