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"; |
53 |
|
|
54 |
|
double pctdone = 0.0; /* percentage done */ |
55 |
|
|
56 |
+ |
long tlastrept = 0L; /* time at last report */ |
57 |
+ |
|
58 |
+ |
extern long time(); |
59 |
+ |
extern long tstart; /* starting time */ |
60 |
+ |
|
61 |
|
extern long nrays; /* number of rays traced */ |
62 |
|
|
63 |
|
#define MAXDIV 32 /* maximum sample size */ |
77 |
|
} |
78 |
|
|
79 |
|
|
80 |
+ |
#ifdef BSD |
81 |
|
report() /* report progress */ |
82 |
|
{ |
77 |
– |
#ifdef BSD |
83 |
|
struct rusage rubuf; |
84 |
|
double t; |
85 |
|
|
92 |
|
|
93 |
|
sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f CPU hours\n", |
94 |
|
nrays, pctdone, t/3600.0); |
95 |
+ |
eputs(errmsg); |
96 |
+ |
tlastrept = time((long *)0); |
97 |
+ |
} |
98 |
|
#else |
99 |
+ |
report() /* report progress */ |
100 |
+ |
{ |
101 |
|
signal(SIGALRM, report); |
102 |
< |
sprintf(errmsg, "%ld rays, %4.2f%% done\n", nrays, pctdone); |
103 |
< |
#endif |
102 |
> |
tlastrept = time((long *)0); |
103 |
> |
sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f hours\n", |
104 |
> |
nrays, pctdone, (tlastrept-tstart)/3600.0); |
105 |
|
eputs(errmsg); |
95 |
– |
|
96 |
– |
if (ralrm > 0) |
97 |
– |
alarm(ralrm); |
106 |
|
} |
107 |
+ |
#endif |
108 |
|
|
109 |
|
|
110 |
|
render(zfile, oldfile) /* render the scene */ |
150 |
|
fputresolu(YMAJOR|YDECR, hresolu, vresolu, stdout); |
151 |
|
/* recover file and compute first */ |
152 |
|
i = salvage(oldfile); |
153 |
< |
if (zfd != -1 && lseek(zfd, (long)i*hresolu*sizeof(float), 0) == -1) |
153 |
> |
if (zfd != -1 && i > 0 && |
154 |
> |
lseek(zfd, (long)i*hresolu*sizeof(float), 0) == -1) |
155 |
|
error(SYSTEM, "z file seek error in render"); |
156 |
+ |
pctdone = 100.0*i/vresolu; |
157 |
+ |
if (ralrm > 0) /* report init stats */ |
158 |
+ |
report(); |
159 |
|
ypos = vresolu-1 - i; |
160 |
|
fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample); |
161 |
|
ystep = psample; |
162 |
|
/* compute scanlines */ |
163 |
|
for (ypos -= ystep; ypos > -ystep; ypos -= ystep) { |
151 |
– |
/* record progress */ |
152 |
– |
pctdone = 100.0*(vresolu-ypos-ystep)/vresolu; |
164 |
|
/* bottom adjust? */ |
165 |
|
if (ypos < 0) { |
166 |
|
ystep += ypos; |
187 |
|
} |
188 |
|
if (fflush(stdout) == EOF) |
189 |
|
goto writerr; |
190 |
+ |
/* record progress */ |
191 |
+ |
pctdone = 100.0*(vresolu-1-ypos)/vresolu; |
192 |
+ |
if (ralrm > 0 && time((long *)0) >= tlastrept+ralrm) |
193 |
+ |
report(); |
194 |
|
} |
195 |
|
/* clean up */ |
196 |
|
if (zfd != -1) { |
197 |
|
if (write(zfd, (char *)zbar[0], hresolu*sizeof(float)) |
198 |
|
< hresolu*sizeof(float)) |
199 |
|
goto writerr; |
200 |
< |
close(zfd); |
200 |
> |
if (close(zfd) == -1) |
201 |
> |
goto writerr; |
202 |
|
for (i = 0; i <= psample; i++) |
203 |
|
free((char *)zbar[i]); |
204 |
|
} |
250 |
|
COLOR vline[MAXDIV+1]; |
251 |
|
float zline[MAXDIV+1]; |
252 |
|
int b = ysize; |
237 |
– |
double z; |
253 |
|
register int i, j; |
254 |
|
|
255 |
|
for (i = 0; i < xres; i++) { |
335 |
|
{ |
336 |
|
static RAY thisray; /* our ray for this pixel */ |
337 |
|
|
338 |
< |
viewray(thisray.rorg, thisray.rdir, &ourview, |
339 |
< |
(x+pixjitter())/hresolu, (y+pixjitter())/vresolu); |
338 |
> |
if (viewray(thisray.rorg, thisray.rdir, &ourview, |
339 |
> |
(x+pixjitter())/hresolu, (y+pixjitter())/vresolu) < 0) { |
340 |
> |
setcolor(col, 0.0, 0.0, 0.0); |
341 |
> |
return(0.0); |
342 |
> |
} |
343 |
|
|
344 |
|
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
345 |
|
|
347 |
|
|
348 |
|
copycolor(col, thisray.rcol); /* return color */ |
349 |
|
|
350 |
< |
return(thisray.rot); /* return distance */ |
350 |
> |
return(thisray.rt); /* return distance */ |
351 |
|
} |
352 |
|
|
353 |
|
|