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

Comparing ray/src/rt/ambient.c (file contents):
Revision 2.39 by greg, Tue Jul 9 19:37:09 1996 UTC vs.
Revision 2.42 by greg, Thu Jan 2 09:37:13 1997 UTC

# Line 50 | Line 50 | static int  nunflshed = 0;     /* number of unflushed ambi
50   #endif
51   #endif
52   #ifndef SORT_INTVL
53 < #define SORT_INTVL      (SORT_THRESH*256)
53 > #define SORT_INTVL      (SORT_THRESH<<1)
54   #endif
55   #ifndef MAX_SORT_INTVL
56 < #define MAX_SORT_INTVL  (SORT_INTVL<<4)
56 > #define MAX_SORT_INTVL  (SORT_INTVL<<6)
57   #endif
58  
59   static COLOR  avsum = BLKCOLOR;         /* computed ambient value sum */
# Line 77 | Line 77 | static long  sortintvl = SORT_INTVL;   /* time until nex
77   #define  newambval()    (AMBVAL *)bmalloc(sizeof(AMBVAL))
78  
79   extern long  ftell(), lseek();
80 < static int  initambfile(), avsave(), avinsert(), sortambvals();
80 > static int  initambfile(), avsave(), avinsert(), sortambvals(), avlmemi();
81   static AMBVAL  *avstore();
82   #ifdef  F_SETLKW
83   static  aflock();
# Line 144 | Line 144 | char  *afile;
144                  pos += (long)nambvals*AMBVALSIZ;
145                  flen = lseek(fileno(ambfp), 0L, 2);
146                  if (flen != pos) {
147 <                        error(WARNING,
147 >                        sprintf(errmsg,
148                          "ignoring last %ld values in ambient file (corrupted)",
149                                          (flen - pos)/AMBVALSIZ);
150 +                        error(WARNING, errmsg);
151                          fseek(ambfp, pos, 0);
152                          ftruncate(fileno(ambfp), pos);
153                  }
# Line 210 | Line 211 | FVECT  nrm;
211                          goto dumbamb;
212                  return;
213          }
214 <                                                /* resort memory? */
215 <        sortambvals(0);
214 >
215 >        if (tracktime)                          /* sort to minimize thrashing */
216 >                sortambvals(0);
217                                                  /* get ambient value */
218          setcolor(acol, 0.0, 0.0, 0.0);
219          d = sumambient(acol, r, nrm, rdepth,
# Line 257 | Line 259 | double s;
259                                          /* do this node */
260          for (av = at->alist; av != NULL; av = av->next) {
261                  if (tracktime)
262 <                        av->latick = ambclock++;
262 >                        av->latick = ambclock;
263                  /*
264                   *  Ambient level test.
265                   */
# Line 402 | Line 404 | int  creat;
404          setbuf(ambfp, bmalloc(BUFSIZ+8));
405          if (creat) {                    /* new file */
406                  newheader("RADIANCE", ambfp);
407 <                fprintf(ambfp, "%s -av %g %g %g -ab %d -aa %g ",
407 >                fprintf(ambfp, "%s -av %g %g %g -aw %d -ab %d -aa %g ",
408                                  progname, colval(ambval,RED),
409                                  colval(ambval,GRN), colval(ambval,BLU),
410 <                                ambounce, ambacc);
410 >                                ambvwt, ambounce, ambacc);
411                  fprintf(ambfp, "-ad %d -as %d -ar %d %s\n",
412                                  ambdiv, ambssamp, ambres,
413                                  octname==NULL ? "" : octname);
# Line 616 | Line 618 | int    always;
618          AMBVAL  tav, *tap, *pnext;
619          register int    i, j;
620                                          /* see if it's time yet */
621 <        if (!always && (ambclock < lastsort+sortintvl ||
621 >        if (!always && (ambclock++ < lastsort+sortintvl ||
622                          nambvals < SORT_THRESH))
623                  return;
624          /*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines