dimforge / parry

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

query::contact false-negative between 2d Ball and Cuboid? #34

Closed acshi closed 3 years ago

acshi commented 3 years ago

Since parry2d doesn't have much documentation yet, I found this example from ncollide: https://www.ncollide.org/geometric_queries/#contact

However, in parry, it doesn't find any collision, and we get Ok(None). Am I misunderstanding some difference between ncollide and parry here?

#[test]
fn test_contact_example() {
    let contact = query::contact(
        &Isometry::translation(1.0, 1.0),
        &Ball::new(1.0),
        &Isometry::identity(),
        &Cuboid::new(Vector2::new(1.0, 1.0)),
        1.0,
    )
    .unwrap()
    .unwrap();

    assert!(contact.dist < 0.0);
}
sebcrozet commented 3 years ago

Hi! This looks like a bug with the special case where one of the cuboid's corner lies exactly on the ball's center.