diff options
| author | Jan Hohenheim <jan@hohenheim.ch> | 2023-02-08 22:17:04 +0100 |
|---|---|---|
| committer | Jan Hohenheim <jan@hohenheim.ch> | 2023-02-08 22:17:04 +0100 |
| commit | 1b449fc31df6b9ecb8d339a5ff5fb2c1763a7978 (patch) | |
| tree | e1ab38443aeaafd031746c3aca5f90a8a7462b6e | |
| parent | 93d0e625c758a8429f1a1e56ea3b6f8f4982a017 (diff) | |
| download | rapier-1b449fc31df6b9ecb8d339a5ff5fb2c1763a7978.tar.gz rapier-1b449fc31df6b9ecb8d339a5ff5fb2c1763a7978.tar.bz2 rapier-1b449fc31df6b9ecb8d339a5ff5fb2c1763a7978.zip | |
Fix faulty snap distance
| -rw-r--r-- | src/control/character_controller.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/control/character_controller.rs b/src/control/character_controller.rs index 31f19c7..66d2d11 100644 --- a/src/control/character_controller.rs +++ b/src/control/character_controller.rs @@ -186,7 +186,6 @@ impl KinematicCharacterController { grounded: false, }; let dims = self.compute_dims(character_shape); - let offset = self.offset.eval(dims.y); // 1. Check and fix penetrations. self.check_and_fix_penetrations(); @@ -208,6 +207,7 @@ impl KinematicCharacterController { let mut max_iters = 20; let mut kinematic_friction_translation = Vector::zeros(); + let offset = self.offset.eval(dims.y); while let Some((translation_dir, translation_dist)) = UnitVector::try_new_and_get(translation_remaining, 1.0e-5) @@ -337,8 +337,7 @@ impl KinematicCharacterController { filter, ) { // Apply the snap. - let snap_distance = hit.toi - offset; - result.translation -= *self.up * snap_distance; + result.translation -= *self.up * (hit.toi - offset).max(0.0); result.grounded = true; return Some((hit_handle, hit)); } |
