summaryrefslogtreecommitdiff
path: root/src/modules/ray/ray.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2017-09-13 18:04:31 -0700
committerVito Caputo <vcaputo@pengaru.com>2017-09-14 14:27:52 -0700
commit445e9481bbe598d1eabcae7a70534c51a52c6de5 (patch)
treecbc7156b0775a8b00ed92714f20aa882a7bfd51a /src/modules/ray/ray.c
parent121846b0e35607bf8b48d5ce304a65e2657be455 (diff)
ray: simplify object iterators using sentinel type
Trivial optimization eliminates some instructions from the hot path, no need to maintain a separate index from the current object pointer.
Diffstat (limited to 'src/modules/ray/ray.c')
-rw-r--r--src/modules/ray/ray.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/modules/ray/ray.c b/src/modules/ray/ray.c
index 60784db..4af9715 100644
--- a/src/modules/ray/ray.c
+++ b/src/modules/ray/ray.c
@@ -73,6 +73,8 @@ static ray_object_t objects[] = {
.center = { .x = 0.2, .y = -1.25, .z = 0.0 },
.radius = 0.6f,
}
+ }, {
+ .type = RAY_OBJECT_TYPE_SENTINEL,
}
};
@@ -89,6 +91,8 @@ static ray_object_t lights[] = {
},
}
}
+ }, {
+ .type = RAY_OBJECT_TYPE_SENTINEL,
}
};
@@ -105,9 +109,7 @@ static ray_camera_t camera = {
static ray_scene_t scene = {
.objects = objects,
- .n_objects = nelems(objects),
.lights = lights,
- .n_lights = nelems(lights),
.ambient_color = { .x = 1.0f, .y = 1.0f, .z = 1.0f },
.ambient_brightness = .04f,
};
© All Rights Reserved