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

Comparing ray/src/rt/rpict.c (file contents):
Revision 2.92 by greg, Thu Mar 21 16:52:40 2019 UTC vs.
Revision 2.97 by greg, Fri Dec 3 18:10:48 2021 UTC

# Line 135 | Line 135 | static int pixnumber(int  x, int  y, int  xres, int  y
135  
136  
137   void
138 < quit(code)                      /* quit program */
139 < int  code;
138 > quit(int code)                  /* quit program */
139   {
140          if (code)                       /* report status */
141                  report(0);
# Line 288 | Line 287 | rpict(                 /* generate image(s) */
287                          break;
288                  pctdone = 0.0;
289                  if (pout != NULL) {
290 +                        int     myfd;
291                          close(1);                       /* reassign stdout */
292                          sprintf(fbuf, pout, seq);
293 +                tryagain:
294                          errno = 0;                      /* exclusive open */
295 <                        if (open(fbuf, O_WRONLY|O_CREAT|O_EXCL, 0666) != 1) {
295 >                        if ((myfd = open(fbuf, O_WRONLY|O_CREAT|O_EXCL, 0666)) < 0) {
296                                  if ((errno != EEXIST) | (prvr != NULL) ||
297                                                  !strcmp(fbuf, pout)) {
298                                          sprintf(errmsg,
# Line 302 | Line 303 | rpict(                 /* generate image(s) */
303                                  setview(&ourview);
304                                  continue;               /* don't clobber */
305                          }
306 +                        if (myfd != 1) {
307 +                                unlink(fbuf);
308 +                                goto tryagain;          /* leave it open */
309 +                        }
310                          SET_FD_BINARY(1);
311                          dupheader();
312                  }
# Line 335 | Line 340 | rpict(                 /* generate image(s) */
340                  if ((pa < .99) | (pa > 1.01))
341                          fputaspect(pa, stdout);
342                  fputnow(stdout);
343 +                fputprims(stdprims, stdout);
344                  fputformat(COLRFMT, stdout);
345                  putchar('\n');
346                  if (zout != NULL)
# Line 654 | Line 660 | pixvalue(              /* compute pixel value */
660          int  y
661   )
662   {
657        extern void  SDsquare2disk(double ds[2], double seedx, double seedy);
663          RAY  thisray;
664          FVECT   lorg, ldir;
665 <        double  hpos, vpos, vdist, lmax;
665 >        double  hpos, vpos, lmax;
666          int     i;
667                                                  /* compute view ray */
668          setcolor(col, 0.0, 0.0, 0.0);
# Line 666 | Line 671 | pixvalue(              /* compute pixel value */
671          if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir,
672                                          &ourview, hpos, vpos)) < -FTINY)
673                  return(0.0);
669
670        vdist = ourview.vdist;
674                                                  /* set pixel index */
675          samplendx = pixnumber(x,y,hres,vres);
676                                                  /* optional motion blur */
# Line 682 | Line 685 | pixvalue(              /* compute pixel value */
685                  }
686                  if (normalize(thisray.rdir) == 0.0)
687                          return(0.0);
685                vdist = (1.-d)*vdist + d*lastview.vdist;
688          }
689 <                                                /* optional depth-of-field */
690 <        if (dblur > FTINY) {
691 <                double  vc, df[2];
690 <                                                /* random point on disk */
691 <                SDsquare2disk(df, frandom(), frandom());
692 <                df[0] *= .5*dblur;
693 <                df[1] *= .5*dblur;
694 <                if ((ourview.type == VT_PER) | (ourview.type == VT_PAR)) {
695 <                        double  adj = 1.0;
696 <                        if (ourview.type == VT_PER)
697 <                                adj /= DOT(thisray.rdir, ourview.vdir);
698 <                        df[0] /= sqrt(ourview.hn2);
699 <                        df[1] /= sqrt(ourview.vn2);
700 <                        for (i = 3; i--; ) {
701 <                                vc = ourview.vp[i] + adj*vdist*thisray.rdir[i];
702 <                                thisray.rorg[i] += df[0]*ourview.hvec[i] +
703 <                                                        df[1]*ourview.vvec[i] ;
704 <                                thisray.rdir[i] = vc - thisray.rorg[i];
705 <                        }
706 <                } else {                        /* non-standard view case */
707 <                        double  dfd = PI/4.*dblur*(.5 - frandom());
708 <                        if ((ourview.type != VT_ANG) & (ourview.type != VT_PLS)) {
709 <                                if (ourview.type != VT_CYL)
710 <                                        df[0] /= sqrt(ourview.hn2);
711 <                                df[1] /= sqrt(ourview.vn2);
712 <                        }
713 <                        for (i = 3; i--; ) {
714 <                                vc = ourview.vp[i] + vdist*thisray.rdir[i];
715 <                                thisray.rorg[i] += df[0]*ourview.hvec[i] +
716 <                                                        df[1]*ourview.vvec[i] +
717 <                                                        dfd*ourview.vdir[i] ;
718 <                                thisray.rdir[i] = vc - thisray.rorg[i];
719 <                        }
720 <                }
721 <                if (normalize(thisray.rdir) == 0.0)
722 <                        return(0.0);
723 <        }
689 >                                                /* depth-of-field */
690 >        if (!jitteraperture(thisray.rorg, thisray.rdir, &ourview, dblur))
691 >                return(0.0);
692  
693          rayorigin(&thisray, PRIMARY, NULL, NULL);
694  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines