diff options
| author | Jan Hohenheim <jan@hohenheim.ch> | 2023-02-05 02:52:50 +0100 |
|---|---|---|
| committer | Jan Hohenheim <jan@hohenheim.ch> | 2023-02-05 02:52:50 +0100 |
| commit | 93d0e625c758a8429f1a1e56ea3b6f8f4982a017 (patch) | |
| tree | 16e5cf28e849c75e339e0363ed182a56c8d862ae /src/control | |
| parent | fac561c902ec3d004d3f95df137beb3450231bc6 (diff) | |
| download | rapier-93d0e625c758a8429f1a1e56ea3b6f8f4982a017.tar.gz rapier-93d0e625c758a8429f1a1e56ea3b6f8f4982a017.tar.bz2 rapier-93d0e625c758a8429f1a1e56ea3b6f8f4982a017.zip | |
Simplify code
Diffstat (limited to 'src/control')
| -rw-r--r-- | src/control/character_controller.rs | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/control/character_controller.rs b/src/control/character_controller.rs index f7f7e2c..31f19c7 100644 --- a/src/control/character_controller.rs +++ b/src/control/character_controller.rs @@ -499,20 +499,16 @@ impl KinematicCharacterController { let angle_with_floor = self.up.angle(&hit.normal1); let climbing = self.up.dot(&slope_translation) >= 0.0; - climbing - .then(|| { - (angle_with_floor <= self.max_slope_climb_angle) // Are we allowed to climb? - .then_some(horizontal_translation) - }) - .unwrap_or_else(|| { - // Are we allowed to slide? - if angle_with_floor >= self.min_slope_slide_angle { - slope_translation - } else { - horizontal_translation - } - .into() - }) + if climbing { + // Are we allowed to climb? + (angle_with_floor <= self.max_slope_climb_angle).then_some(horizontal_translation) + } + // Are we allowed to slide? + else if angle_with_floor >= self.min_slope_slide_angle { + Some(slope_translation) + } else { + Some(horizontal_translation) + } } fn split_into_components(&self, translation: &Vector<Real>) -> [Vector<Real>; 2] { |
