summaryrefslogtreecommitdiffstats
path: root/libdimension/raytrace.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-05-08 23:21:48 -0600
committerTavian Barnes <tavianator@gmail.com>2010-05-08 23:21:48 -0600
commit7a21db5914dd7a5666e603d66ed3948b659ba2fc (patch)
treebde8e00a1677ba865adae8a82780d1cc832ece8e /libdimension/raytrace.c
parent152362a57dc7fe9dce830ef69118984f854d6375 (diff)
downloaddimension-7a21db5914dd7a5666e603d66ed3948b659ba2fc.tar.xz
New DMNSN_ARRAY_FOREACH() macro, faster than iterating with dmnsn_array_get().
Diffstat (limited to 'libdimension/raytrace.c')
-rw-r--r--libdimension/raytrace.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/libdimension/raytrace.c b/libdimension/raytrace.c
index f5d0885..0c3b738 100644
--- a/libdimension/raytrace.c
+++ b/libdimension/raytrace.c
@@ -315,17 +315,13 @@ dmnsn_raytrace_lighting(dmnsn_raytrace_state *state)
return;
}
- const dmnsn_light *light;
-
/* Iterate over each light */
- for (size_t i = 0; i < dmnsn_array_size(state->scene->lights); ++i) {
- dmnsn_array_get(state->scene->lights, i, &light);
-
- dmnsn_color light_color = dmnsn_raytrace_light_ray(state, light);
+ DMNSN_ARRAY_FOREACH (dmnsn_light **, light, state->scene->lights) {
+ dmnsn_color light_color = dmnsn_raytrace_light_ray(state, *light);
if (!dmnsn_color_is_black(light_color)) {
if (state->scene->quality & DMNSN_RENDER_FINISH) {
dmnsn_vector ray = dmnsn_vector_normalize(
- dmnsn_vector_sub(light->x0, state->r)
+ dmnsn_vector_sub((*light)->x0, state->r)
);
/* Get this light's color contribution to the object */