Skip to content

Commit

Permalink
fix: less invasive solve_character_collision_impulses function (#652)
Browse files Browse the repository at this point in the history
* fix: less invasive `solve_character_collision_impulses` function

Taking ownership of the elements is not necessary.

It also conveys the information that elements are only read.

* Add Changelog
  • Loading branch information
Vrixyz authored Jun 23, 2024
1 parent 3004a7d commit 5308a28
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

- Fix `NaN` values appearing in bodies translation and rotation after a simulation step with a delta time equal to 0 ([#660](https://github.com/dimforge/rapier/pull/660)).

### Modified

- `solve_character_collision_impulses` collisions parameter is now an iterator over references.

## v0.20.0 (9 June 2024)

This release introduces two new crates:
Expand Down
6 changes: 3 additions & 3 deletions src/control/character_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,15 +788,15 @@ impl KinematicCharacterController {
/// 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(
pub fn solve_character_collision_impulses<'a>(
&self,
dt: Real,
bodies: &mut RigidBodySet,
colliders: &ColliderSet,
queries: &QueryPipeline,
character_shape: &dyn Shape,
character_mass: Real,
collisions: impl IntoIterator<Item = CharacterCollision>,
collisions: impl IntoIterator<Item = &'a CharacterCollision>,
filter: QueryFilter,
) {
for collision in collisions {
Expand All @@ -807,7 +807,7 @@ impl KinematicCharacterController {
queries,
character_shape,
character_mass,
&collision,
collision,
filter,
);
}
Expand Down
2 changes: 1 addition & 1 deletion src_testbed/testbed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ impl<'a, 'b, 'c, 'd, 'e, 'f> Testbed<'a, 'b, 'c, 'd, 'e, 'f> {
&phx.query_pipeline,
character_collider.shape(),
character_mass,
collisions,
&*collisions,
QueryFilter::new().exclude_rigid_body(character_handle),
);

Expand Down

0 comments on commit 5308a28

Please sign in to comment.