diff options
| author | Jan Hohenheim <jan@hohenheim.ch> | 2023-02-04 19:55:05 +0100 |
|---|---|---|
| committer | Jan Hohenheim <jan@hohenheim.ch> | 2023-02-04 19:55:05 +0100 |
| commit | 7a2759c52feae6379da51fbf44584ea2c0b76c0c (patch) | |
| tree | 8e0db538d593a20aa98ee1f607064e4f09cba023 /src/control | |
| parent | b461d028df09f8715646ca476e30693121777f31 (diff) | |
| download | rapier-7a2759c52feae6379da51fbf44584ea2c0b76c0c.tar.gz rapier-7a2759c52feae6379da51fbf44584ea2c0b76c0c.tar.bz2 rapier-7a2759c52feae6379da51fbf44584ea2c0b76c0c.zip | |
Revert grounded checks to not be grounded by default again
Diffstat (limited to 'src/control')
| -rw-r--r-- | src/control/character_controller.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/control/character_controller.rs b/src/control/character_controller.rs index 5812d2e..5467a4a 100644 --- a/src/control/character_controller.rs +++ b/src/control/character_controller.rs @@ -376,7 +376,7 @@ impl KinematicCharacterController { .compute_aabb(character_pos) .loosened(prediction); - let mut grounded = true; + let mut grounded = false; queries.colliders_with_aabb_intersecting_aabb(&character_aabb, |handle| { if let Some(collider) = colliders.get(*handle) { @@ -404,9 +404,10 @@ impl KinematicCharacterController { for m in &manifolds { let normal = -(character_pos * m.local_n1); - if normal.dot(&self.up) <= 1.0e-5 { - grounded = false; + if normal.dot(&self.up) >= -1.0e-5 { + grounded = true; } + if let Some(kinematic_parent) = kinematic_parent { let mut num_active_contacts = 0; let mut manifold_center = Point::origin(); @@ -451,9 +452,13 @@ impl KinematicCharacterController { for m in &manifolds { let normal = character_pos * m.local_n1; - if normal.dot(&self.up) >= -1.0e-5 { - grounded = false; - return false; // We can stop the search early. + if normal.dot(&self.up) <= 1.0e-5 { + for contact in &m.points { + if contact.dist <= prediction { + grounded = true; + return false; // We can stop the search early. + } + } } } } |
