aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/geometry/broad_phase_multi_sap/broad_phase.rs4
-rw-r--r--src/pipeline/physics_hooks.rs10
-rw-r--r--src/pipeline/physics_pipeline.rs10
3 files changed, 17 insertions, 7 deletions
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<Bodies, Colliders> {
+ /// Applies the contact pair filter.
fn filter_contact_pair(
&self,
_context: &PairFilterContext<Bodies, Colliders>,
) -> Option<SolverFlags> {
None
}
+
+ /// Applies the intersection pair filter.
fn filter_intersection_pair(&self, _context: &PairFilterContext<Bodies, Colliders>) -> bool {
false
}
+
+ /// Modifies the set of contacts seen by the constraints solver.
fn modify_solver_contacts(&self, _context: &mut ContactModificationContext<Bodies, Colliders>) {
}
}
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);