From cfc4e660bc33bfb63de805c7ef70a4a6836b37d1 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sun, 21 Aug 2011 15:01:03 -0600 Subject: Don't evaluate the background color if we don't have to. --- libdimension/raytrace.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'libdimension') 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; } -- cgit v1.2.3