-
Notifications
You must be signed in to change notification settings - Fork 1
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
Raycasts miss exact matches on boxes #7
Comments
This appears to be a bug in the calculation of the inverse ray vector. The problem is that given a ray like the above: |
No, this is actually an expected property of the rays. See: https://tavianator.com/fast-branchless-raybounding-box-intersections/ |
This is actually caused by |
Waiting to hear from the author about whether or not anything can be done about this. I can't work it out from the second part of the article. |
I cover this in my latest post: https://tavianator.com/2022/ray_box_boundary.html. TLDR: - tmin = max(min(t1, t2), tmin);
- tmax = min(max(t1, t2), tmax);
+ tmin = min(max(t1, tmin), max(t2, tmin));
+ tmax = max(min(t1, tmax), min(t2, tmax));
...
- return tmin < tmax;
+ return tmin <= tmax; |
Ah, thank you! Sorry for the ridiculous delay in replying. I had no idea this had even been posted (I get far too many GitHub notifications for any human to deal with!). 🙂 |
For example:
A box
b
is placed at(32, 32)
of size(64, 64)
.A ray is cast from
(16, 32)
to(256, 32)
. The ray should intersectb
because it passes through32
on the Y axis, and that's the minimum Y value ofb
. However, the current implementation misses the intersection.The text was updated successfully, but these errors were encountered: