Hit intersectObjects(Scene *world, Ray *ray) { Hit tempHit; Scalar closest = 1000000; // The closest so far Scalar t; tempHit.obj = NULL; node_t *node = world->objects->head; while (node != NULL) { assert(node->data); Object *temp = (Object *)(node->data); t = temp->hits(temp, ray); if(t > THRESHOLD && t < closest) { tempHit.obj = temp; tempHit.t = t; closest = t; } node = node->next; } return tempHit; } // intersectObjects