aboutsummaryrefslogtreecommitdiff
path: root/src_testbed/ui.rs
diff options
context:
space:
mode:
authorThierry Berger <contact@thierryberger.com>2024-09-23 11:10:29 +0200
committerGitHub <noreply@github.com>2024-09-23 11:10:29 +0200
commit76357e3588dfc5efe9fa609df21e2aaf707fbba9 (patch)
tree252852c89d9a7c750af853f77f649508c914b89d /src_testbed/ui.rs
parente7e196d9f949a03ef997f0adc629344c3696b1ff (diff)
downloadrapier-76357e3588dfc5efe9fa609df21e2aaf707fbba9.tar.gz
rapier-76357e3588dfc5efe9fa609df21e2aaf707fbba9.tar.bz2
rapier-76357e3588dfc5efe9fa609df21e2aaf707fbba9.zip
Fix CharacterController max/min slope handling (#701)
Diffstat (limited to 'src_testbed/ui.rs')
-rw-r--r--src_testbed/ui.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src_testbed/ui.rs b/src_testbed/ui.rs
index aa9dc7a..b27ea7a 100644
--- a/src_testbed/ui.rs
+++ b/src_testbed/ui.rs
@@ -1,3 +1,4 @@
+use rapier::control::CharacterLength;
use rapier::counters::Counters;
use rapier::math::Real;
use std::num::NonZeroUsize;
@@ -240,7 +241,40 @@ pub fn update_ui(
// .set(TestbedStateFlags::CONTACT_POINTS, contact_points);
// state.flags.set(TestbedStateFlags::WIREFRAME, wireframe);
ui.separator();
+ if let Some(character_controller) = &mut state.character_controller {
+ ui.label("Character controller");
+ ui.checkbox(&mut character_controller.slide, "slide").on_hover_text("Should the character try to slide against the floor if it hits it?");
+ #[allow(clippy::useless_conversion)]
+ {
+ ui.add(Slider::new(&mut character_controller.max_slope_climb_angle, 0.0..=std::f32::consts::TAU.into()).text("max_slope_climb_angle"))
+ .on_hover_text("The maximum angle (radians) between the floor’s normal and the `up` vector that the character is able to climb.");
+ ui.add(Slider::new(&mut character_controller.min_slope_slide_angle, 0.0..=std::f32::consts::FRAC_PI_2.into()).text("min_slope_slide_angle"))
+ .on_hover_text("The minimum angle (radians) between the floor’s normal and the `up` vector before the character starts to slide down automatically.");
+ }
+ let mut is_snapped = character_controller.snap_to_ground.is_some();
+ if ui.checkbox(&mut is_snapped, "snap_to_ground").changed {
+ match is_snapped {
+ true => {
+ character_controller.snap_to_ground = Some(CharacterLength::Relative(0.1));
+ },
+ false => {
+ character_controller.snap_to_ground = None;
+ },
+ }
+ }
+ if let Some(snapped) = &mut character_controller.snap_to_ground {
+ match snapped {
+ CharacterLength::Relative(val) => {
+ ui.add(Slider::new(val, 0.0..=10.0).text("Snapped Relative Character Length"));
+ },
+ CharacterLength::Absolute(val) => {
+ ui.add(Slider::new(val, 0.0..=10.0).text("Snapped Absolute Character Length"));
+ },
+ }
+ }
+ ui.separator();
+ }
let label = if state.running == RunMode::Stop {
"Start (T)"
} else {