parry3d/query/nonlinear_shape_cast/nonlinear_shape_cast.rs
1use crate::math::Real;
2use crate::query::{
3 DefaultQueryDispatcher, NonlinearRigidMotion, QueryDispatcher, ShapeCastHit, Unsupported,
4};
5use crate::shape::Shape;
6
7/// Computes the smallest time of impact of two shapes under translational an rotational movements.
8///
9/// # Parameters
10/// * `motion1` - The motion of the first shape.
11/// * `g1` - The first shape involved in the query.
12/// * `motion2` - The motion of the second shape.
13/// * `g2` - The second shape involved in the query.
14/// * `start_time` - The starting time of the interval where the motion takes place.
15/// * `end_time` - The end time of the interval where the motion takes place.
16/// * `stop_at_penetration` - If the casted shape starts in a penetration state with any
17/// collider, two results are possible. If `stop_at_penetration` is `true` then, the
18/// result will have a `time_of_impact` equal to `start_time`. If `stop_at_penetration` is `false`
19/// then the nonlinear shape-casting will see if further motion wrt. the penetration normal
20/// would result in tunnelling. If it does not (i.e. we have a separating velocity along
21/// that normal) then the nonlinear shape-casting will attempt to find another impact,
22/// at a time `> start_time` that could result in tunnelling.
23pub fn cast_shapes_nonlinear(
24 motion1: &NonlinearRigidMotion,
25 g1: &dyn Shape,
26 motion2: &NonlinearRigidMotion,
27 g2: &dyn Shape,
28 start_time: Real,
29 end_time: Real,
30 stop_at_penetration: bool,
31) -> Result<Option<ShapeCastHit>, Unsupported> {
32 DefaultQueryDispatcher.cast_shapes_nonlinear(
33 motion1,
34 g1,
35 motion2,
36 g2,
37 start_time,
38 end_time,
39 stop_at_penetration,
40 )
41}