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.34 by greg, Wed Sep 24 14:55:54 2003 UTC vs.
Revision 2.39 by greg, Thu Apr 14 18:04:12 2005 UTC

# Line 25 | Line 25 | static const char      RCSid[] = "$Id$";
25  
26   #include  "platform.h"
27   #include  "ray.h"
28 + #include  "ambient.h"
29 + #include  "source.h"
30   #include  "otypes.h"
31   #include  "resolu.h"
32  
# Line 46 | Line 48 | int  do_irrad = 0;                     /* compute irradiance? */
48  
49   void  (*trace)() = NULL;                /* trace call */
50  
49 extern void  ambnotify(), tranotify();
50 void  (*addobjnotify[])() = {ambnotify, tranotify, NULL};
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 */
# Line 57 | Line 57 | int  hresolu = 0;                      /* horizontal (scan) size */
57   int  vresolu = 0;                       /* vertical resolution */
58  
59   double  dstrsrc = 0.0;                  /* square source distribution */
60 < double  shadthresh = .05;               /* shadow threshold */
61 < double  shadcert = .5;                  /* shadow certainty */
60 > double  shadthresh = .03;               /* shadow threshold */
61 > double  shadcert = .75;                 /* shadow certainty */
62   int  directrelay = 2;                   /* number of source relays */
63   int  vspretest = 512;                   /* virtual source pretest density */
64   int  directvis = 1;                     /* sources visible? */
# Line 80 | Line 80 | double  minweight = 2e-3;              /* minimum ray weight */
80   char  *ambfile = NULL;                  /* ambient file name */
81   COLOR  ambval = BLKCOLOR;               /* ambient value */
82   int  ambvwt = 0;                        /* initial weight for ambient value */
83 < double  ambacc = 0.1;                   /* ambient accuracy */
83 > double  ambacc = 0.15;                  /* ambient accuracy */
84   int  ambres = 256;                      /* ambient resolution */
85   int  ambdiv = 1024;                     /* ambient divisions */
86   int  ambssamp = 512;                    /* ambient super-samples */
87   int  ambounce = 0;                      /* ambient bounces */
88 < char  *amblist[128];                    /* ambient include/exclude list */
88 > char  *amblist[AMBLLEN];                /* ambient include/exclude list */
89   int  ambincl = -1;                      /* include == 1, exclude == 0 */
90  
91 + static int  castonly = 0;
92  
93   static RAY  thisray;                    /* for our convenience */
94  
95 < static void  oputo(), oputd(), oputv(), oputl(), oputL(), oputc(),
96 <                oputp(), oputn(), oputN(), oputs(), oputw(), oputm();
95 > typedef void putf_t(double v);
96 > static putf_t puta, putd, putf;
97  
98 < static void  ourtrace(), tabin();
99 < static void  (*ray_out[16])(), (*every_out[16])();
100 < static int  castonly = 0;
98 > typedef void oputf_t(RAY *r);
99 > static oputf_t  oputo, oputd, oputv, oputl, oputL, oputc,
100 >                oputp, oputn, oputN, oputs, oputw, oputm, oputM;
101  
102 < static void  puta(), putf(), putd();
102 > static void setoutput(char *vs);
103 > static void tranotify(OBJECT obj);
104 > static void bogusray(void);
105 > static void rad(FVECT  org, FVECT  dir, double  dmax);
106 > static void irrad(FVECT  org, FVECT  dir);
107 > static void printvals(RAY  *r);
108 > static int getvec(FVECT  vec, int  fmt, FILE  *fp);
109 > static void tabin(RAY  *r);
110 > static void ourtrace(RAY  *r);
111  
112 < static void  (*putreal)();
112 > static oputf_t *ray_out[16], *every_out[16];
113 > static putf_t *putreal;
114  
115 < void    bogusray(), rad(), irrad(), printvals();
115 > void  (*addobjnotify[])() = {ambnotify, tranotify, NULL};
116  
117  
118   void
119 < quit(code)                      /* quit program */
120 < int  code;
119 > quit(                   /* quit program */
120 >        int  code
121 > )
122   {
123   #ifndef  NON_POSIX /* XXX we don't clean up elsewhere? */
124          headclean();            /* delete header file */
# Line 117 | Line 128 | int  code;
128   }
129  
130  
131 < char *
132 < formstr(f)                              /* return format identifier */
133 < int  f;
131 > extern char *
132 > formstr(                                /* return format identifier */
133 >        int  f
134 > )
135   {
136          switch (f) {
137          case 'a': return("ascii");
# Line 131 | Line 143 | int  f;
143   }
144  
145  
146 < void
147 < rtrace(fname)                           /* trace rays from file */
148 < char  *fname;
146 > extern void
147 > rtrace(                         /* trace rays from file */
148 >        char  *fname
149 > )
150   {
151          long  vcount = hresolu>1 ? hresolu*vresolu : vresolu;
152          long  nextflush = hresolu;
# Line 206 | Line 219 | char  *fname;
219   }
220  
221  
222 < setoutput(vs)                           /* set up output tables */
223 < register char  *vs;
222 > static void
223 > setoutput(                              /* set up output tables */
224 >        register char  *vs
225 > )
226   {
227 <        extern void  (*trace)();
213 <        register void (**table)() = ray_out;
227 >        register oputf_t **table = ray_out;
228  
229          castonly = 1;
230          while (*vs)
# Line 260 | Line 274 | register char  *vs;
274                  case 'm':                               /* modifier */
275                          *table++ = oputm;
276                          break;
277 +                case 'M':                               /* material */
278 +                        *table++ = oputM;
279 +                        break;
280                  }
281          *table = NULL;
282   }
283  
284  
285 < void
286 < bogusray()                      /* print out empty record */
285 > static void
286 > bogusray(void)                  /* print out empty record */
287   {
288          thisray.rorg[0] = thisray.rorg[1] = thisray.rorg[2] =
289          thisray.rdir[0] = thisray.rdir[1] = thisray.rdir[2] = 0.0;
# Line 275 | Line 292 | bogusray()                     /* print out empty record */
292   }
293  
294  
295 < void
296 < rad(org, dir, dmax)             /* compute and print ray value(s) */
297 < FVECT  org, dir;
298 < double  dmax;
295 > static void
296 > rad(            /* compute and print ray value(s) */
297 >        FVECT  org,
298 >        FVECT  dir,
299 >        double  dmax
300 > )
301   {
302          VCOPY(thisray.rorg, org);
303          VCOPY(thisray.rdir, dir);
# Line 298 | Line 317 | double dmax;
317   }
318  
319  
320 < void
321 < irrad(org, dir)                 /* compute immediate irradiance value */
322 < FVECT  org, dir;
320 > static void
321 > irrad(                  /* compute immediate irradiance value */
322 >        FVECT  org,
323 >        FVECT  dir
324 > )
325   {
326          register int  i;
327  
# Line 321 | Line 342 | FVECT  org, dir;
342   }
343  
344  
345 < void
346 < printvals(r)                    /* print requested ray values */
347 < RAY  *r;
345 > static void
346 > printvals(                      /* print requested ray values */
347 >        RAY  *r
348 > )
349   {
350 <        register void  (**tp)();
350 >        register oputf_t **tp;
351  
352          if (ray_out[0] == NULL)
353                  return;
# Line 336 | Line 358 | RAY  *r;
358   }
359  
360  
361 < int
362 < getvec(vec, fmt, fp)            /* get a vector from fp */
363 < register FVECT  vec;
364 < int  fmt;
365 < FILE  *fp;
361 > static int
362 > getvec(         /* get a vector from fp */
363 >        register FVECT  vec,
364 >        int  fmt,
365 >        FILE  *fp
366 > )
367   {
368          static float  vf[3];
369          static double  vd[3];
# Line 373 | Line 396 | FILE  *fp;
396   }
397  
398  
399 < void
400 < tranotify(obj)                  /* record new modifier */
401 < OBJECT  obj;
399 > static void
400 > tranotify(                      /* record new modifier */
401 >        OBJECT  obj
402 > )
403   {
404          static int  hitlimit = 0;
405          register OBJREC  *o = objptr(obj);
# Line 402 | Line 426 | OBJECT obj;
426  
427  
428   static void
429 < ourtrace(r)                             /* print ray values */
430 < RAY  *r;
429 > ourtrace(                               /* print ray values */
430 >        RAY  *r
431 > )
432   {
433 <        register void  (**tp)();
433 >        register oputf_t **tp;
434  
435          if (every_out[0] == NULL)
436                  return;
# Line 422 | Line 447 | RAY  *r;
447  
448  
449   static void
450 < tabin(r)                                /* tab in appropriate amount */
451 < RAY  *r;
450 > tabin(                          /* tab in appropriate amount */
451 >        RAY  *r
452 > )
453   {
454          register RAY  *rp;
455  
# Line 433 | Line 459 | RAY  *r;
459  
460  
461   static void
462 < oputo(r)                                /* print origin */
463 < RAY  *r;
462 > oputo(                          /* print origin */
463 >        RAY  *r
464 > )
465   {
466          (*putreal)(r->rorg[0]);
467          (*putreal)(r->rorg[1]);
# Line 443 | Line 470 | RAY  *r;
470  
471  
472   static void
473 < oputd(r)                                /* print direction */
474 < RAY  *r;
473 > oputd(                          /* print direction */
474 >        RAY  *r
475 > )
476   {
477          (*putreal)(r->rdir[0]);
478          (*putreal)(r->rdir[1]);
# Line 453 | Line 481 | RAY  *r;
481  
482  
483   static void
484 < oputv(r)                                /* print value */
485 < RAY  *r;
484 > oputv(                          /* print value */
485 >        RAY  *r
486 > )
487   {
488          COLR  cout;
489          
# Line 472 | Line 501 | RAY  *r;
501  
502  
503   static void
504 < oputl(r)                                /* print effective distance */
505 < RAY  *r;
504 > oputl(                          /* print effective distance */
505 >        RAY  *r
506 > )
507   {
508          (*putreal)(r->rt);
509   }
510  
511  
512   static void
513 < oputL(r)                                /* print single ray length */
514 < RAY  *r;
513 > oputL(                          /* print single ray length */
514 >        RAY  *r
515 > )
516   {
517          (*putreal)(r->rot);
518   }
519  
520  
521   static void
522 < oputc(r)                                /* print local coordinates */
523 < RAY  *r;
522 > oputc(                          /* print local coordinates */
523 >        RAY  *r
524 > )
525   {
526          (*putreal)(r->uv[0]);
527          (*putreal)(r->uv[1]);
# Line 497 | Line 529 | RAY  *r;
529  
530  
531   static void
532 < oputp(r)                                /* print point */
533 < RAY  *r;
532 > oputp(                          /* print point */
533 >        RAY  *r
534 > )
535   {
536          if (r->rot < FHUGE) {
537                  (*putreal)(r->rop[0]);
# Line 513 | Line 546 | RAY  *r;
546  
547  
548   static void
549 < oputN(r)                                /* print unperturbed normal */
550 < RAY  *r;
549 > oputN(                          /* print unperturbed normal */
550 >        RAY  *r
551 > )
552   {
553          if (r->rot < FHUGE) {
554                  (*putreal)(r->ron[0]);
# Line 529 | Line 563 | RAY  *r;
563  
564  
565   static void
566 < oputn(r)                                /* print perturbed normal */
567 < RAY  *r;
566 > oputn(                          /* print perturbed normal */
567 >        RAY  *r
568 > )
569   {
570          FVECT  pnorm;
571  
# Line 548 | Line 583 | RAY  *r;
583  
584  
585   static void
586 < oputs(r)                                /* print name */
587 < RAY  *r;
586 > oputs(                          /* print name */
587 >        RAY  *r
588 > )
589   {
590          if (r->ro != NULL)
591                  fputs(r->ro->oname, stdout);
# Line 560 | Line 596 | RAY  *r;
596  
597  
598   static void
599 < oputw(r)                                /* print weight */
600 < RAY  *r;
599 > oputw(                          /* print weight */
600 >        RAY  *r
601 > )
602   {
603          (*putreal)(r->rweight);
604   }
605  
606  
607   static void
608 < oputm(r)                                /* print modifier */
609 < RAY  *r;
608 > oputm(                          /* print modifier */
609 >        RAY  *r
610 > )
611   {
612          if (r->ro != NULL)
613                  if (r->ro->omod != OVOID)
# Line 583 | Line 621 | RAY  *r;
621  
622  
623   static void
624 < puta(v)                         /* print ascii value */
625 < double  v;
624 > oputM(                          /* print material */
625 >        RAY  *r
626 > )
627 > {
628 >        OBJREC  *mat;
629 >
630 >        if (r->ro != NULL) {
631 >                if ((mat = findmaterial(r->ro)) != NULL)
632 >                        fputs(mat->oname, stdout);
633 >                else
634 >                        fputs(VOIDID, stdout);
635 >        } else
636 >                putchar('*');
637 >        putchar('\t');
638 > }
639 >
640 >
641 > static void
642 > puta(                           /* print ascii value */
643 >        double  v
644 > )
645   {
646          printf("%e\t", v);
647   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines