pub trait PersistentQueryDispatcher<ManifoldData = (), ContactData = ()>: QueryDispatcher {
// Required methods
fn contact_manifolds(
&self,
pos12: &Isometry<f32>,
g1: &dyn Shape,
g2: &dyn Shape,
prediction: f32,
manifolds: &mut Vec<ContactManifold<ManifoldData, ContactData>>,
workspace: &mut Option<ContactManifoldsWorkspace>,
) -> Result<(), Unsupported>;
fn contact_manifold_convex_convex(
&self,
pos12: &Isometry<f32>,
g1: &dyn Shape,
g2: &dyn Shape,
normal_constraints1: Option<&dyn NormalConstraints>,
normal_constraints2: Option<&dyn NormalConstraints>,
prediction: f32,
manifold: &mut ContactManifold<ManifoldData, ContactData>,
) -> Result<(), Unsupported>;
}Expand description
A query dispatcher for queries relying on spatial coherence, including contact-manifold computation.
This trait extends QueryDispatcher with methods that maintain persistent state between
queries to improve performance through spatial and temporal coherence.
§What is Spatial Coherence?
Spatial coherence is the principle that objects that are close to each other in one frame are likely to remain close in subsequent frames. Contact manifolds exploit this by:
- Tracking contact points over multiple frames
- Reusing previous contact information to accelerate new queries
- Maintaining contact IDs for physics solvers to track persistent contacts
§Contact Manifolds vs Single Contacts
-
Single Contact (
QueryDispatcher::contact): Returns one contact point, suitable for one-off queries or simple collision detection. -
Contact Manifold (
PersistentQueryDispatcher::contact_manifolds): Returns multiple contact points that persist across frames, essential for stable physics simulation.
§When to Use This Trait
Use PersistentQueryDispatcher when:
- Implementing physics simulation that needs stable contact tracking
- Building a custom physics engine on top of Parry
- Optimizing repeated collision queries between the same shape pairs
§Generic Parameters
ManifoldData: Custom data attached to each contact manifold (default:())ContactData: Custom data attached to each contact point (default:())
These allow physics engines to attach solver-specific data to contacts without modifying Parry’s core types.
Required Methods§
Sourcefn contact_manifolds(
&self,
pos12: &Isometry<f32>,
g1: &dyn Shape,
g2: &dyn Shape,
prediction: f32,
manifolds: &mut Vec<ContactManifold<ManifoldData, ContactData>>,
workspace: &mut Option<ContactManifoldsWorkspace>,
) -> Result<(), Unsupported>
fn contact_manifolds( &self, pos12: &Isometry<f32>, g1: &dyn Shape, g2: &dyn Shape, prediction: f32, manifolds: &mut Vec<ContactManifold<ManifoldData, ContactData>>, workspace: &mut Option<ContactManifoldsWorkspace>, ) -> Result<(), Unsupported>
Compute all the contacts between two shapes.
The output is written into manifolds and context. Both can persist
between multiple calls to contacts by re-using the result of the previous
call to contacts. This persistence can significantly improve collision
detection performances by allowing the underlying algorithms to exploit
spatial and temporal coherence.
Sourcefn contact_manifold_convex_convex(
&self,
pos12: &Isometry<f32>,
g1: &dyn Shape,
g2: &dyn Shape,
normal_constraints1: Option<&dyn NormalConstraints>,
normal_constraints2: Option<&dyn NormalConstraints>,
prediction: f32,
manifold: &mut ContactManifold<ManifoldData, ContactData>,
) -> Result<(), Unsupported>
fn contact_manifold_convex_convex( &self, pos12: &Isometry<f32>, g1: &dyn Shape, g2: &dyn Shape, normal_constraints1: Option<&dyn NormalConstraints>, normal_constraints2: Option<&dyn NormalConstraints>, prediction: f32, manifold: &mut ContactManifold<ManifoldData, ContactData>, ) -> Result<(), Unsupported>
Computes the contact-manifold between two convex shapes.