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 {
|
if let Some(filter) = pair_filter {
|
||||||
let context = PairFilterContext {
|
let context = PairFilterContext {
|
||||||
collider1: co1,
|
|
||||||
collider2: co2,
|
|
||||||
rigid_body1: rb1,
|
rigid_body1: rb1,
|
||||||
rigid_body2: rb2,
|
rigid_body2: rb2,
|
||||||
|
collider1: co1,
|
||||||
|
collider2: co2,
|
||||||
};
|
};
|
||||||
|
|
||||||
if !filter.filter_proximity_pair(&context) {
|
if !filter.filter_proximity_pair(&context) {
|
||||||
@@ -389,12 +389,12 @@ impl NarrowPhase {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let solver_flags = if let Some(filter) = pair_filter {
|
let mut solver_flags = if let Some(filter) = pair_filter {
|
||||||
let context = PairFilterContext {
|
let context = PairFilterContext {
|
||||||
collider1: co1,
|
|
||||||
collider2: co2,
|
|
||||||
rigid_body1: rb1,
|
rigid_body1: rb1,
|
||||||
rigid_body2: rb2,
|
rigid_body2: rb2,
|
||||||
|
collider1: co1,
|
||||||
|
collider2: co2,
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(solver_flags) = filter.filter_contact_pair(&context) {
|
if let Some(solver_flags) = filter.filter_contact_pair(&context) {
|
||||||
@@ -404,13 +404,13 @@ impl NarrowPhase {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if co1.solver_groups.test(co2.solver_groups) {
|
SolverFlags::COMPUTE_IMPULSES
|
||||||
SolverFlags::COMPUTE_IMPULSES
|
|
||||||
} else {
|
|
||||||
SolverFlags::empty()
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if !co1.solver_groups.test(co2.solver_groups) {
|
||||||
|
solver_flags.remove(SolverFlags::COMPUTE_IMPULSES);
|
||||||
|
}
|
||||||
|
|
||||||
let dispatcher = DefaultContactDispatcher;
|
let dispatcher = DefaultContactDispatcher;
|
||||||
if pair.generator.is_none() {
|
if pair.generator.is_none() {
|
||||||
// We need a redispatch for this generator.
|
// 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.
|
/// Context given to custom collision filters to filter-out collisions.
|
||||||
pub struct PairFilterContext<'a> {
|
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.
|
/// The first collider involved in the potential collision.
|
||||||
pub rigid_body1: &'a RigidBody,
|
pub rigid_body1: &'a RigidBody,
|
||||||
/// The first collider involved in the potential collision.
|
/// The first collider involved in the potential collision.
|
||||||
pub rigid_body2: &'a RigidBody,
|
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.
|
/// 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
|
/// Note that using a contact pair filter will replace the default contact filtering
|
||||||
/// which consists of preventing contact computation between two non-dynamic bodies.
|
/// 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.
|
/// 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
|
/// If this returns `None`, then the narrow-phase will ignore this contact pair and
|
||||||
|
|||||||
@@ -290,6 +290,8 @@ mod test {
|
|||||||
&mut bodies,
|
&mut bodies,
|
||||||
&mut colliders,
|
&mut colliders,
|
||||||
&mut joints,
|
&mut joints,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
&(),
|
&(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -332,6 +334,8 @@ mod test {
|
|||||||
&mut bodies,
|
&mut bodies,
|
||||||
&mut colliders,
|
&mut colliders,
|
||||||
&mut joints,
|
&mut joints,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
&(),
|
&(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user