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.91 by greg, Sun Apr 5 15:47:02 2020 UTC vs.
Revision 2.99 by greg, Mon Jul 20 15:54:29 2020 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 < static int  castonly = 0;
48 > int  castonly = 0;                      /* only doing ray-casting? */
49  
50   #ifndef  MAXTSET
51   #define  MAXTSET        8191            /* maximum number in trace set */
# Line 68 | Line 68 | static oputf_t  oputo, oputd, oputv, oputV, oputl, opu
68                  oputr, oputR, oputx, oputX, oputn, oputN, oputs,
69                  oputw, oputW, oputm, oputM, oputtilde;
70  
71 static void setoutput(char *vs);
71   extern void tranotify(OBJECT obj);
72 + static int is_fifo(FILE *fp);
73   static void bogusray(void);
74   static void raycast(RAY *r);
75   static void rayirrad(RAY *r);
# Line 92 | 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 117 | Line 119 | formstr(                               /* return format identifier */
119   }
120  
121  
122 < extern void
122 > void
123   rtrace(                         /* trace rays from file */
124          char  *fname,
125          int  nproc
# Line 144 | Line 146 | rtrace(                                /* trace rays from file */
146          if (inform != 'a')
147                  SET_FILE_BINARY(inpfp);
148                                          /* set up output */
149 <        if (imm_irrad)
148 <                castonly = 0;
149 <        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 237 | 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 287 | 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 354 | 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 461 | Line 464 | printvals(                     /* print requested ray values */
464  
465  
466   static int
467 + is_fifo(                /* check if file pointer connected to pipe */
468 +        FILE *fp
469 + )
470 + {
471 + #ifdef S_ISFIFO
472 +        struct stat  sbuf;
473 +
474 +        if (fstat(fileno(fp), &sbuf) < 0)
475 +                error(SYSTEM, "fstat() failed on input stream");
476 +        return(S_ISFIFO(sbuf.st_mode));
477 + #else
478 +        return (fp == stdin);           /* just a guess, really */
479 + #endif
480 + }
481 +
482 +
483 + static int
484   getvec(                 /* get a vector from fp */
485          FVECT  vec,
486          int  fmt,
# Line 524 | Line 544 | nextray(               /* return next ray in work group (-1.0 if EO
544                  int     rsiz = 6*20;    /* conservative ascii ray size */
545                  if (inform == 'f') rsiz = 6*sizeof(float);
546                  else if (inform == 'd') rsiz = 6*sizeof(double);
547 <                if ((inpfp == stdin) & (qlength*rsiz > 512))    /* pipe limit */
547 >                                        /* check against pipe limit */
548 >                if (qlength*rsiz > 512 && is_fifo(inpfp))
549                          inp_queue = (FVECT *)malloc(sizeof(FVECT)*2*qlength);
550                  inp_qend = -(inp_queue == NULL);        /* flag for no queue */
551          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines