--- ray/src/rt/rtrace.c 2005/04/14 18:04:12 2.39 +++ ray/src/rt/rtrace.c 2005/05/25 04:44:26 2.41 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rtrace.c,v 2.39 2005/04/14 18:04:12 greg Exp $"; +static const char RCSid[] = "$Id: rtrace.c,v 2.41 2005/05/25 04:44:26 greg Exp $"; #endif /* * rtrace.c - program and variables for individual ray tracing. @@ -96,8 +96,8 @@ typedef void putf_t(double v); static putf_t puta, putd, putf; typedef void oputf_t(RAY *r); -static oputf_t oputo, oputd, oputv, oputl, oputL, oputc, - oputp, oputn, oputN, oputs, oputw, oputm, oputM; +static oputf_t oputo, oputd, oputv, oputl, oputL, oputc, oputp, + oputn, oputN, oputs, oputw, oputW, oputm, oputM, oputdash; static void setoutput(char *vs); static void tranotify(OBJECT obj); @@ -220,6 +220,16 @@ rtrace( /* trace rays from file */ static void +trace_sources(void) /* trace rays to light sources, also */ +{ + int sn; + + for (sn = 0; sn < nsources; sn++) + source[sn].sflags |= SFOLLOW; +} + + +static void setoutput( /* set up output tables */ register char *vs ) @@ -229,6 +239,9 @@ setoutput( /* set up output tables */ castonly = 1; while (*vs) switch (*vs++) { + case 'T': /* trace sources */ + trace_sources(); + /* fall through */ case 't': /* trace */ *table = NULL; table = every_out; @@ -271,12 +284,21 @@ setoutput( /* set up output tables */ case 'w': /* weight */ *table++ = oputw; break; + case 'W': /* coefficient */ + *table++ = oputW; + if (ambounce > 0 && (ambacc > FTINY || ambssamp > 0)) + error(WARNING, + "-otW accuracy depends on -aa 0 -as 0"); + break; case 'm': /* modifier */ *table++ = oputm; break; case 'M': /* material */ *table++ = oputM; break; + case '-': /* dash */ + *table++ = oputdash; + break; } *table = NULL; } @@ -287,7 +309,8 @@ bogusray(void) /* print out empty record */ { thisray.rorg[0] = thisray.rorg[1] = thisray.rorg[2] = thisray.rdir[0] = thisray.rdir[1] = thisray.rdir[2] = 0.0; - rayorigin(&thisray, NULL, PRIMARY, 1.0); + thisray.rmax = 0.0; + rayorigin(&thisray, PRIMARY, NULL, NULL); printvals(&thisray); } @@ -302,7 +325,7 @@ rad( /* compute and print ray value(s) */ VCOPY(thisray.rorg, org); VCOPY(thisray.rdir, dir); thisray.rmax = dmax; - rayorigin(&thisray, NULL, PRIMARY, 1.0); + rayorigin(&thisray, PRIMARY, NULL, NULL); if (castonly) { if (!localhit(&thisray, &thescene)) { if (thisray.ro == &Aftplane) { /* clipped */ @@ -329,7 +352,8 @@ irrad( /* compute immediate irradiance value */ thisray.rorg[i] = org[i] + dir[i]; thisray.rdir[i] = -dir[i]; } - rayorigin(&thisray, NULL, PRIMARY, 1.0); + thisray.rmax = 0.0; + rayorigin(&thisray, PRIMARY, NULL, NULL); /* pretend we hit surface */ thisray.rot = 1.0-1e-4; thisray.rod = 1.0; @@ -442,7 +466,8 @@ ourtrace( /* print ray values */ tabin(r); for (tp = every_out; *tp != NULL; tp++) (**tp)(r); - putchar('\n'); + if (outform == 'a') + putchar('\n'); } @@ -451,7 +476,7 @@ tabin( /* tab in appropriate amount */ RAY *r ) { - register RAY *rp; + const RAY *rp; for (rp = r->parent; rp != NULL; rp = rp->parent) putchar('\t'); @@ -485,9 +510,8 @@ oputv( /* print value */ RAY *r ) { - COLR cout; - if (outform == 'c') { + COLR cout; setcolr(cout, colval(r->rcol,RED), colval(r->rcol,GRN), colval(r->rcol,BLU)); @@ -605,6 +629,20 @@ oputw( /* print weight */ static void +oputW( /* print contribution */ + RAY *r +) +{ + COLOR contr; + + raycontrib(contr, r, PRIMARY); + (*putreal)(colval(contr,RED)); + (*putreal)(colval(contr,GRN)); + (*putreal)(colval(contr,BLU)); +} + + +static void oputm( /* print modifier */ RAY *r ) @@ -634,6 +672,16 @@ oputM( /* print material */ fputs(VOIDID, stdout); } else putchar('*'); + putchar('\t'); +} + + +static void +oputdash( /* output dash (spacer) */ + RAY *r +) +{ + putchar('-'); putchar('\t'); }