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 1.17 by greg, Fri Jan 19 00:00:19 1990 UTC vs.
Revision 1.29 by greg, Tue Jun 25 14:06:12 1991 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1986 Regents of the University of California */
1 > /* Copyright (c) 1991 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 18 | Line 18 | static char SCCSid[] = "$SunId$ LBL";
18   #else
19   #include  <signal.h>
20   #endif
21 < #include  <sys/fcntl.h>
21 > #include  <fcntl.h>
22  
23   #include  "view.h"
24  
25   #include  "random.h"
26  
27 + int  dimlist[MAXDIM];                   /* sampling dimensions */
28 + int  ndims = 0;                         /* number of sampling dimensions */
29 + int  samplendx;                         /* sample index number */
30 +
31   VIEW  ourview = STDVIEW;                /* view parameters */
32   int  hresolu = 512;                     /* horizontal resolution */
33   int  vresolu = 512;                     /* vertical resolution */
# Line 36 | Line 40 | double  dstrpix = 0.67;                        /* square pixel distribution
40   double  dstrsrc = 0.0;                  /* square source distribution */
41   double  shadthresh = .05;               /* shadow threshold */
42   double  shadcert = .5;                  /* shadow certainty */
43 + int  directrelay = 0;                   /* number of source relays */
44 + int  vspretest = 512;                   /* virtual source pretest density */
45  
46   int  maxdepth = 6;                      /* maximum recursion depth */
47   double  minweight = 5e-3;               /* minimum ray weight */
# Line 53 | Line 59 | int  ralrm = 0;                                /* seconds between reports */
59  
60   double  pctdone = 0.0;                  /* percentage done */
61  
62 + long  tlastrept = 0L;                   /* time at last report */
63 +
64 + extern long  time();
65 + extern long  tstart;                    /* starting time */
66 +
67   extern long  nrays;                     /* number of rays traced */
68  
69 < #define  MAXDIV         32              /* maximum sample size */
69 > #define  MAXDIV         15              /* maximum sample size */
70  
71   #define  pixjitter()    (.5+dstrpix*(.5-frandom()))
72  
# Line 72 | Line 83 | int  code;
83   }
84  
85  
86 + #ifdef BSD
87   report()                /* report progress */
88   {
77 #ifdef BSD
89          struct rusage  rubuf;
90          double  t;
91  
# Line 87 | Line 98 | report()               /* report progress */
98  
99          sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f CPU hours\n",
100                          nrays, pctdone, t/3600.0);
101 +        eputs(errmsg);
102 +        tlastrept = time((long *)0);
103 + }
104   #else
105 + report()                /* report progress */
106 + {
107          signal(SIGALRM, report);
108 <        sprintf(errmsg, "%ld rays, %4.2f%% done\n", nrays, pctdone);
109 < #endif
108 >        tlastrept = time((long *)0);
109 >        sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f hours\n",
110 >                        nrays, pctdone, (tlastrept-tstart)/3600.0);
111          eputs(errmsg);
95
96        if (ralrm > 0)
97                alarm(ralrm);
112   }
113 + #endif
114  
115  
116   render(zfile, oldfile)                          /* render the scene */
# Line 113 | Line 128 | char  *zfile, *oldfile;
128                                          /* check sampling */
129          if (psample < 1)
130                  psample = 1;
131 <        else if (psample > MAXDIV)
131 >        else if (psample > MAXDIV) {
132 >                sprintf(errmsg, "pixel sampling reduced from %d to %d",
133 >                                psample, MAXDIV);
134 >                error(WARNING, errmsg);
135                  psample = MAXDIV;
136 +        }
137                                          /* allocate scanlines */
138          for (i = 0; i <= psample; i++) {
139                  scanbar[i] = (COLOR *)malloc(hresolu*sizeof(COLOR));
# Line 141 | Line 160 | char  *zfile, *oldfile;
160          fputresolu(YMAJOR|YDECR, hresolu, vresolu, stdout);
161                                          /* recover file and compute first */
162          i = salvage(oldfile);
163 <        if (zfd != -1 && lseek(zfd, (long)i*hresolu*sizeof(float), 0) == -1)
163 >        if (zfd != -1 && i > 0 &&
164 >                        lseek(zfd, (long)i*hresolu*sizeof(float), 0) == -1)
165                  error(SYSTEM, "z file seek error in render");
166 +        pctdone = 100.0*i/vresolu;
167 +        if (ralrm > 0)                  /* report init stats */
168 +                report();
169          ypos = vresolu-1 - i;
170          fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample);
171          ystep = psample;
172                                                  /* compute scanlines */
173          for (ypos -= ystep; ypos > -ystep; ypos -= ystep) {
151                                                        /* record progress */
152                pctdone = 100.0*(vresolu-ypos-ystep)/vresolu;
174                                                          /* bottom adjust? */
175                  if (ypos < 0) {
176                          ystep += ypos;
# Line 176 | Line 197 | char  *zfile, *oldfile;
197                  }
198                  if (fflush(stdout) == EOF)
199                          goto writerr;
200 +                                                        /* record progress */
201 +                pctdone = 100.0*(vresolu-1-ypos)/vresolu;
202 +                if (ralrm > 0 && time((long *)0) >= tlastrept+ralrm)
203 +                        report();
204          }
205                                                  /* clean up */
206          if (zfd != -1) {
207                  if (write(zfd, (char *)zbar[0], hresolu*sizeof(float))
208                                  < hresolu*sizeof(float))
209                          goto writerr;
210 <                close(zfd);
210 >                if (close(zfd) == -1)
211 >                        goto writerr;
212                  for (i = 0; i <= psample; i++)
213                          free((char *)zbar[i]);
214          }
# Line 234 | Line 260 | int  xres, y, ysize;
260          COLOR  vline[MAXDIV+1];
261          float  zline[MAXDIV+1];
262          int  b = ysize;
237        double  z;
263          register int  i, j;
264          
265          for (i = 0; i < xres; i++) {
# Line 318 | Line 343 | pixvalue(col, x, y)            /* compute pixel value */
343   COLOR  col;                     /* returned color */
344   int  x, y;                      /* pixel position */
345   {
346 <        static RAY  thisray;    /* our ray for this pixel */
346 >        static RAY  thisray;
347  
348 <        viewray(thisray.rorg, thisray.rdir, &ourview,
349 <                        (x+pixjitter())/hresolu, (y+pixjitter())/vresolu);
348 >        if (viewray(thisray.rorg, thisray.rdir, &ourview,
349 >                        (x+pixjitter())/hresolu, (y+pixjitter())/vresolu) < 0) {
350 >                setcolor(col, 0.0, 0.0, 0.0);
351 >                return(0.0);
352 >        }
353  
354          rayorigin(&thisray, NULL, PRIMARY, 1.0);
355 <        
355 >
356 >        samplendx = 3*y + x;                    /* set pixel index */
357 >
358          rayvalue(&thisray);                     /* trace ray */
359  
360          copycolor(col, thisray.rcol);           /* return color */
361          
362 <        return(thisray.rot);                    /* return distance */
362 >        return(thisray.rt);                     /* return distance */
363   }
364  
365  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines