From 69e3a23a89b0b4567de92c004946113ce2db0151 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 2 Jun 2017 10:20:35 -0700 Subject: ray: simplify trace_ray inner loop slightly Remove unnecessary nearest_object check, the distance comparison alone is sufficient when initialized to INFINITY. --- src/modules/ray/ray_scene.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/modules') diff --git a/src/modules/ray/ray_scene.c b/src/modules/ray/ray_scene.c index eb18d08..50da28a 100644 --- a/src/modules/ray/ray_scene.c +++ b/src/modules/ray/ray_scene.c @@ -155,8 +155,7 @@ static ray_color_t trace_ray(ray_scene_t *scene, ray_ray_t *ray, unsigned depth) if (ray_object_intersects_ray(&scene->objects[i], ray, &distance)) { /* Is it the nearest intersection? */ - if (!nearest_object || - distance < nearest_object_distance) { + if (distance < nearest_object_distance) { nearest_object = &scene->objects[i]; nearest_object_distance = distance; } -- cgit v1.2.3