ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/rtrace.c
(Generate patch)

Comparing ray/src/rt/rtrace.c (file contents):
Revision 2.39 by greg, Thu Apr 14 18:04:12 2005 UTC vs.
Revision 2.46 by greg, Fri Jun 10 20:44:00 2005 UTC

# Line 50 | Line 50 | void  (*trace)() = NULL;               /* trace call */
50  
51   char  *tralist[128];                    /* list of modifers to trace (or no) */
52   int  traincl = -1;                      /* include == 1, exclude == 0 */
53 < #define  MAXTSET        511             /* maximum number in trace set */
53 > #ifndef  MAXTSET
54 > #define  MAXTSET        1024            /* maximum number in trace set */
55 > #endif
56   OBJECT  traset[MAXTSET+1]={0};          /* trace include/exclude set */
57  
58   int  hresolu = 0;                       /* horizontal (scan) size */
# Line 74 | Line 76 | double  specjitter = 1.;               /* specular sampling jitter
76  
77   int  backvis = 1;                       /* back face visibility */
78  
79 < int  maxdepth = 8;                      /* maximum recursion depth */
79 > int  maxdepth = -10;                    /* maximum recursion depth */
80   double  minweight = 2e-3;               /* minimum ray weight */
81  
82   char  *ambfile = NULL;                  /* ambient file name */
# Line 96 | Line 98 | typedef void putf_t(double v);
98   static putf_t puta, putd, putf;
99  
100   typedef void oputf_t(RAY *r);
101 < static oputf_t  oputo, oputd, oputv, oputl, oputL, oputc,
102 <                oputp, oputn, oputN, oputs, oputw, oputm, oputM;
101 > static oputf_t  oputo, oputd, oputv, oputl, oputL, oputc, oputp,
102 >                oputn, oputN, oputs, oputw, oputW, oputm, oputM, oputtilde;
103  
104   static void setoutput(char *vs);
105   static void tranotify(OBJECT obj);
# Line 148 | Line 150 | rtrace(                                /* trace rays from file */
150          char  *fname
151   )
152   {
153 <        long  vcount = hresolu>1 ? hresolu*vresolu : vresolu;
153 >        unsigned long  vcount = (hresolu > 1) ? (unsigned long)hresolu*vresolu
154 >                                              : vresolu;
155          long  nextflush = hresolu;
156          FILE  *fp;
157          double  d;
# Line 160 | Line 163 | rtrace(                                /* trace rays from file */
163                  sprintf(errmsg, "cannot open input file \"%s\"", fname);
164                  error(SYSTEM, errmsg);
165          }
163 #ifdef _WIN32
166          if (inform != 'a')
167                  SET_FILE_BINARY(fp);
166 #endif
168                                          /* set up output */
169          setoutput(outvals);
170          switch (outform) {
# Line 189 | Line 190 | rtrace(                                /* trace rays from file */
190                  d = normalize(direc);
191                  if (d == 0.0) {                         /* zero ==> flush */
192                          bogusray();
193 <                        if (--nextflush <= 0 || vcount <= 0) {
193 >                        if (--nextflush <= 0 || !vcount) {
194                                  fflush(stdout);
195                                  nextflush = hresolu;
196                          }
# Line 201 | Line 202 | rtrace(                                /* trace rays from file */
202                          else
203                                  rad(orig, direc, lim_dist ? d : 0.0);
204                                                          /* flush if time */
205 <                        if (--nextflush == 0) {
205 >                        if (!--nextflush) {
206                                  fflush(stdout);
207                                  nextflush = hresolu;
208                          }
209                  }
210                  if (ferror(stdout))
211                          error(SYSTEM, "write error");
212 <                if (--vcount == 0)                      /* check for end */
212 >                if (vcount && !--vcount)                /* check for end */
213                          break;
214          }
215          fflush(stdout);
216 <        if (vcount > 0)
217 <                error(USER, "read error");
216 >        if (vcount)
217 >                error(USER, "unexpected EOF on input");
218          if (fname != NULL)
219                  fclose(fp);
220   }
221  
222  
223   static void
224 + trace_sources(void)                     /* trace rays to light sources, also */
225 + {
226 +        int     sn;
227 +        
228 +        for (sn = 0; sn < nsources; sn++)
229 +                source[sn].sflags |= SFOLLOW;
230 + }
231 +
232 +
233 + static void
234   setoutput(                              /* set up output tables */
235          register char  *vs
236   )
# Line 229 | Line 240 | setoutput(                             /* set up output tables */
240          castonly = 1;
241          while (*vs)
242                  switch (*vs++) {
243 +                case 'T':                               /* trace sources */
244 +                        if (!*vs) break;
245 +                        trace_sources();
246 +                        /* fall through */
247                  case 't':                               /* trace */
248 +                        if (!*vs) break;
249                          *table = NULL;
250                          table = every_out;
251                          trace = ourtrace;
# Line 271 | Line 287 | setoutput(                             /* set up output tables */
287                  case 'w':                               /* weight */
288                          *table++ = oputw;
289                          break;
290 +                case 'W':                               /* coefficient */
291 +                        *table++ = oputW;
292 +                        if (ambounce > 0 && (ambacc > FTINY || ambssamp > 0))
293 +                                error(WARNING,
294 +                                        "-otW accuracy depends on -aa 0 -as 0");
295 +                        break;
296                  case 'm':                               /* modifier */
297                          *table++ = oputm;
298                          break;
299                  case 'M':                               /* material */
300                          *table++ = oputM;
301                          break;
302 +                case '~':                               /* tilde */
303 +                        *table++ = oputtilde;
304 +                        break;
305                  }
306          *table = NULL;
307   }
# Line 287 | Line 312 | bogusray(void)                 /* print out empty record */
312   {
313          thisray.rorg[0] = thisray.rorg[1] = thisray.rorg[2] =
314          thisray.rdir[0] = thisray.rdir[1] = thisray.rdir[2] = 0.0;
315 <        rayorigin(&thisray, NULL, PRIMARY, 1.0);
315 >        thisray.rmax = 0.0;
316 >        rayorigin(&thisray, PRIMARY, NULL, NULL);
317          printvals(&thisray);
318   }
319  
# Line 302 | Line 328 | rad(           /* compute and print ray value(s) */
328          VCOPY(thisray.rorg, org);
329          VCOPY(thisray.rdir, dir);
330          thisray.rmax = dmax;
331 <        rayorigin(&thisray, NULL, PRIMARY, 1.0);
331 >        rayorigin(&thisray, PRIMARY, NULL, NULL);
332          if (castonly) {
333                  if (!localhit(&thisray, &thescene)) {
334                          if (thisray.ro == &Aftplane) {  /* clipped */
# Line 329 | Line 355 | irrad(                 /* compute immediate irradiance value */
355                  thisray.rorg[i] = org[i] + dir[i];
356                  thisray.rdir[i] = -dir[i];
357          }
358 <        rayorigin(&thisray, NULL, PRIMARY, 1.0);
358 >        thisray.rmax = 0.0;
359 >        rayorigin(&thisray, PRIMARY, NULL, NULL);
360                                          /* pretend we hit surface */
361          thisray.rot = 1.0-1e-4;
362          thisray.rod = 1.0;
# Line 442 | Line 469 | ourtrace(                              /* print ray values */
469          tabin(r);
470          for (tp = every_out; *tp != NULL; tp++)
471                  (**tp)(r);
472 <        putchar('\n');
472 >        if (outform == 'a')
473 >                putchar('\n');
474   }
475  
476  
# Line 451 | Line 479 | tabin(                         /* tab in appropriate amount */
479          RAY  *r
480   )
481   {
482 <        register RAY  *rp;
482 >        const RAY  *rp;
483  
484          for (rp = r->parent; rp != NULL; rp = rp->parent)
485                  putchar('\t');
# Line 485 | Line 513 | oputv(                         /* print value */
513          RAY  *r
514   )
515   {
488        COLR  cout;
489        
516          if (outform == 'c') {
517 +                COLR  cout;
518                  setcolr(cout,   colval(r->rcol,RED),
519                                  colval(r->rcol,GRN),
520                                  colval(r->rcol,BLU));
# Line 605 | Line 632 | oputw(                         /* print weight */
632  
633  
634   static void
635 + oputW(                          /* print contribution */
636 +        RAY  *r
637 + )
638 + {
639 +        COLOR   contr;
640 +
641 +        raycontrib(contr, r, PRIMARY);
642 +        (*putreal)(colval(contr,RED));
643 +        (*putreal)(colval(contr,GRN));
644 +        (*putreal)(colval(contr,BLU));
645 + }
646 +
647 +
648 + static void
649   oputm(                          /* print modifier */
650          RAY  *r
651   )
# Line 635 | Line 676 | oputM(                         /* print material */
676          } else
677                  putchar('*');
678          putchar('\t');
679 + }
680 +
681 +
682 + static void
683 + oputtilde(                      /* output tilde (spacer) */
684 +        RAY  *r
685 + )
686 + {
687 +        fputs("~\t", stdout);
688   }
689  
690  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines