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

Bug: rect hit returning NaN's, Infinities #681

Closed
Walther opened this issue Jul 24, 2020 · 3 comments
Closed

Bug: rect hit returning NaN's, Infinities #681

Walther opened this issue Jul 24, 2020 · 3 comments

Comments

@Walther
Copy link

Walther commented Jul 24, 2020

auto t = (k-r.origin().y()) / r.direction().y();
if (t < t0 || t > t1)
return false;

If r.direction().y() happens to be zero, you'll get t=infinity. This infinity will get passed along, because infinity > infinity is false so the if branch is not taken.

Additionally, if k-r.origin().y() happens to be 0 as well, you'll get 0.0 / 0.0 resulting in a NaN that again gets passed along.

This exists in all three cases of rect, with different axes being the culprit.

Caveat emptor: I bumped into this in my Rust implementation, so some specific details may be slightly different, including in case infinity & NaN semantics are slightly different in C++. But I think this should be applicable.


Offtopic sidenote: wonder if it would be worth it to make the distance be named something else than t, considering some other functions in the book use t or t0, t1 for time

@hollasch
Copy link
Collaborator

hollasch commented Jul 24, 2020

Regarding the side note: see #678, currently in progress now resolved.

@hollasch hollasch self-assigned this Jul 24, 2020
@hollasch hollasch added this to the v3.2.1 milestone Jul 24, 2020
@hollasch hollasch removed their assignment Aug 20, 2020
@hollasch hollasch modified the milestones: v3.2.1, v3.2.2 Sep 30, 2020
@hollasch hollasch modified the milestones: v3.2.2, v3.3.0 Oct 10, 2020
@hollasch
Copy link
Collaborator

See #756

@hollasch hollasch modified the milestones: v3.3.0, Backlog, v4.0.0 Oct 12, 2020
@hollasch hollasch self-assigned this Dec 14, 2020
@hollasch hollasch assigned trevordblack and unassigned hollasch Jan 10, 2021
@hollasch hollasch assigned hollasch and unassigned trevordblack Feb 15, 2021
hollasch added a commit that referenced this issue Aug 13, 2021
This reverts commit b0fbca7b0c6c4e77491b1bbebc6ed5fe939d912e.

Removing these primitives, since we will not be using them. This change
also removes the temporary test scene for quads.

Resolves #292
Resolves #662
Resolves #681
Resolves #756
Resolves #780
@hollasch
Copy link
Collaborator

Fixed in ed119af

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

No branches or pull requests

3 participants