18 |
|
#else |
19 |
|
#include <signal.h> |
20 |
|
#endif |
21 |
< |
#include <sys/fcntl.h> |
21 |
> |
#include <fcntl.h> |
22 |
|
|
23 |
|
#include "view.h" |
24 |
|
|
141 |
|
fputresolu(YMAJOR|YDECR, hresolu, vresolu, stdout); |
142 |
|
/* recover file and compute first */ |
143 |
|
i = salvage(oldfile); |
144 |
< |
if (zfd != -1 && lseek(zfd, (long)i*hresolu*sizeof(float), 0) == -1) |
144 |
> |
if (zfd != -1 && i > 0 && |
145 |
> |
lseek(zfd, (long)i*hresolu*sizeof(float), 0) == -1) |
146 |
|
error(SYSTEM, "z file seek error in render"); |
147 |
|
ypos = vresolu-1 - i; |
148 |
|
fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample); |
150 |
|
/* compute scanlines */ |
151 |
|
for (ypos -= ystep; ypos > -ystep; ypos -= ystep) { |
152 |
|
/* record progress */ |
153 |
< |
pctdone = 100.0*(vresolu-ypos-ystep)/vresolu; |
153 |
> |
pctdone = 100.0*(vresolu-1-ypos-ystep)/vresolu; |
154 |
|
/* bottom adjust? */ |
155 |
|
if (ypos < 0) { |
156 |
|
ystep += ypos; |
183 |
|
if (write(zfd, (char *)zbar[0], hresolu*sizeof(float)) |
184 |
|
< hresolu*sizeof(float)) |
185 |
|
goto writerr; |
186 |
< |
close(zfd); |
186 |
> |
if (close(zfd) == -1) |
187 |
> |
goto writerr; |
188 |
|
for (i = 0; i <= psample; i++) |
189 |
|
free((char *)zbar[i]); |
190 |
|
} |
236 |
|
COLOR vline[MAXDIV+1]; |
237 |
|
float zline[MAXDIV+1]; |
238 |
|
int b = ysize; |
237 |
– |
double z; |
239 |
|
register int i, j; |
240 |
|
|
241 |
|
for (i = 0; i < xres; i++) { |
321 |
|
{ |
322 |
|
static RAY thisray; /* our ray for this pixel */ |
323 |
|
|
324 |
< |
viewray(thisray.rorg, thisray.rdir, &ourview, |
325 |
< |
(x+pixjitter())/hresolu, (y+pixjitter())/vresolu); |
324 |
> |
if (viewray(thisray.rorg, thisray.rdir, &ourview, |
325 |
> |
(x+pixjitter())/hresolu, (y+pixjitter())/vresolu) < 0) { |
326 |
> |
setcolor(col, 0.0, 0.0, 0.0); |
327 |
> |
return(0.0); |
328 |
> |
} |
329 |
|
|
330 |
|
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
331 |
|
|
333 |
|
|
334 |
|
copycolor(col, thisray.rcol); /* return color */ |
335 |
|
|
336 |
< |
return(thisray.rot); /* return distance */ |
336 |
> |
return(thisray.rt); /* return distance */ |
337 |
|
} |
338 |
|
|
339 |
|
|