aboutsummaryrefslogtreecommitdiff
path: root/src/control
diff options
context:
space:
mode:
authorJan Nils Ferner <contact@jnferner.com>2023-01-27 15:08:41 +0100
committerJan Nils Ferner <contact@jnferner.com>2023-01-27 15:08:41 +0100
commit247ed510b4fa08195fd54bf8736194a8d168783b (patch)
treed3076dbe570fa3ff59e62f737c8cc2cf0bc49aef /src/control
parent7bfa593d3f370afc0fe2f9680d99fa4c7bc0cee1 (diff)
downloadrapier-247ed510b4fa08195fd54bf8736194a8d168783b.tar.gz
rapier-247ed510b4fa08195fd54bf8736194a8d168783b.tar.bz2
rapier-247ed510b4fa08195fd54bf8736194a8d168783b.zip
Fix horizontal offset not being respected
Diffstat (limited to 'src/control')
-rw-r--r--src/control/character_controller.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/control/character_controller.rs b/src/control/character_controller.rs
index ec0e04e..06e7ff0 100644
--- a/src/control/character_controller.rs
+++ b/src/control/character_controller.rs
@@ -228,13 +228,13 @@ impl KinematicCharacterController {
&(Translation::from(result.translation) * character_pos),
&translation_dir,
character_shape,
- translation_dist - offset,
+ translation_dist,
false,
filter,
) {
// We hit something, compute the allowed self.
let allowed_dist =
- (toi.toi - (-toi.normal1.dot(&translation_dir)) * offset).max(0.0);
+ toi.toi - (toi.normal1.dot(&translation_dir)).abs() * offset;
let allowed_translation = *translation_dir * allowed_dist;
result.translation += allowed_translation;
translation_remaining -= allowed_translation;
@@ -337,7 +337,7 @@ impl KinematicCharacterController {
&-self.up,
character_shape,
snap_distance,
- true,
+ false,
filter,
) {
// Apply the snap.
@@ -738,6 +738,7 @@ impl KinematicCharacterController {
}
fn subtract_hit(translation: Vector<Real>, hit: &TOI, offset: Real) -> Vector<Real> {
- let surface_correction = translation.dot(&hit.normal1) * (1.0 + offset);
- translation - *hit.normal1 * surface_correction
+ let surface_correction = translation.dot(&hit.normal1).abs();
+ let surface_correction = surface_correction + offset;
+ translation + *hit.normal1 * surface_correction
}