diff options
| author | Crozet Sébastien <developer@crozet.re> | 2020-09-14 22:22:55 +0200 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2020-09-28 15:27:25 +0200 |
| commit | e16b7722be23f7b6627bd54e174d7782d33c53fe (patch) | |
| tree | c98e24cb22bd7bf11a1d41f1fd20f77b3aa50b7d /src/pipeline | |
| parent | a60e1e030d624a255e544cabdf98a2df5bb6efdc (diff) | |
| download | rapier-e16b7722be23f7b6627bd54e174d7782d33c53fe.tar.gz rapier-e16b7722be23f7b6627bd54e174d7782d33c53fe.tar.bz2 rapier-e16b7722be23f7b6627bd54e174d7782d33c53fe.zip | |
Fix crash caused by the removal of a kinematic body.
Diffstat (limited to 'src/pipeline')
| -rw-r--r-- | src/pipeline/physics_pipeline.rs | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/src/pipeline/physics_pipeline.rs b/src/pipeline/physics_pipeline.rs index 8449477..192ca9a 100644 --- a/src/pipeline/physics_pipeline.rs +++ b/src/pipeline/physics_pipeline.rs @@ -298,8 +298,9 @@ impl PhysicsPipeline { #[cfg(test)] mod test { - use crate::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet}; - use crate::geometry::{BroadPhase, ColliderSet, NarrowPhase}; + use crate::dynamics::{IntegrationParameters, JointSet, RigidBodyBuilder, RigidBodySet}; + use crate::geometry::{BroadPhase, ColliderBuilder, ColliderSet, NarrowPhase}; + use crate::math::Vector; use crate::pipeline::PhysicsPipeline; #[test] @@ -310,12 +311,45 @@ mod test { let mut bf = BroadPhase::new(); let mut nf = NarrowPhase::new(); - let mut set = RigidBodySet::new(); - let rb = RigidBodyBuilder::new_dynamic().build(); + let mut bodies = RigidBodySet::new(); // Check that removing the body right after inserting it works. - let h1 = set.insert(rb.clone()); - pipeline.remove_rigid_body(h1, &mut bf, &mut nf, &mut set, &mut colliders, &mut joints); + // We add two dynamic bodies, one kinematic body and one static body before removing + // them. This include a non-regression test where deleting a kimenatic body crashes. + let rb = RigidBodyBuilder::new_dynamic().build(); + let h1 = bodies.insert(rb.clone()); + let h2 = bodies.insert(rb.clone()); + + // The same but with a kinematic body. + let rb = RigidBodyBuilder::new_kinematic().build(); + let h3 = bodies.insert(rb.clone()); + + // The same but with a static body. + let rb = RigidBodyBuilder::new_static().build(); + let h4 = bodies.insert(rb.clone()); + + let to_delete = [h1, h2, h3, h4]; + for h in &to_delete { + pipeline.remove_rigid_body( + *h, + &mut bf, + &mut nf, + &mut bodies, + &mut colliders, + &mut joints, + ); + } + + pipeline.step( + &Vector::zeros(), + &IntegrationParameters::default(), + &mut bf, + &mut nf, + &mut bodies, + &mut colliders, + &mut joints, + &(), + ); } #[test] |
