dimforge / parry

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

`Segment::intersects_ray` returns false-positive when the segment is zero-length #31

Open picoHz opened 3 years ago

picoHz commented 3 years ago
use parry2d::math::*;
use parry2d::query::{Ray, RayCast};
use parry2d::shape::Segment;

fn main() {
    // never intersect each other
    let ray = Ray::new(Point::new(0.0, 0.0), Vector::new(1.0, 0.0));
    let segment = Segment {
        a: Point::new(10.0, 10.0),
        b: Point::new(10.0, 10.0),
    };

    // returns true
    let hit = segment.intersects_ray(&Isometry::identity(), &ray, std::f32::MAX);
    assert_eq!(hit, false);
}