From ea191663c7894aea00e9dc93bc990da9b2220c5d Mon Sep 17 00:00:00 2001 From: Piero V Date: Sun, 4 Dec 2022 21:25:28 +0100 Subject: [PATCH] KCC::move_shape early break in case of no update. If no movements are performed in an iteration of move_shape, early break, instead of trying to repeat it again. --- src/control/character_controller.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/control/character_controller.rs b/src/control/character_controller.rs index 3972adc2..7654d4ff 100644 --- a/src/control/character_controller.rs +++ b/src/control/character_controller.rs @@ -195,6 +195,7 @@ impl KinematicCharacterController { self.check_and_fix_penetrations(); let mut translation_remaining = desired_translation; + let mut translation_before = result.translation; // Check if we are grounded at the initial position. let grounded_at_starting_pos = self.detect_grounded_status_and_apply_friction( @@ -290,6 +291,11 @@ impl KinematicCharacterController { Some(&mut translation_remaining), ); + if (translation_before - result.translation).norm_squared() < 1e-10 { + break; + } + translation_before = result.translation; + if !self.slide { break; }