parry3d/query/contact/
contact_shape_shape.rs

1use crate::math::{Isometry, Real};
2use crate::query::{Contact, DefaultQueryDispatcher, QueryDispatcher, Unsupported};
3use crate::shape::Shape;
4
5/// Computes one pair of contact points point between two shapes.
6///
7/// Returns `None` if the objects are separated by a distance greater than `prediction`.
8/// The result is given in world-space.
9pub fn contact(
10    pos1: &Isometry<Real>,
11    g1: &dyn Shape,
12    pos2: &Isometry<Real>,
13    g2: &dyn Shape,
14    prediction: Real,
15) -> Result<Option<Contact>, Unsupported> {
16    let pos12 = pos1.inv_mul(pos2);
17    let mut result = DefaultQueryDispatcher.contact(&pos12, g1, g2, prediction);
18
19    if let Ok(Some(contact)) = &mut result {
20        contact.transform_by_mut(pos1, pos2);
21    }
22
23    result
24}