From 83a9c08b2c1070bf93710cb8c01ceb371021f74e Mon Sep 17 00:00:00 2001 From: Jan Nils Ferner Date: Thu, 26 Jan 2023 20:32:03 +0100 Subject: Apply translation left --- src/control/character_controller.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/control/character_controller.rs b/src/control/character_controller.rs index 9888701..91c5a98 100644 --- a/src/control/character_controller.rs +++ b/src/control/character_controller.rs @@ -271,13 +271,12 @@ impl KinematicCharacterController { println!("[stair] translation_remaining: {translation_remaining:?}"); // No slopes or stairs ahead; try to move along obstacles. - let [vertical_slope_translation, horizontal_slope_translation] = + let allowed_translation: Vector = self.split_into_components(&translation_remaining) - .map(|remaining| subtract_hit(remaining, &toi, offset)); + .map(|remaining| subtract_hit(remaining, &toi, offset)) + .into_iter() + .sum(); - let horizontal_allowed_dist = - (toi.toi - (-toi.normal1.dot(&translation_dir)) * offset).max(0.0); - let allowed_translation = *translation_dir * allowed_dist; result.translation += allowed_translation; translation_remaining -= allowed_translation; -- cgit