--- ray/src/rt/rtrace.c 2004/03/30 16:13:01 2.37 +++ 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.37 2004/03/30 16:13:01 schorsch 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. @@ -85,7 +85,7 @@ int ambres = 256; /* ambient resolution */ int ambdiv = 1024; /* ambient divisions */ int ambssamp = 512; /* ambient super-samples */ int ambounce = 0; /* ambient bounces */ -char *amblist[128]; /* ambient include/exclude list */ +char *amblist[AMBLLEN]; /* ambient include/exclude list */ int ambincl = -1; /* include == 1, exclude == 0 */ static int castonly = 0; @@ -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; +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,9 +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; } @@ -284,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); } @@ -299,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 */ @@ -326,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; @@ -439,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'); } @@ -448,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'); @@ -482,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)); @@ -602,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 ) @@ -613,6 +654,34 @@ oputm( /* print modifier */ fputs(VOIDID, stdout); else putchar('*'); + putchar('\t'); +} + + +static void +oputM( /* print material */ + RAY *r +) +{ + OBJREC *mat; + + if (r->ro != NULL) { + if ((mat = findmaterial(r->ro)) != NULL) + fputs(mat->oname, stdout); + else + fputs(VOIDID, stdout); + } else + putchar('*'); + putchar('\t'); +} + + +static void +oputdash( /* output dash (spacer) */ + RAY *r +) +{ + putchar('-'); putchar('\t'); }