From ecd57a651905c54c2bddb8dcb64770da089e9ba5 Mon Sep 17 00:00:00 2001 From: Jan Nils Ferner Date: Thu, 26 Jan 2023 20:37:34 +0100 Subject: Cut off invalid values --- src/control/character_controller.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/control/character_controller.rs b/src/control/character_controller.rs index 91c5a98..fe355a4 100644 --- a/src/control/character_controller.rs +++ b/src/control/character_controller.rs @@ -271,11 +271,7 @@ impl KinematicCharacterController { println!("[stair] translation_remaining: {translation_remaining:?}"); // No slopes or stairs ahead; try to move along obstacles. - let allowed_translation: Vector = - self.split_into_components(&translation_remaining) - .map(|remaining| subtract_hit(remaining, &toi, offset)) - .into_iter() - .sum(); + let allowed_translation = subtract_hit(translation_remaining, &toi, offset); result.translation += allowed_translation; translation_remaining -= allowed_translation; @@ -740,5 +736,5 @@ impl KinematicCharacterController { } fn subtract_hit(translation: Vector, hit: &TOI, offset: Real) -> Vector { - translation - *hit.normal1 * (translation).dot(&hit.normal1) * (1.0 + offset) + translation - *hit.normal1 * ((translation).dot(&hit.normal1) * (1.0 + offset)).min(0.0) } -- cgit