Skip to content

Commit ea19166

Browse files
committed
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.
1 parent 2e929bb commit ea19166

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/control/character_controller.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ impl KinematicCharacterController {
195195
self.check_and_fix_penetrations();
196196

197197
let mut translation_remaining = desired_translation;
198+
let mut translation_before = result.translation;
198199

199200
// Check if we are grounded at the initial position.
200201
let grounded_at_starting_pos = self.detect_grounded_status_and_apply_friction(
@@ -290,6 +291,11 @@ impl KinematicCharacterController {
290291
Some(&mut translation_remaining),
291292
);
292293

294+
if (translation_before - result.translation).norm_squared() < 1e-10 {
295+
break;
296+
}
297+
translation_before = result.translation;
298+
293299
if !self.slide {
294300
break;
295301
}

0 commit comments

Comments
 (0)