From 19dbf88c811c6f853566fda48ad100d1c29faf50 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Thu, 9 Feb 2017 04:32:45 -0800 Subject: ray: fix mistake in ray:sphere intersection math --- src/modules/ray/ray_object_sphere.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules/ray/ray_object_sphere.h') 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; -- cgit v1.2.1