Skip to content

fix: correct min_t semantics in AABB::intersect_ray#2536

Open
nmlucarelli wants to merge 3 commits intolibigl:mainfrom
nmlucarelli:fix/aabb-intersect-ray-min-t
Open

fix: correct min_t semantics in AABB::intersect_ray#2536
nmlucarelli wants to merge 3 commits intolibigl:mainfrom
nmlucarelli:fix/aabb-intersect-ray-min-t

Conversation

@nmlucarelli
Copy link
Copy Markdown

Fixes #2518 .
Breaking fix for users who have adapted to the inverted behavior when supplying min_t

Fixes the inverted behavior of min_t argument in AABB::intersect_ray.

The min_t value passed in is used as t1 when calling ray_box_intersect which sets the upper limit of t range considered for intersections. That mixup is part of a larger issue with a mismatch in intended behavior and usage of min_t between the public intersect_ray and private intersect_ray_opt called recursively to do the search and return the nearest hit.

L1686 in AABB.cpp is attempting to back out the nearest hit value with comparisons to min_t. That's consistent with the defined behavior for that specific intersect_ray_opt overload, but clashes with the expected behavior of min_t in the public method intersect_ray.

This patch introduces a max_t parameter to the intersect_ray_opt method. Internally BVH culling is now done with comparisons to max_t and the user input of min_t is properly passed as the lower limit, t0, of the ray_box_intersect call. The PR also includes a separate fix for a hardcoded cast to float in ray_triangle_intersect.

The existing unit test AABB: intersect_tet is updated to pass min_t = 0 instead of min_t = std::numeric_limits<double>::infinity() which follows the old, inverted behavior. A new unit test (AABB: intersect_cube_min_t) is added following the example given in the bug report (#2518)

Checklist

  • All changes meet libigl style-guidelines.
  • Adds new .cpp file.
  • Adds corresponding unit test.
  • This is a minor change.

Nico Lucarelli and others added 3 commits March 25, 2026 16:52
…arameter to cull BVH and track nearest hit. min_t now yields expected behavior as defined in AABB::intersect_ray comments
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

Successfully merging this pull request may close these issues.

Clarifying min_t in AABB ray intersections

2 participants