Fix tests and wasm build.

This commit is contained in:
Crozet Sébastien
2021-06-02 16:22:40 +02:00
parent acc4e4f301
commit bde6657287
3 changed files with 17 additions and 7 deletions

View File

@@ -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);

View File

@@ -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>) {
}
}

View File

@@ -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);