dimforge / parry

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

closest_points panics when a Cylinder & Trimesh are not within max_dist #79

Open mijalk0 opened 2 years ago

mijalk0 commented 2 years ago

closest_points panics when a Cylinder and Trimesh are tested and the objects are not within max_dist of each other. I believe the function is actually supposed to return Disjoint instead. Here is a specific example I've found:

use parry3d::{math::*, query, shape::*};

fn main() {
    let cylinder = Cylinder::new(0.5, 1.0);

    let vertices = vec![
        Point::new(1.0, -1.0, 0.0),
        Point::new(-1.0, -1.0, 0.0),
        Point::new(0.0, -1.0, 1.0),
    ];
    let indices = vec![[0, 1, 2]];
    let trimesh = TriMesh::new(vertices, indices);

    // let max_dist = 0.5; // Fine
    let max_dist = 0.49; // Panics

    let _ = query::closest_points(
        &Isometry::identity(),
        cylinder.clone_box().as_ref(),
        &Isometry::identity(),
        trimesh.clone_box().as_ref(),
        max_dist,
    );
}
hunterZh37 commented 2 years ago

Same error here. For me, closest_points panics when two shapes are not within 1.0 unit distance of each other. I have gotten a "Composite shapes must not be empty" error. I have double-checked that my inputs are not indeed empty, but still getting the same error.