From 9fe64b445b0d264b7c8e7eab60e0a7619eb6d0d4 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Mon, 15 Mar 2021 20:28:48 +0000 Subject: [PATCH] Fixed incorrect velocity snapping on collision --- common/sys/src/phys.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/common/sys/src/phys.rs b/common/sys/src/phys.rs index 9a6dd22748..a1b18cd3af 100644 --- a/common/sys/src/phys.rs +++ b/common/sys/src/phys.rs @@ -1059,13 +1059,12 @@ fn box_voxel_collision<'a, T: BaseVol + ReadVol>( break; } else { // Correct the velocity - vel.0 = vel.0.map2(resolve_dir, |e, d| { - if d * e.signum() < 0.0 { - if d < 0.0 { d.min(0.0) } else { d.max(0.0) } - } else { - e - } - }); + vel.0 = vel.0.map2( + resolve_dir, + |e, d| { + if d * e.signum() < 0.0 { 0.0 } else { e } + }, + ); pos_delta *= resolve_dir.map(|e| if e != 0.0 { 0.0 } else { 1.0 }); }