From 8160b4ebdb06afb39f493b5c8f65d1dd280b3dfb Mon Sep 17 00:00:00 2001 From: Thierry Berger Date: Sun, 9 Jun 2024 13:20:58 +0200 Subject: feat: change the character controller’s solve_character_collision_impulses to take multiple CharacterCollision (#646) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * character controller: solve multiple collisions * add solve multiple collisions to changelog * chore: apply review comments --------- Co-authored-by: Sébastien Crozet --- src/control/character_controller.rs | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'src/control') diff --git a/src/control/character_controller.rs b/src/control/character_controller.rs index 87b5c16..dc7381f 100644 --- a/src/control/character_controller.rs +++ b/src/control/character_controller.rs @@ -782,11 +782,40 @@ impl KinematicCharacterController { true } - /// For a given collision between a character and its environment, this method will apply - /// impulses to the rigid-bodies surrounding the character shape at the time of the collision. + /// For the given collisions between a character and its environment, this method will apply + /// impulses to the rigid-bodies surrounding the character shape at the time of the collisions. /// Note that the impulse calculation is only approximate as it is not based on a global /// constraints resolution scheme. pub fn solve_character_collision_impulses( + &self, + dt: Real, + bodies: &mut RigidBodySet, + colliders: &ColliderSet, + queries: &QueryPipeline, + character_shape: &dyn Shape, + character_mass: Real, + collisions: impl IntoIterator, + filter: QueryFilter, + ) { + for collision in collisions { + self.solve_single_character_collision_impulse( + dt, + bodies, + colliders, + queries, + character_shape, + character_mass, + &collision, + filter, + ); + } + } + + /// For the given collision between a character and its environment, this method will apply + /// impulses to the rigid-bodies surrounding the character shape at the time of the collision. + /// Note that the impulse calculation is only approximate as it is not based on a global + /// constraints resolution scheme. + fn solve_single_character_collision_impulse( &self, dt: Real, bodies: &mut RigidBodySet, -- cgit