ContactPairFilter: don't overwrite the effect of the solver groups.
This is more consistent with the fact that the effect of collision groups is not overwritten either.
This commit is contained in:
@@ -320,10 +320,10 @@ impl NarrowPhase {
|
||||
|
||||
if let Some(filter) = pair_filter {
|
||||
let context = PairFilterContext {
|
||||
collider1: co1,
|
||||
collider2: co2,
|
||||
rigid_body1: rb1,
|
||||
rigid_body2: rb2,
|
||||
collider1: co1,
|
||||
collider2: co2,
|
||||
};
|
||||
|
||||
if !filter.filter_proximity_pair(&context) {
|
||||
@@ -389,12 +389,12 @@ impl NarrowPhase {
|
||||
return;
|
||||
}
|
||||
|
||||
let solver_flags = if let Some(filter) = pair_filter {
|
||||
let mut solver_flags = if let Some(filter) = pair_filter {
|
||||
let context = PairFilterContext {
|
||||
collider1: co1,
|
||||
collider2: co2,
|
||||
rigid_body1: rb1,
|
||||
rigid_body2: rb2,
|
||||
collider1: co1,
|
||||
collider2: co2,
|
||||
};
|
||||
|
||||
if let Some(solver_flags) = filter.filter_contact_pair(&context) {
|
||||
@@ -404,13 +404,13 @@ impl NarrowPhase {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if co1.solver_groups.test(co2.solver_groups) {
|
||||
SolverFlags::COMPUTE_IMPULSES
|
||||
} else {
|
||||
SolverFlags::empty()
|
||||
}
|
||||
SolverFlags::COMPUTE_IMPULSES
|
||||
};
|
||||
|
||||
if !co1.solver_groups.test(co2.solver_groups) {
|
||||
solver_flags.remove(SolverFlags::COMPUTE_IMPULSES);
|
||||
}
|
||||
|
||||
let dispatcher = DefaultContactDispatcher;
|
||||
if pair.generator.is_none() {
|
||||
// We need a redispatch for this generator.
|
||||
|
||||
@@ -3,14 +3,14 @@ use crate::geometry::{Collider, SolverFlags};
|
||||
|
||||
/// Context given to custom collision filters to filter-out collisions.
|
||||
pub struct PairFilterContext<'a> {
|
||||
/// The first collider involved in the potential collision.
|
||||
pub collider1: &'a Collider,
|
||||
/// The first collider involved in the potential collision.
|
||||
pub collider2: &'a Collider,
|
||||
/// The first collider involved in the potential collision.
|
||||
pub rigid_body1: &'a RigidBody,
|
||||
/// The first collider involved in the potential collision.
|
||||
pub rigid_body2: &'a RigidBody,
|
||||
/// The first collider involved in the potential collision.
|
||||
pub collider1: &'a Collider,
|
||||
/// The first collider involved in the potential collision.
|
||||
pub collider2: &'a Collider,
|
||||
}
|
||||
|
||||
/// User-defined filter for potential contact pairs detected by the broad-phase.
|
||||
@@ -24,9 +24,6 @@ pub trait ContactPairFilter: Send + Sync {
|
||||
/// Note that using a contact pair filter will replace the default contact filtering
|
||||
/// which consists of preventing contact computation between two non-dynamic bodies.
|
||||
///
|
||||
/// Note that using a contact pair filter will replace the default determination
|
||||
/// of solver flags, based on the colliders solver groups.
|
||||
///
|
||||
/// This filtering method is called after taking into account the colliders collision groups.
|
||||
///
|
||||
/// If this returns `None`, then the narrow-phase will ignore this contact pair and
|
||||
|
||||
@@ -290,6 +290,8 @@ mod test {
|
||||
&mut bodies,
|
||||
&mut colliders,
|
||||
&mut joints,
|
||||
None,
|
||||
None,
|
||||
&(),
|
||||
);
|
||||
}
|
||||
@@ -332,6 +334,8 @@ mod test {
|
||||
&mut bodies,
|
||||
&mut colliders,
|
||||
&mut joints,
|
||||
None,
|
||||
None,
|
||||
&(),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user