forked from StrafesNET/strafe-client
use hashset for contacts
This commit is contained in:
parent
2d0e80323b
commit
4978341b5b
@ -91,7 +91,8 @@ impl MouseInterpolationState {
|
|||||||
pub struct PhysicsState {
|
pub struct PhysicsState {
|
||||||
pub body: Body,
|
pub body: Body,
|
||||||
pub hitbox_size: glam::Vec3,
|
pub hitbox_size: glam::Vec3,
|
||||||
pub contacts: Vec<RelativeCollision>,
|
pub contacts: std::collections::HashSet::<RelativeCollision>,
|
||||||
|
//pub intersections: Vec<ModelId>,
|
||||||
//temp
|
//temp
|
||||||
pub models_cringe_clone: Vec<Model>,
|
pub models_cringe_clone: Vec<Model>,
|
||||||
pub temp_control_dir: glam::Vec3,
|
pub temp_control_dir: glam::Vec3,
|
||||||
@ -111,7 +112,7 @@ pub struct PhysicsState {
|
|||||||
pub jump_trying: bool,
|
pub jump_trying: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone,Copy)]
|
#[derive(Clone,Copy,Hash,Eq,PartialEq)]
|
||||||
pub enum AabbFace{
|
pub enum AabbFace{
|
||||||
Right,//+X
|
Right,//+X
|
||||||
Top,
|
Top,
|
||||||
@ -256,6 +257,8 @@ impl Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//need non-face (full model) variant for CanCollide false objects
|
//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 {
|
pub struct RelativeCollision {
|
||||||
face: TreyMeshFace,//just an id
|
face: TreyMeshFace,//just an id
|
||||||
model: u32,//using id to avoid lifetimes
|
model: u32,//using id to avoid lifetimes
|
||||||
@ -651,6 +654,7 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
|||||||
},
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
self.contacts.insert(c);
|
||||||
},
|
},
|
||||||
PhysicsInstruction::CollisionEnd(c) => {
|
PhysicsInstruction::CollisionEnd(c) => {
|
||||||
//check ground
|
//check ground
|
||||||
@ -661,6 +665,7 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
|||||||
},
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
self.contacts.remove(&c);
|
||||||
},
|
},
|
||||||
PhysicsInstruction::StrafeTick => {
|
PhysicsInstruction::StrafeTick => {
|
||||||
//let control_dir=self.get_control_dir();//this should respect your mouse interpolation settings
|
//let control_dir=self.get_control_dir();//this should respect your mouse interpolation settings
|
||||||
|
@ -304,7 +304,7 @@ impl strafe_client::framework::Example for Skybox {
|
|||||||
jump_trying: false,
|
jump_trying: false,
|
||||||
temp_control_dir: glam::Vec3::ZERO,
|
temp_control_dir: glam::Vec3::ZERO,
|
||||||
walkspeed: 18.0,
|
walkspeed: 18.0,
|
||||||
contacts: Vec::<strafe_client::body::RelativeCollision>::new(),
|
contacts: std::collections::HashSet::new(),
|
||||||
models_cringe_clone: modeldatas.iter().map(|m|strafe_client::body::Model::new(m.transform)).collect(),
|
models_cringe_clone: modeldatas.iter().map(|m|strafe_client::body::Model::new(m.transform)).collect(),
|
||||||
walk_target_velocity: glam::Vec3::ZERO,
|
walk_target_velocity: glam::Vec3::ZERO,
|
||||||
hitbox_size: glam::vec3(2.0,5.0,2.0),
|
hitbox_size: glam::vec3(2.0,5.0,2.0),
|
||||||
|
Loading…
Reference in New Issue
Block a user