tape up last stragglers

This commit is contained in:
Quaternions 2023-11-03 18:18:40 -07:00
parent d9be4b8105
commit a53d90f74b
2 changed files with 12 additions and 2 deletions

View File

@ -653,6 +653,10 @@ impl Planar64Vec3{
))
}
#[inline]
pub fn slope(&self,up:Self)->Planar64{
self.dot(up)/self.cross(up).length()
}
#[inline]
pub fn length(&self)->Planar64{
let radicand=(self.0.x as i128)*(self.0.x as i128)+(self.0.y as i128)*(self.0.y as i128)+(self.0.z as i128)*(self.0.z as i128);
Planar64(unsafe{(radicand as f64).sqrt().to_int_unchecked()})

View File

@ -715,6 +715,12 @@ impl Collision{
|&Collision::Intersect(IntersectCollision{model_id})=>model_id,
}
}
fn face_id(&self)->Option<crate::model_physics::FaceId>{
match self{
&Collision::Contact(ContactCollision{model_id:_,face_id})=>Some(face_id),
&Collision::Intersect(IntersectCollision{model_id:_})=>None,
}
}
}
#[derive(Default)]
struct TouchingState{
@ -1225,12 +1231,12 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
//ladder walkstate
let mut target_velocity=self.style.get_ladder_target_velocity(&self.camera,self.controls,&self.next_mouse,self.time);
self.touching.constrain_velocity(&self.models,&mut target_velocity);
let (walk_state,mut a)=WalkState::ladder(&self.touching,&self.body,&self.style,&self.models,target_velocity,&self.models.mesh(c.model_id).face_nd(c.face_id).0);
let (walk_state,mut a)=WalkState::ladder(&self.touching,&self.body,&self.style,&self.models,target_velocity,&self.models.mesh(model_id).face_nd(c.face_id().unwrap()).0);
self.move_state=MoveState::Ladder(walk_state);
self.touching.constrain_acceleration(&self.models,&mut a);
self.body.acceleration=a;
}
None=>if self.style.surf_slope.map_or(true,|s|s<self.models.mesh(model_id).face_nd(c.face_id).0.slope(up)){
None=>if self.style.surf_slope.map_or(true,|s|s<self.models.mesh(model_id).face_nd(c.face_id().unwrap()).0.slope(Planar64Vec3::Y)){
//ground
let mut target_velocity=self.style.get_walk_target_velocity(&self.camera,self.controls,&self.next_mouse,self.time);
self.touching.constrain_velocity(&self.models,&mut target_velocity);