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

ray: Nudge ray direction of axis when intersecting #217

Merged
merged 1 commit into from
Mar 23, 2021

Conversation

jadahl
Copy link
Contributor

@jadahl jadahl commented Mar 23, 2021

The formula used to calculate the inverse of the direction vector
doesn't handle the direction vector aligning with an axis. Depending on
the SIMD (or not SIMD) implementation used, a axis aligned vector would
either remain the same, or e.g. end up with NaN components messing up
any future calculations.

Fixing the math to handle this is non-trivial, so for now work around
this by nudging the direction vector slightly off axis so that it has a
better hand of hitting the right box even when the direction is axis
aligned.

Closes: #214

Fixes #...

Proposed changes:

  • ...

Benchmark results:

  • Before: ...
  • After: ...

Test suite changes:

  • ...

The formula used to calculate the inverse of the direction vector
doesn't handle the direction vector aligning with an axis. Depending on
the SIMD (or not SIMD) implementation used, a axis aligned vector would
either remain the same, or e.g. end up with NaN components messing up
any future calculations.

Fixing the math to handle this is non-trivial, so for now work around
this by nudging the direction vector slightly off axis so that it has a
better hand of hitting the right box even when the direction is axis
aligned.

Closes: ebassi#214
tests/ray.c Outdated Show resolved Hide resolved
Copy link
Owner

@ebassi ebassi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good; a couple of fixes to the test suite to make it more idiomatic.

tests/ray.c Show resolved Hide resolved
tests/ray.c Show resolved Hide resolved
tests/ray.c Show resolved Hide resolved
tests/ray.c Show resolved Hide resolved
@ebassi ebassi merged commit 1ec2948 into ebassi:master Mar 23, 2021
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.

Graphene can't handle axis aligned ray directions
3 participants