From bde6657287cd32a801abb996322c520673406418 Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Wed, 2 Jun 2021 16:22:40 +0200 Subject: Fix tests and wasm build. --- src/geometry/broad_phase_multi_sap/broad_phase.rs | 4 ++-- src/pipeline/physics_hooks.rs | 10 ++++++++++ src/pipeline/physics_pipeline.rs | 10 +++++----- 3 files changed, 17 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/geometry/broad_phase_multi_sap/broad_phase.rs b/src/geometry/broad_phase_multi_sap/broad_phase.rs index 4b35e53..63f1a55 100644 --- a/src/geometry/broad_phase_multi_sap/broad_phase.rs +++ b/src/geometry/broad_phase_multi_sap/broad_phase.rs @@ -598,7 +598,7 @@ mod test { let rb = RigidBodyBuilder::new_dynamic().build(); let co = ColliderBuilder::ball(0.5).build(); let hrb = bodies.insert(rb); - let coh = colliders.insert(co, hrb, &mut bodies); + let coh = colliders.insert_with_parent(co, hrb, &mut bodies); let mut events = Vec::new(); broad_phase.update(0.0, &mut colliders, &[coh], &[], &mut events); @@ -610,7 +610,7 @@ mod test { let rb = RigidBodyBuilder::new_dynamic().build(); let co = ColliderBuilder::ball(0.5).build(); let hrb = bodies.insert(rb); - let coh = colliders.insert(co, hrb, &mut bodies); + let coh = colliders.insert_with_parent(co, hrb, &mut bodies); // Make sure the proxy handles is recycled properly. broad_phase.update(0.0, &mut colliders, &[coh], &[], &mut events); diff --git a/src/pipeline/physics_hooks.rs b/src/pipeline/physics_hooks.rs index bb09452..68a05d1 100644 --- a/src/pipeline/physics_hooks.rs +++ b/src/pipeline/physics_hooks.rs @@ -133,17 +133,27 @@ impl Default for ActiveHooks { } } +// TODO: right now, the wasm version don't have the Send+Sync bounds. +// This is because these bounds are very difficult to fulfill if we want to +// call JS closures. Also, parallelism cannot be enabled for wasm targets, so +// not having Send+Sync isn't a problem. +/// User-defined functions called by the physics engines during one timestep in order to customize its behavior. #[cfg(target_arch = "wasm32")] pub trait PhysicsHooks { + /// Applies the contact pair filter. fn filter_contact_pair( &self, _context: &PairFilterContext, ) -> Option { None } + + /// Applies the intersection pair filter. fn filter_intersection_pair(&self, _context: &PairFilterContext) -> bool { false } + + /// Modifies the set of contacts seen by the constraints solver. fn modify_solver_contacts(&self, _context: &mut ContactModificationContext) { } } diff --git a/src/pipeline/physics_pipeline.rs b/src/pipeline/physics_pipeline.rs index 987ca25..a83240e 100644 --- a/src/pipeline/physics_pipeline.rs +++ b/src/pipeline/physics_pipeline.rs @@ -745,12 +745,12 @@ mod test { let rb = RigidBodyBuilder::new_static().build(); let h1 = bodies.insert(rb.clone()); let co = ColliderBuilder::ball(10.0).build(); - colliders.insert(co.clone(), h1, &mut bodies); + colliders.insert_with_parent(co.clone(), h1, &mut bodies); // The same but with a kinematic body. - let rb = RigidBodyBuilder::new_kinematic().build(); + let rb = RigidBodyBuilder::new_kinematic_position_based().build(); let h2 = bodies.insert(rb.clone()); - colliders.insert(co, h2, &mut bodies); + colliders.insert_with_parent(co, h2, &mut bodies); pipeline.step( &Vector::zeros(), @@ -786,7 +786,7 @@ mod test { let h2 = bodies.insert(rb.clone()); // The same but with a kinematic body. - let rb = RigidBodyBuilder::new_kinematic().build(); + let rb = RigidBodyBuilder::new_kinematic_position_based().build(); let h3 = bodies.insert(rb.clone()); // The same but with a static body. @@ -864,7 +864,7 @@ mod test { let body = RigidBodyBuilder::new_dynamic().build(); let b_handle = bodies.insert(body); let collider = ColliderBuilder::ball(1.0).build(); - let c_handle = colliders.insert(collider, b_handle, &mut bodies); + let c_handle = colliders.insert_with_parent(collider, b_handle, &mut bodies); colliders.remove(c_handle, &mut islands, &mut bodies, true); bodies.remove(b_handle, &mut islands, &mut colliders, &mut joints); -- cgit