diff --git a/src/integer.rs b/src/integer.rs index 744958c..9d8f9d6 100644 --- a/src/integer.rs +++ b/src/integer.rs @@ -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()}) diff --git a/src/physics.rs b/src/physics.rs index 5c4ca0c..8c17777 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -715,6 +715,12 @@ impl Collision{ |&Collision::Intersect(IntersectCollision{model_id})=>model_id, } } + fn face_id(&self)->Option{ + 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 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|sif self.style.surf_slope.map_or(true,|s|s