dimforge / parry

2D and 3D collision-detection library for Rust.
https://parry.rs
Apache License 2.0
557 stars 97 forks source link

`time_of_impact` query no longer has threshold distance #26

Open rishflab opened 3 years ago

rishflab commented 3 years ago

The comment for the time_of_impact query suggests the existence of a threshold distance but this has been removed since release 0.3. The old API was useful to me but I guess I can just shift pos2 by the threshold distance? Is there any chance of getting the old API back?

/// Computes the smallest time when two shapes under translational movement are separated by a
/// distance smaller or equal to `distance`.
///
/// Returns `0.0` if the objects are touching or penetrating.
pub fn time_of_impact(
    pos1: &Isometry<Real>,
    vel1: &Vector<Real>,
    g1: &dyn Shape,
    pos2: &Isometry<Real>,
    vel2: &Vector<Real>,
    g2: &dyn Shape,
    max_toi: Real,
) -> Result<Option<TOI>, Unsupported> {
    let pos12 = pos1.inv_mul(pos2);
    let vel12 = pos1.inverse_transform_vector(&(vel2 - vel1));
    DefaultQueryDispatcher.time_of_impact(&pos12, &vel12, g1, g2, max_toi)
}
sebcrozet commented 3 years ago

Hi! There is no immediate plane to re-add the threshold distance because its implementation was actually buggy and computationally expensive.

But let's keep this issue open so that we revisit this in the future if this becomes more feasible after some of the upcoming algorithmic change.