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

Some missing ray functions #399

Merged
merged 13 commits into from
Mar 23, 2024
Merged

Some missing ray functions #399

merged 13 commits into from
Mar 23, 2024

Conversation

recp
Copy link
Owner

@recp recp commented Mar 21, 2024

Some missing ray functions:

  • glm_ray_sphere(origin, dir, s, &t1, &t2)) -> bool ray sphere intersection
  • glm_ray_at(orig, dir, t, &point) point by parameter
  • glm_vec3_faceforward(N, I, Nref, dest)
  • glm_vec[2|3|4]_reflect(I, N, &dest) reflect
  • glm_vec[2|3|4]_refract(I, N, eta, &dest) refract
  • tests
  • docs

glm_ray_sphere():

  • t1 > 0, t2 > 0: ray intersects the sphere at t1 and t2 both ahead of the origin
  • t1 < 0, t2 > 0: ray starts inside the sphere, exits at t2
  • t1 < 0, t2 < 0: no intersection ahead of the ray
  • the caller can check if the intersection points (t1 and t2) fall within a specific range (for example, tmin < t1, t2 < tmax) to determine if the intersections are within a desired segment of the ray

PS: Since there are multiple FPUs on modern CPUs, I see no benefit to use SIMD for reflect() and refract() for now but it is in TODOs for future, not tested but may bring extra overhead, maybe!.

@recp recp mentioned this pull request Mar 21, 2024
@recp recp merged commit 707bff0 into master Mar 23, 2024
74 checks passed
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.

None yet

1 participant