summaryrefslogtreecommitdiffstats
path: root/libdimension/raytrace.c
diff options
context:
space:
mode:
Diffstat (limited to 'libdimension/raytrace.c')
-rw-r--r--libdimension/raytrace.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/libdimension/raytrace.c b/libdimension/raytrace.c
index 056e7bf..7cc99ba 100644
--- a/libdimension/raytrace.c
+++ b/libdimension/raytrace.c
@@ -465,12 +465,10 @@ dmnsn_raytrace_shoot(dmnsn_raytrace_state *state, dmnsn_line ray)
--state->reclevel;
- /* Calculate the background color */
- dmnsn_color color = dmnsn_raytrace_background(state, ray);
-
dmnsn_intersection intersection;
bool reset = state->reclevel == state->scene->reclimit - 1;
if (dmnsn_prtree_intersection(state->prtree, ray, &intersection, reset)) {
+ /* Found an intersection */
dmnsn_initialize_raytrace_state(state, &intersection);
/* Pigment */
@@ -494,8 +492,9 @@ dmnsn_raytrace_shoot(dmnsn_raytrace_state *state, dmnsn_line ray)
dmnsn_raytrace_transparency(state);
}
- color = dmnsn_color_add(state->diffuse, state->additional);
+ return dmnsn_color_add(state->diffuse, state->additional);
+ } else {
+ /* No intersection, return the background color */
+ return dmnsn_raytrace_background(state, ray);
}
-
- return color;
}