Fix trace_ray()
function in the lightmapper missing hits with large triangles.
#83040
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.
The DDA traversal had a conceptual error where it did an early termination of the search if it hit a triangle, but it didn't check if the hit position was inside the bounds of the cell being traversed. This can aid to fix light leaks such as the ones found in issue #75440.
I don't have much in the way of good comparison pics as the effectiveness of this fix is better observed with another change I'll introduce in my indirect bounces PR, which is the possibility of tracing lights on each bounce. In that scenario there's leaks that are impossible to fix otherwise that this PR will address.
What I did notice however is an increase in baking times as expected.
That's around ~10% slower bake times for what might not be a very noticeable fix right now, but it's hard to deny the fact the algorithm itself is wrong and can cause errors. The slower bake times are easily explained by the fact it's not doing early termination anymore. The fact the difference shows up means there was a significant amount of cases where the light mapper was not finding the actual closest hit but something further away.
So in short, there might be not be easy to find scenarios where we can confirm this fixes something right now, but it'd be for the best for the code to not work incorrectly.