pub fn contact_manifolds(
collider1: &Collider,
position1: impl Into<Position>,
rotation1: impl Into<Rotation>,
collider2: &Collider,
position2: impl Into<Position>,
rotation2: impl Into<Rotation>,
prediction_distance: Scalar,
manifolds: &mut Vec<ContactManifold>,
)
Expand description
Computes all ContactManifold
s between two Collider
s.
The contact points are expressed in world space, relative to the origin of the first and second shape respectively.
Returns an empty vector if the colliders are separated by a distance greater than prediction_distance
or if the given shapes are invalid.
ยงExample
use avian3d::{collision::collider::contact_query::contact_manifolds, prelude::*};
use bevy::prelude::*;
let collider1 = Collider::sphere(0.5);
let collider2 = Collider::cuboid(1.0, 1.0, 1.0);
// Compute contact manifolds a collision that should be penetrating
let mut manifolds = Vec::new();
contact_manifolds(
// First collider
&collider1,
Vec3::default(),
Quat::default(),
// Second collider
&collider2,
Vec3::X * 0.25,
Quat::default(),
// Prediction distance
0.0,
// Output manifolds
&mut manifolds,
);
assert_eq!(manifolds.is_empty(), false);