From 432a38718cc42546d4a5d71cb5a34e6beb439c7d Mon Sep 17 00:00:00 2001 From: Quaternions Date: Mon, 6 Nov 2023 16:11:41 -0800 Subject: [PATCH] fix slope divide by zero --- src/integer.rs | 6 ++++-- src/physics.rs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/integer.rs b/src/integer.rs index 46d2d67..ff16b84 100644 --- a/src/integer.rs +++ b/src/integer.rs @@ -653,8 +653,10 @@ impl Planar64Vec3{ )) } #[inline] - pub fn slope(&self,up:Self)->Planar64{ - self.dot(up)/self.cross(up).length() + pub fn slope_cmp(&self,slope:Planar64,up:Self)->bool{ + let y=self.dot(up); + let x=self.cross(up).length(); + yPlanar64{ diff --git a/src/physics.rs b/src/physics.rs index 3281baf..51084e5 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -1235,7 +1235,7 @@ impl crate::instruction::InstructionConsumer for PhysicsStat 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|self.models.mesh(model_id).face_nd(c.face_id().unwrap()).0.slope_cmp(s,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);