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.20 by greg, Tue Mar 27 11:40:07 1990 UTC vs.
Revision 1.27 by greg, Wed Jun 19 16:36:34 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 24 | Line 24 | static char SCCSid[] = "$SunId$ LBL";
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  
45   int  maxdepth = 6;                      /* maximum recursion depth */
46   double  minweight = 5e-3;               /* minimum ray weight */
# Line 53 | Line 58 | int  ralrm = 0;                                /* seconds between reports */
58  
59   double  pctdone = 0.0;                  /* percentage done */
60  
61 + long  tlastrept = 0L;                   /* time at last report */
62 +
63 + extern long  time();
64 + extern long  tstart;                    /* starting time */
65 +
66   extern long  nrays;                     /* number of rays traced */
67  
68 < #define  MAXDIV         32              /* maximum sample size */
68 > #define  MAXDIV         15              /* maximum sample size */
69  
70   #define  pixjitter()    (.5+dstrpix*(.5-frandom()))
71  
# Line 72 | Line 82 | int  code;
82   }
83  
84  
85 + #ifdef BSD
86   report()                /* report progress */
87   {
77 #ifdef BSD
88          struct rusage  rubuf;
89          double  t;
90  
# Line 87 | Line 97 | report()               /* report progress */
97  
98          sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f CPU hours\n",
99                          nrays, pctdone, t/3600.0);
100 +        eputs(errmsg);
101 +        tlastrept = time((long *)0);
102 + }
103   #else
104 + report()                /* report progress */
105 + {
106          signal(SIGALRM, report);
107 <        sprintf(errmsg, "%ld rays, %4.2f%% done\n", nrays, pctdone);
108 < #endif
107 >        tlastrept = time((long *)0);
108 >        sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f hours\n",
109 >                        nrays, pctdone, (tlastrept-tstart)/3600.0);
110          eputs(errmsg);
95
96        if (ralrm > 0)
97                alarm(ralrm);
111   }
112 + #endif
113  
114  
115   render(zfile, oldfile)                          /* render the scene */
# Line 113 | Line 127 | char  *zfile, *oldfile;
127                                          /* check sampling */
128          if (psample < 1)
129                  psample = 1;
130 <        else if (psample > MAXDIV)
130 >        else if (psample > MAXDIV) {
131 >                sprintf(errmsg, "pixel sampling reduced from %d to %d",
132 >                                psample, MAXDIV);
133 >                error(WARNING, errmsg);
134                  psample = MAXDIV;
135 +        }
136                                          /* allocate scanlines */
137          for (i = 0; i <= psample; i++) {
138                  scanbar[i] = (COLOR *)malloc(hresolu*sizeof(COLOR));
# Line 141 | Line 159 | char  *zfile, *oldfile;
159          fputresolu(YMAJOR|YDECR, hresolu, vresolu, stdout);
160                                          /* recover file and compute first */
161          i = salvage(oldfile);
162 <        if (zfd != -1 && lseek(zfd, (long)i*hresolu*sizeof(float), 0) == -1)
162 >        if (zfd != -1 && i > 0 &&
163 >                        lseek(zfd, (long)i*hresolu*sizeof(float), 0) == -1)
164                  error(SYSTEM, "z file seek error in render");
165 +        pctdone = 100.0*i/vresolu;
166 +        if (ralrm > 0)                  /* report init stats */
167 +                report();
168          ypos = vresolu-1 - i;
169          fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample);
170          ystep = psample;
171                                                  /* compute scanlines */
172          for (ypos -= ystep; ypos > -ystep; ypos -= ystep) {
151                                                        /* record progress */
152                pctdone = 100.0*(vresolu-1-ypos-ystep)/vresolu;
173                                                          /* bottom adjust? */
174                  if (ypos < 0) {
175                          ystep += ypos;
# Line 176 | Line 196 | char  *zfile, *oldfile;
196                  }
197                  if (fflush(stdout) == EOF)
198                          goto writerr;
199 +                                                        /* record progress */
200 +                pctdone = 100.0*(vresolu-1-ypos)/vresolu;
201 +                if (ralrm > 0 && time((long *)0) >= tlastrept+ralrm)
202 +                        report();
203          }
204                                                  /* clean up */
205          if (zfd != -1) {
# Line 235 | Line 259 | int  xres, y, ysize;
259          COLOR  vline[MAXDIV+1];
260          float  zline[MAXDIV+1];
261          int  b = ysize;
238        double  z;
262          register int  i, j;
263          
264          for (i = 0; i < xres; i++) {
# Line 319 | Line 342 | pixvalue(col, x, y)            /* compute pixel value */
342   COLOR  col;                     /* returned color */
343   int  x, y;                      /* pixel position */
344   {
345 <        static RAY  thisray;    /* our ray for this pixel */
345 >        static RAY  thisray;
346  
347 <        viewray(thisray.rorg, thisray.rdir, &ourview,
348 <                        (x+pixjitter())/hresolu, (y+pixjitter())/vresolu);
347 >        if (viewray(thisray.rorg, thisray.rdir, &ourview,
348 >                        (x+pixjitter())/hresolu, (y+pixjitter())/vresolu) < 0) {
349 >                setcolor(col, 0.0, 0.0, 0.0);
350 >                return(0.0);
351 >        }
352  
353          rayorigin(&thisray, NULL, PRIMARY, 1.0);
354 <        
354 >
355 >        samplendx = 3*y + x;                    /* set pixel index */
356 >
357          rayvalue(&thisray);                     /* trace ray */
358  
359          copycolor(col, thisray.rcol);           /* return color */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines