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.93 by greg, Mon Apr 6 04:10:44 2020 UTC vs.
Revision 2.101 by greg, Tue Feb 16 22:06:00 2021 UTC

# Line 45 | Line 45 | extern int  traincl;                   /* include == 1, exclude == 0 *
45   extern int  hresolu;                    /* horizontal resolution */
46   extern int  vresolu;                    /* vertical resolution */
47  
48 < extern int  castonly;                   /* only doing ray-casting? */
48 > int  castonly = 0;                      /* only doing ray-casting? */
49  
50   #ifndef  MAXTSET
51   #define  MAXTSET        8191            /* maximum number in trace set */
# Line 69 | Line 69 | static oputf_t  oputo, oputd, oputv, oputV, oputl, opu
69                  oputw, oputW, oputm, oputM, oputtilde;
70  
71   extern void tranotify(OBJECT obj);
72 static void setoutput(char *vs);
72   static int is_fifo(FILE *fp);
73   static void bogusray(void);
74   static void raycast(RAY *r);
# Line 93 | Line 92 | quit(                  /* quit program */
92   {
93          if (ray_pnprocs > 0)    /* close children if any */
94                  ray_pclose(0);          
95 +        else if (ray_pnprocs < 0)
96 +                _exit(code);    /* avoid flush() in child */
97   #ifndef  NON_POSIX
98 <        else if (!ray_pnprocs) {
98 >        else {
99                  headclean();    /* delete header file */
100                  pfclean();      /* clean up persist files */
101          }
# Line 145 | Line 146 | rtrace(                                /* trace rays from file */
146          if (inform != 'a')
147                  SET_FILE_BINARY(inpfp);
148                                          /* set up output */
149 <        if (imm_irrad)
149 <                castonly = 0;
150 <        else if (castonly || every_out[0] != NULL)
149 >        if (castonly || every_out[0] != NULL)
150                  nproc = 1;              /* don't bother multiprocessing */
151          if ((nextflush > 0) & (nproc > nextflush)) {
152                  error(WARNING, "reducing number of processes to match flush interval");
# Line 238 | Line 237 | setrtoutput(void)                      /* set up output tables, return #c
237          if (!*vs)
238                  error(USER, "empty output specification");
239  
240 <        castonly = 1;
240 >        castonly = 1;                   /* sets castonly as side-effect */
241          do
242                  switch (*vs) {
243                  case 'T':                               /* trace sources */
# Line 288 | Line 287 | setrtoutput(void)                      /* set up output tables, return #c
287                  case 'V':                               /* contribution */
288                          *table++ = oputV;
289                          ncomp += 3;
290 +                        castonly = 0;
291                          if (ambounce > 0 && (ambacc > FTINY || ambssamp > 0))
292                                  error(WARNING,
293                                          "-otV accuracy depends on -aa 0 -as 0");
# Line 355 | Line 355 | setrtoutput(void)                      /* set up output tables, return #c
355          if (*every_out != NULL)
356                  ncomp = 0;
357                                                          /* compatibility */
358 +        if ((do_irrad | imm_irrad) && castonly)
359 +                error(USER, "-I+ and -i+ options require some value output");
360          for (table = ray_out; *table != NULL; table++) {
361                  if ((*table == oputV) | (*table == oputW))
362                          error(WARNING, "-oVW options require trace mode");
# Line 418 | Line 420 | rtcompute(                     /* compute and print ray value(s) */
420   )
421   {
422                                          /* set up ray */
421        rayorigin(&thisray, PRIMARY, NULL, NULL);
423          if (imm_irrad) {
424                  VSUM(thisray.rorg, org, dir, 1.1e-4);
425                  thisray.rdir[0] = -dir[0];
426                  thisray.rdir[1] = -dir[1];
427                  thisray.rdir[2] = -dir[2];
428                  thisray.rmax = 0.0;
428                thisray.revf = rayirrad;
429          } else {
430                  VCOPY(thisray.rorg, org);
431                  VCOPY(thisray.rdir, dir);
432                  thisray.rmax = dmax;
433                if (castonly)
434                        thisray.revf = raycast;
433          }
434 +        rayorigin(&thisray, PRIMARY, NULL, NULL);
435 +        if (imm_irrad)
436 +                thisray.revf = rayirrad;
437 +        else if (castonly)
438 +                thisray.revf = raycast;
439          if (ray_pnprocs > 1) {          /* multiprocessing FIFO? */
440                  if (ray_fifo_in(&thisray) < 0)
441                          error(USER, "lost children");
# Line 763 | Line 766 | static RREAL   vdummy[3] = {0.0, 0.0, 0.0};
766  
767  
768   static void
769 < oputp(                          /* print point */
769 > oputp(                          /* print intersection point */
770          RAY  *r
771   )
772   {
773 <        if (r->rot < FHUGE*.99)
771 <                (*putreal)(r->rop, 3);
772 <        else
773 <                (*putreal)(vdummy, 3);
773 >        (*putreal)(r->rop, 3);  /* set to ray origin if distant or no hit */
774   }
775  
776  
# Line 779 | Line 779 | oputN(                         /* print unperturbed normal */
779          RAY  *r
780   )
781   {
782 <        if (r->rot < FHUGE*.99) {
783 <                if (r->rflips & 1) {    /* undo any flippin' flips */
784 <                        FVECT   unrm;
785 <                        unrm[0] = -r->ron[0];
786 <                        unrm[1] = -r->ron[1];
787 <                        unrm[2] = -r->ron[2];
788 <                        (*putreal)(unrm, 3);
789 <                } else
790 <                        (*putreal)(r->ron, 3);
791 <        } else
782 >        if (r->ro == NULL) {    /* zero vector if clipped or no hit */
783                  (*putreal)(vdummy, 3);
784 +                return;
785 +        }
786 +        if (r->rflips & 1) {    /* undo any flippin' flips */
787 +                FVECT   unrm;
788 +                unrm[0] = -r->ron[0];
789 +                unrm[1] = -r->ron[1];
790 +                unrm[2] = -r->ron[2];
791 +                (*putreal)(unrm, 3);
792 +        } else
793 +                (*putreal)(r->ron, 3);
794   }
795  
796  
# Line 800 | Line 801 | oputn(                         /* print perturbed normal */
801   {
802          FVECT  pnorm;
803  
804 <        if (r->rot >= FHUGE*.99) {
804 >        if (r->ro == NULL) {    /* clipped or no hit */
805                  (*putreal)(vdummy, 3);
806                  return;
807          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines