diff options
author | Tavian Barnes <tavianator@gmail.com> | 2011-08-21 15:01:03 -0600 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2011-08-21 15:01:03 -0600 |
commit | cfc4e660bc33bfb63de805c7ef70a4a6836b37d1 (patch) | |
tree | 1f724492cedbc25007b71de4e189fdf6fbd761db /libdimension | |
parent | 942fd9ff8e267b361de580a95fa247e486120891 (diff) | |
download | dimension-cfc4e660bc33bfb63de805c7ef70a4a6836b37d1.tar.xz |
Don't evaluate the background color if we don't have to.
Diffstat (limited to 'libdimension')
-rw-r--r-- | libdimension/raytrace.c | 11 |
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; } |