From 61d23ff95b71eb71bf7ced09f410ab1acc9a6db4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 6 Oct 2010 14:47:40 +0000 Subject: [PATCH] minor edits so traceray() uses less stack memory, also remove memset() usage, initialize as {0}. no functional change. --- .../blender/render/intern/source/rayshade.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index 724fd9a3110..1172bee7d67 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -697,17 +697,9 @@ static void ray_fadeout(Isect *is, ShadeInput *shi, float *col, float *blendcol, * note: 'col' must be initialized */ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, float *start, float *vec, float *col, ObjectInstanceRen *obi, VlakRen *vlr, int traflag) { - ShadeInput shi; - ShadeResult shr; + ShadeInput shi= {0}; Isect isec; - float f, f1, fr, fg, fb; - float ref[3]; float dist_mir = origshi->mat->dist_mir; - - /* Warning, This is not that nice, and possibly a bit slow for every ray, - however some variables were not initialized properly in, unless using shade_input_initialize(...), we need to do a memset */ - memset(&shi, 0, sizeof(ShadeInput)); - /* end warning! - Campbell */ VECCOPY(isec.start, start); VECCOPY(isec.vec, vec ); @@ -721,8 +713,9 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, flo RE_RC_INIT(isec, shi); if(RE_rayobject_raycast(R.raytree, &isec)) { + ShadeResult shr= {{0}}; float d= 1.0f; - + shi.mask= origshi->mask; shi.osatex= origshi->osatex; shi.depth= 1; /* only used to indicate tracing */ @@ -737,16 +730,15 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, flo shi.light_override= origshi->light_override; shi.mat_override= origshi->mat_override; - memset(&shr, 0, sizeof(ShadeResult)); - shade_ray(&isec, &shi, &shr); if (traflag & RAY_TRA) d= shade_by_transmission(&isec, &shi, &shr); if(depth>0) { + float fr, fg, fb, f, f1; if((shi.mat->mode_l & MA_TRANSP) && shr.alpha < 1.0f) { - float nf, f, f1, refract[3], tracol[4]; + float nf, f, refract[3], tracol[4]; tracol[0]= shi.r; tracol[1]= shi.g; @@ -799,6 +791,7 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, flo if(f!=0.0f) { float mircol[4]; + float ref[3]; reflection(ref, shi.vn, shi.view, NULL); traceray(origshi, origshr, depth-1, shi.co, ref, mircol, shi.obi, shi.vlr, 0);