svenstaro / bvh

A fast BVH using SAH in rust
https://docs.rs/bvh
MIT License
224 stars 37 forks source link

Null ray intersect with a flat AABB #107

Open niess opened 1 week ago

niess commented 1 week ago

Hello,

thank you for this useful crate :) It works great for my application, except for the following case. When intersecting a ray and a flat AABB, false is returned. For instance,

    let origin = Point3::<f64>::new(0.0, 0.0, 0.0);
    let direction = Vector3::<f64>::new(0.0, 0.0, 1.0);
    let ray = Ray::new(origin, direction);
    let min = Point3::<f64>::new(-1.0, -1.0, 1.0);
    let max = Point3::<f64>::new(1.0, 1.0, 1.0);
    let aabb = Aabb::with_bounds(min, max);
    assert!(ray.intersects_aabb(&aabb));

The last assertion fails, where I would have expected true (e.g. when bounding an axis-aligned triangular facet).

My apologies if this is the intended behaviour?

I am running on x86_64 Linux with version 0.9.0 (and default features, i.e. simd disabled).

svenstaro commented 6 days ago

Can you check whether #106 fixes your problem?