From 84a473d0369c8d676a5a42dcbd11039360668e40 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 2 Jun 2017 10:31:52 -0700 Subject: ray: separate lights from objects This may need to be undone in the future when more sophisticated lights, like area lights, are implemented. For now I can avoid polluting the objects list with the lights by strictly separating them. --- src/modules/ray/ray.c | 10 +++++++--- src/modules/ray/ray_scene.c | 3 --- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src/modules/ray') diff --git a/src/modules/ray/ray.c b/src/modules/ray/ray.c index 185b412..1143db1 100644 --- a/src/modules/ray/ray.c +++ b/src/modules/ray/ray.c @@ -73,7 +73,11 @@ static ray_object_t objects[] = { .center = { .x = 0.2, .y = -1.25, .z = 0.0 }, .radius = 0.6f, } - }, { + } +}; + +static ray_object_t lights[] = { + { .light = { .type = RAY_OBJECT_TYPE_LIGHT, .brightness = 1.0, @@ -102,8 +106,8 @@ static ray_camera_t camera = { static ray_scene_t scene = { .objects = objects, .n_objects = nelems(objects), - .lights = &objects[5], - .n_lights = 1, + .lights = lights, + .n_lights = nelems(lights), .ambient_color = { .x = 1.0f, .y = 1.0f, .z = 1.0f }, .ambient_brightness = .04f, }; diff --git a/src/modules/ray/ray_scene.c b/src/modules/ray/ray_scene.c index 50da28a..a95058f 100644 --- a/src/modules/ray/ray_scene.c +++ b/src/modules/ray/ray_scene.c @@ -23,9 +23,6 @@ static inline int ray_is_obstructed(ray_scene_t *scene, ray_ray_t *ray, float di for (i = 0; i < scene->n_objects; i++) { float ood; - if (scene->objects[i].type == RAY_OBJECT_TYPE_LIGHT) - continue; - if (ray_object_intersects_ray(&scene->objects[i], ray, &ood) && ood < distance) { return 1; -- cgit v1.2.1