summaryrefslogtreecommitdiff
path: root/src/modules/ray/ray_object_sphere.h
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@gnugeneration.com>2017-02-09 04:32:45 -0800
committerVito Caputo <vcaputo@gnugeneration.com>2017-02-09 04:32:45 -0800
commit19dbf88c811c6f853566fda48ad100d1c29faf50 (patch)
tree4a1d563ee5c7808aef11ce89b0b5a0ef73b9d42d /src/modules/ray/ray_object_sphere.h
parent8563edd058bb5e564b5e6c2bafde6636b3fce6ee (diff)
ray: fix mistake in ray:sphere intersection math
Diffstat (limited to 'src/modules/ray/ray_object_sphere.h')
-rw-r--r--src/modules/ray/ray_object_sphere.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/modules/ray/ray_object_sphere.h b/src/modules/ray/ray_object_sphere.h
index 85b3d93..5df4b2e 100644
--- a/src/modules/ray/ray_object_sphere.h
+++ b/src/modules/ray/ray_object_sphere.h
@@ -23,7 +23,7 @@ static inline int ray_object_sphere_intersects_ray(ray_object_sphere_t *sphere,
{
ray_3f_t v = ray_3f_sub(&ray->origin, &sphere->center);
float b = ray_3f_dot(&v, &ray->direction);
- float disc = (sphere->radius * sphere->radius) - ray_3f_dot(&v, &v) + (b * b);
+ float disc = (sphere->radius * sphere->radius) - (ray_3f_dot(&v, &v) - (b * b));
if (disc > 0) {
float i1, i2;
© All Rights Reserved