aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Nils Ferner <contact@jnferner.com>2023-01-26 20:37:34 +0100
committerJan Nils Ferner <contact@jnferner.com>2023-01-26 20:37:34 +0100
commitecd57a651905c54c2bddb8dcb64770da089e9ba5 (patch)
treebead96f3a201676ee0804c42549cd5acede686c5 /src
parent83a9c08b2c1070bf93710cb8c01ceb371021f74e (diff)
downloadrapier-ecd57a651905c54c2bddb8dcb64770da089e9ba5.tar.gz
rapier-ecd57a651905c54c2bddb8dcb64770da089e9ba5.tar.bz2
rapier-ecd57a651905c54c2bddb8dcb64770da089e9ba5.zip
Cut off invalid values
Diffstat (limited to 'src')
-rw-r--r--src/control/character_controller.rs8
1 files 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<Real> =
- 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<Real>, hit: &TOI, offset: Real) -> Vector<Real> {
- translation - *hit.normal1 * (translation).dot(&hit.normal1) * (1.0 + offset)
+ translation - *hit.normal1 * ((translation).dot(&hit.normal1) * (1.0 + offset)).min(0.0)
}