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

Comparing ray/src/hd/rhcopy.c (file contents):
Revision 3.37 by greg, Tue Dec 19 20:22:36 2023 UTC vs.
Revision 3.41 by greg, Thu Jun 5 19:10:31 2025 UTC

# Line 33 | Line 33 | int    iofmt = 'a';            /* input/output format for rays */
33   #define H_VDST          010             /* VDISTANCE= True */
34   #define H_SWAP          020             /* byte order is different */
35  
36 char    *progname;              /* global argv[0] */
37
36   struct phead {
37          VIEW    vw;
38          double  expos;
# Line 51 | Line 49 | typedef struct {
49   } RAYPAR;
50  
51   static int openholo(char *fname, int append);
52 < static void addray(RAYPAR *rp);
52 > static int addray(RAYPAR *rp);
53   static int readval(RREAL *v, int n, FILE *fp);
54   static void readrays(FILE *fp);
55   static int writeval(RREAL *v, int n, FILE *fp);
# Line 73 | Line 71 | main(
71   {
72          int     i;
73  
74 <        progname = argv[0];
74 >        fixargv0(argv[0]);
75          for (i = 2; i < argc && argv[i][0] == '-'; i++)
76                  switch (argv[i][1]) {
77                  case 'u':
# Line 228 | Line 226 | openholo(              /* open existing holodeck file for i/o */
226          return(n);
227   }
228  
229 < void
229 > int
230   addray(         /* add a ray to our output holodeck */
231          RAYPAR *rp
232   )
# Line 241 | Line 239 | addray(                /* add a ray to our output holodeck */
239          double  d0, d1;
240          unsigned        dc;
241          RAYVAL  *rv;
242 +        int     nsects = 0;
243                                  /* check each output section */
244          for (sn = nholosects; sn--; ) {
245                  hp = hdlist[sn];
# Line 271 | Line 270 | addray(                /* add a ray to our output holodeck */
270                  rv->r[0][0] = rr[0][0]; rv->r[0][1] = rr[0][1];
271                  rv->r[1][0] = rr[1][0]; rv->r[1][1] = rr[1][1];
272                  copycolr(rv->v, rp->cv);
273 +                ++nsects;
274          }
275 +        return nsects;
276   }
277  
278   /* Read n-vector from file stream */
# Line 325 | Line 326 | readval(RREAL *v, int n, FILE *fp)
326   static void
327   readrays(FILE *fp)
328   {
329 +        unsigned long   nread=0, ngood=0;
330 +
331          if (iofmt != 'a')
332                  SET_FILE_BINARY(fp);
333   #ifdef getc_unlocked
# Line 379 | Line 382 | readrays(FILE *fp)
382                          if (!flags)     /* got nothing, so may be normal EOF */
383                                  return;
384                  }
385 +                ++nread;
386                  if (flags & (BAD_DIR|BAD_LEN))
387                          continue;       /* just a bad ray is all -- skip */
388                  if (!(flags & GOT_VAL))
# Line 396 | Line 400 | readrays(FILE *fp)
400                          } else
401                                  goto missingData;
402                  }
403 <                addray(&ryp);           /* add our ray to holodeck */
403 >                ngood += (addray(&ryp) > 0);    /* add our ray to holodeck */
404          }
405          return;
406   missingData:
407 <        sprintf(errmsg, "insufficient data or read error for -i%s", rspec);
407 >        sprintf(errmsg, "insufficient data or read error with -i%s after %lu rays read (%lu used)",
408 >                        rspec, nread, ngood);
409          error(USER, errmsg);
410   }
411  
# Line 527 | Line 532 | writerays(FILE *fp)
532                          hdbcoord(gc, hp, bq[bi]);
533                          rv = hdbray(bp);
534                          for (k = bp->nrm; k--; rv++) {
535 +                                RREAL   hitd = hddepth(hp, rv->d);
536                                  ryp.d = hdray(ryp.ro, ryp.rd, hp, gc, rv->r);
537 <                                if (*(int *)hp->priv & H_OBSF)
537 >                                if (*(int *)hp->priv & H_OBST) {
538 >                                        ryp.d = 0;
539 >                                } else {
540 >                                        if (ryp.d > 0.97*hitd)
541 >                                                ryp.d = 0.97*hitd;
542                                          VSUM(ryp.ro, ryp.ro, ryp.rd, ryp.d);
543 <                                else
544 <                                        ryp.d = 0.;
535 <                                ryp.d = hddepth(hp, rv->d) - ryp.d;
543 >                                }
544 >                                ryp.d = hitd - ryp.d;
545                                  copycolr(ryp.cv, rv->v);
546                                  if (!write_ray(&ryp, fp)) {
547                                          free(bq);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines