Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null ray intersect with a flat AABB #107

Open
niess opened this issue Jun 25, 2024 · 4 comments
Open

Null ray intersect with a flat AABB #107

niess opened this issue Jun 25, 2024 · 4 comments

Comments

@niess
Copy link

niess commented Jun 25, 2024

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
Copy link
Owner

Can you check whether #106 fixes your problem?

@svenstaro
Copy link
Owner

@niess ping

@niess
Copy link
Author

niess commented Jul 15, 2024

Hello @svenstaro ,

I do not think that patch #106 would help.

The issue is not that the BVH is empty, but that faces that are axis-aligned (thus have a flat bounding box) are not considered as being intersected by rays. Changing the strict equality test to "greater or equal" (for example here) solved my issue (basically). Thus something the like:

tmax >= fast_max(tmin, T::zero())

(but also in other places, depending on the architecture)

@svenstaro
Copy link
Owner

That makes sense. Would you like to put in a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants