1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use crate::math::Real;
use crate::query::{
    DefaultQueryDispatcher, NonlinearRigidMotion, QueryDispatcher, ShapeCastHit, Unsupported,
};
use crate::shape::Shape;

/// Computes the smallest time of impact of two shapes under translational an rotational movements.
///
/// # Parameters
/// * `motion1` - The motion of the first shape.
/// * `g1` - The first shape involved in the query.
/// * `motion2` - The motion of the second shape.
/// * `g2` - The second shape involved in the query.
/// * `start_time` - The starting time of the interval where the motion takes place.
/// * `end_time` - The end time of the interval where the motion takes place.
/// * `stop_at_penetration` - If the casted shape starts in a penetration state with any
///    collider, two results are possible. If `stop_at_penetration` is `true` then, the
///    result will have a `time_of_impact` equal to `start_time`. If `stop_at_penetration` is `false`
///    then the nonlinear shape-casting will see if further motion wrt. the penetration normal
///    would result in tunnelling. If it does not (i.e. we have a separating velocity along
///    that normal) then the nonlinear shape-casting will attempt to find another impact,
///    at a time `> start_time` that could result in tunnelling.
pub fn cast_shapes_nonlinear(
    motion1: &NonlinearRigidMotion,
    g1: &dyn Shape,
    motion2: &NonlinearRigidMotion,
    g2: &dyn Shape,
    start_time: Real,
    end_time: Real,
    stop_at_penetration: bool,
) -> Result<Option<ShapeCastHit>, Unsupported> {
    DefaultQueryDispatcher.cast_shapes_nonlinear(
        motion1,
        g1,
        motion2,
        g2,
        start_time,
        end_time,
        stop_at_penetration,
    )
}