forked from StrafesNET/strafe-client
RelativeCollision concept
This commit is contained in:
parent
e6862b5bad
commit
f11742ef3b
16
src/body.rs
16
src/body.rs
@ -8,7 +8,7 @@ pub struct Body {
|
|||||||
|
|
||||||
pub struct PhysicsState {
|
pub struct PhysicsState {
|
||||||
pub body: Body,
|
pub body: Body,
|
||||||
//pub contacts: Vec<RelativeCollision>,
|
pub contacts: Vec<RelativeCollision>,
|
||||||
pub time: TIME,
|
pub time: TIME,
|
||||||
pub strafe_tick_num: TIME,
|
pub strafe_tick_num: TIME,
|
||||||
pub strafe_tick_den: TIME,
|
pub strafe_tick_den: TIME,
|
||||||
@ -21,6 +21,20 @@ pub struct PhysicsState {
|
|||||||
pub jump_trying: bool,
|
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<Model>) -> TreyMesh {
|
||||||
|
return models.get(self.model as usize).unwrap().face_mesh(self.face)
|
||||||
|
}
|
||||||
|
pub fn normal(&self,models:&Vec<Model>) -> glam::Vec3 {
|
||||||
|
return models.get(self.model as usize).unwrap().face_normal(self.face)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub type TIME = i64;
|
pub type TIME = i64;
|
||||||
|
|
||||||
const CONTROL_JUMP:u32 = 0b01000000;//temp
|
const CONTROL_JUMP:u32 = 0b01000000;//temp
|
||||||
|
@ -4,8 +4,8 @@ pub struct EventStruct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub enum EventEnum {
|
pub enum EventEnum {
|
||||||
CollisionStart,//(Collideable),//Body::CollisionStart
|
CollisionStart(crate::body::RelativeCollision),//Body::CollisionStart
|
||||||
CollisionEnd,//(Collideable),//Body::CollisionEnd
|
CollisionEnd(crate::body::RelativeCollision),//Body::CollisionEnd
|
||||||
StrafeTick,
|
StrafeTick,
|
||||||
Jump,
|
Jump,
|
||||||
}
|
}
|
||||||
|
@ -307,6 +307,7 @@ impl strafe_client::framework::Example for Skybox {
|
|||||||
grounded: true,
|
grounded: true,
|
||||||
jump_trying: false,
|
jump_trying: false,
|
||||||
walkspeed: 18.0,
|
walkspeed: 18.0,
|
||||||
|
contacts: Vec::<crate::body::RelativeCollision>::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let camera_uniforms = camera.to_uniform_data(physics.extrapolate_position(0));
|
let camera_uniforms = camera.to_uniform_data(physics.extrapolate_position(0));
|
||||||
|
Loading…
Reference in New Issue
Block a user