fix: correct min_t semantics in AABB::intersect_ray#2536
Open
nmlucarelli wants to merge 3 commits intolibigl:mainfrom
Open
fix: correct min_t semantics in AABB::intersect_ray#2536nmlucarelli wants to merge 3 commits intolibigl:mainfrom
nmlucarelli wants to merge 3 commits intolibigl:mainfrom
Conversation
…arameter to cull BVH and track nearest hit. min_t now yields expected behavior as defined in AABB::intersect_ray comments
… in ray_mesh_intersect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2518 .
Breaking fix for users who have adapted to the inverted behavior when supplying
min_tFixes the inverted behavior of
min_targument inAABB::intersect_ray.The
min_tvalue passed in is used ast1when callingray_box_intersectwhich 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 ofmin_tbetween the publicintersect_rayand privateintersect_ray_optcalled 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 specificintersect_ray_optoverload, but clashes with the expected behavior ofmin_tin the public methodintersect_ray.This patch introduces a
max_tparameter to theintersect_ray_optmethod. Internally BVH culling is now done with comparisons tomax_tand the user input ofmin_tis properly passed as the lower limit,t0, of theray_box_intersectcall. The PR also includes a separate fix for a hardcoded cast tofloatinray_triangle_intersect.The existing unit test AABB: intersect_tet is updated to pass
min_t = 0instead ofmin_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