From 11d145b11ac24942d7d9c7e30df773d305a540a8 Mon Sep 17 00:00:00 2001 From: jeff425 Date: Sun, 19 Mar 2023 21:16:42 -0700 Subject: #465 Add is_sliding_down_slope field to EffectiveCharacterMovement --- src/control/character_controller.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/control/character_controller.rs b/src/control/character_controller.rs index c919064..695d811 100644 --- a/src/control/character_controller.rs +++ b/src/control/character_controller.rs @@ -135,6 +135,8 @@ pub struct EffectiveCharacterMovement { pub translation: Vector, /// Is the character touching the ground after applying `EffectiveKineamticMovement::translation`? pub grounded: bool, + /// Is the character sliding down a slope due to slope angle being larger than `min_slope_slide_angle`? + pub is_sliding_down_slope: bool, } impl KinematicCharacterController { @@ -184,6 +186,7 @@ impl KinematicCharacterController { let mut result = EffectiveCharacterMovement { translation: Vector::zeros(), grounded: false, + is_sliding_down_slope: false, }; let dims = self.compute_dims(character_shape); @@ -258,7 +261,7 @@ impl KinematicCharacterController { &mut result, ) { // No stairs, try to move along slopes. - translation_remaining = self.handle_slopes(&toi, &translation_remaining); + translation_remaining = self.handle_slopes(&toi, &translation_remaining, &mut result); } } else { // No interference along the path. @@ -472,13 +475,14 @@ impl KinematicCharacterController { false } - fn handle_slopes(&self, hit: &TOI, translation_remaining: &Vector) -> Vector { + fn handle_slopes(&self, hit: &TOI, translation_remaining: &Vector, result: &mut EffectiveCharacterMovement) -> Vector { let [vertical_translation, horizontal_translation] = self.split_into_components(translation_remaining); let slope_translation = subtract_hit(*translation_remaining, hit); // Check if there is a slope to climb. let angle_with_floor = self.up.angle(&hit.normal1); + // We are climbing if the movement along the slope goes upward, and the angle with the // floor is smaller than pi/2 (in which case we hit some some sort of ceiling). // @@ -495,6 +499,7 @@ impl KinematicCharacterController { horizontal_translation } else { // Let it slide + result.is_sliding_down_slope = true; slope_translation } } -- cgit From 8aafd5d0bbde4999579e6bd12cc634919b394fee Mon Sep 17 00:00:00 2001 From: Sébastien Crozet Date: Sat, 25 Mar 2023 18:36:51 +0100 Subject: Fix deprecation warning --- src/pipeline/query_pipeline.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/pipeline/query_pipeline.rs b/src/pipeline/query_pipeline.rs index a248426..46d6389 100644 --- a/src/pipeline/query_pipeline.rs +++ b/src/pipeline/query_pipeline.rs @@ -6,7 +6,6 @@ use crate::math::{Isometry, Point, Real, Vector}; use crate::{dynamics::RigidBodySet, geometry::ColliderSet}; use parry::partitioning::{QbvhDataGenerator, QbvhUpdateWorkspace}; use parry::query::details::{ - IntersectionCompositeShapeShapeBestFirstVisitor, NonlinearTOICompositeShapeShapeBestFirstVisitor, PointCompositeShapeProjBestFirstVisitor, PointCompositeShapeProjWithFeatureBestFirstVisitor, RayCompositeShapeToiAndNormalBestFirstVisitor, RayCompositeShapeToiBestFirstVisitor, @@ -539,12 +538,16 @@ impl QueryPipeline { filter: QueryFilter, ) -> Option { let pipeline_shape = self.as_composite_shape(bodies, colliders, filter); - let mut visitor = IntersectionCompositeShapeShapeBestFirstVisitor::new( - &*self.query_dispatcher, - shape_pos, - &pipeline_shape, - shape, - ); + #[allow(deprecated)] + // TODO: replace this with IntersectionCompositeShapeShapeVisitor when it + // can return the shape part id. + let mut visitor = + parry::query::details::IntersectionCompositeShapeShapeBestFirstVisitor::new( + &*self.query_dispatcher, + shape_pos, + &pipeline_shape, + shape, + ); self.qbvh .traverse_best_first(&mut visitor) -- cgit From afe4e4d53d0ab15aff0830cd14bb77b71a112208 Mon Sep 17 00:00:00 2001 From: Sébastien Crozet Date: Sat, 25 Mar 2023 18:37:04 +0100 Subject: cargo fmt --- src/control/character_controller.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/control/character_controller.rs b/src/control/character_controller.rs index 695d811..a5bcf3d 100644 --- a/src/control/character_controller.rs +++ b/src/control/character_controller.rs @@ -261,7 +261,8 @@ impl KinematicCharacterController { &mut result, ) { // No stairs, try to move along slopes. - translation_remaining = self.handle_slopes(&toi, &translation_remaining, &mut result); + translation_remaining = + self.handle_slopes(&toi, &translation_remaining, &mut result); } } else { // No interference along the path. @@ -475,7 +476,12 @@ impl KinematicCharacterController { false } - fn handle_slopes(&self, hit: &TOI, translation_remaining: &Vector, result: &mut EffectiveCharacterMovement) -> Vector { + fn handle_slopes( + &self, + hit: &TOI, + translation_remaining: &Vector, + result: &mut EffectiveCharacterMovement, + ) -> Vector { let [vertical_translation, horizontal_translation] = self.split_into_components(translation_remaining); let slope_translation = subtract_hit(*translation_remaining, hit); -- cgit