aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Nils Ferner <contact@jnferner.com>2023-01-26 21:21:09 +0100
committerJan Nils Ferner <contact@jnferner.com>2023-01-26 21:21:09 +0100
commit3cabe58ac650fa6054af761ba59329d4d00d1154 (patch)
tree2f2e6c351559c6ab846ae9cf9c9c37a11de2f5c2 /src
parent6701108f6f0f8b2543c503958a5d93cc1b91d71f (diff)
downloadrapier-3cabe58ac650fa6054af761ba59329d4d00d1154.tar.gz
rapier-3cabe58ac650fa6054af761ba59329d4d00d1154.tar.bz2
rapier-3cabe58ac650fa6054af761ba59329d4d00d1154.zip
Remove debug prints
Diffstat (limited to 'src')
-rw-r--r--src/control/character_controller.rs64
1 files changed, 26 insertions, 38 deletions
diff --git a/src/control/character_controller.rs b/src/control/character_controller.rs
index e16ca39..2aec8a7 100644
--- a/src/control/character_controller.rs
+++ b/src/control/character_controller.rs
@@ -247,42 +247,32 @@ impl KinematicCharacterController {
toi,
});
- // If the slope is too big, try to step on the stair.
- if !self.handle_stairs(
- bodies,
- colliders,
- queries,
- character_shape,
- &(Translation::from(result.translation) * character_pos),
- &dims,
- filter,
- handle,
- &mut translation_remaining,
- &mut result,
- &self.up
- ) && !self.handle_stairs(
- bodies,
- colliders,
- queries,
- character_shape,
- &(Translation::from(result.translation) * character_pos),
- &dims,
- filter,
- handle,
- &mut translation_remaining,
- &mut result,
- &-self.up
- ){
- if let Some(translation_on_slope) =
- self.handle_slopes(&toi, &mut translation_remaining, offset)
- {
- translation_remaining = translation_on_slope;
- } else {
- // No slopes or stairs ahead; try to move along obstacles.
- let allowed_translation = subtract_hit(translation_remaining, &toi, offset);
- result.translation += allowed_translation;
- translation_remaining -= allowed_translation;
- }
+ if ![self.up, -self.up] // Try to move up or down stairs
+ .iter()
+ .any(|up| self.handle_stairs(
+ bodies,
+ colliders,
+ queries,
+ character_shape,
+ &(Translation::from(result.translation) * character_pos),
+ &dims,
+ filter,
+ handle,
+ &mut translation_remaining,
+ &mut result,
+ up
+ )) {
+ // No stairs, try to move along slopes.
+ if let Some(translation_on_slope) =
+ self.handle_slopes(&toi, &mut translation_remaining, offset)
+ {
+ translation_remaining = translation_on_slope;
+ } else {
+ // No slopes or stairs ahead; try to move along obstacles.
+ let allowed_translation = subtract_hit(translation_remaining, &toi, offset);
+ result.translation += allowed_translation;
+ translation_remaining -= allowed_translation;
+ }
}
} else {
@@ -498,8 +488,6 @@ impl KinematicCharacterController {
// Check if there is a slope to climb.
let angle_with_floor = self.up.angle(&hit.normal1);
let climbing = self.up.dot(&slope_translation) >= 0.0;
- println!("angle_with_floor: {}, climbing: {}", angle_with_floor, climbing);
- println!("max_slope_climb_angle: {}, min_slope_slide_angle: {}", self.max_slope_climb_angle, self.min_slope_slide_angle);
climbing
.then(||(angle_with_floor <= self.max_slope_climb_angle) // Are we allowed to climb?