diff options
| author | Thierry Berger <contact@thierryberger.com> | 2024-06-09 13:20:58 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-09 13:20:58 +0200 |
| commit | 8160b4ebdb06afb39f493b5c8f65d1dd280b3dfb (patch) | |
| tree | 1ce461648d0bec5f0dcd343ed213e41764ab2ccd /src | |
| parent | a8a0f297f52d4336c0d3b0effc24401e8066183b (diff) | |
| download | rapier-8160b4ebdb06afb39f493b5c8f65d1dd280b3dfb.tar.gz rapier-8160b4ebdb06afb39f493b5c8f65d1dd280b3dfb.tar.bz2 rapier-8160b4ebdb06afb39f493b5c8f65d1dd280b3dfb.zip | |
feat: change the character controller’s solve_character_collision_impulses to take multiple CharacterCollision (#646)
* character controller: solve multiple collisions
* add solve multiple collisions to changelog
* chore: apply review comments
---------
Co-authored-by: Sébastien Crozet <sebcrozet@dimforge.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/control/character_controller.rs | 33 |
1 files changed, 31 insertions, 2 deletions
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,8 +782,8 @@ 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( @@ -794,6 +794,35 @@ impl KinematicCharacterController { queries: &QueryPipeline, character_shape: &dyn Shape, character_mass: Real, + collisions: impl IntoIterator<Item = CharacterCollision>, + 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, + colliders: &ColliderSet, + queries: &QueryPipeline, + character_shape: &dyn Shape, + character_mass: Real, collision: &CharacterCollision, filter: QueryFilter, ) { |
