diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-05-08 23:21:48 -0600 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-05-08 23:21:48 -0600 |
commit | 7a21db5914dd7a5666e603d66ed3948b659ba2fc (patch) | |
tree | bde8e00a1677ba865adae8a82780d1cc832ece8e /libdimension/raytrace.c | |
parent | 152362a57dc7fe9dce830ef69118984f854d6375 (diff) | |
download | dimension-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.c | 10 |
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 */ |