--- ray/src/rt/rpict.c 1990/01/16 11:30:09 1.16 +++ ray/src/rt/rpict.c 1990/10/13 21:32:25 1.22 @@ -18,7 +18,7 @@ static char SCCSid[] = "$SunId$ LBL"; #else #include #endif -#include +#include #include "view.h" @@ -149,7 +149,7 @@ char *zfile, *oldfile; /* compute scanlines */ for (ypos -= ystep; ypos > -ystep; ypos -= ystep) { /* record progress */ - pctdone = 100.0*(vresolu-ypos-ystep)/vresolu; + pctdone = 100.0*(vresolu-1-ypos-ystep)/vresolu; /* bottom adjust? */ if (ypos < 0) { ystep += ypos; @@ -167,10 +167,11 @@ char *zfile, *oldfile; fillscanbar(scanbar, zbar, hresolu, ypos, ystep); /* write it out */ for (i = ystep; i > 0; i--) { - if (zfd!=-1 && write(zfd,zbar[i],hresolu*sizeof(float)) + if (zfd != -1 && write(zfd, (char *)zbar[i], + hresolu*sizeof(float)) < hresolu*sizeof(float)) goto writerr; - if (fwritescan(scanbar[i],hresolu,stdout) < 0) + if (fwritescan(scanbar[i], hresolu, stdout) < 0) goto writerr; } if (fflush(stdout) == EOF) @@ -178,10 +179,11 @@ char *zfile, *oldfile; } /* clean up */ if (zfd != -1) { - if (write(zfd,zbar[0],hresolu*sizeof(float)) + if (write(zfd, (char *)zbar[0], hresolu*sizeof(float)) < hresolu*sizeof(float)) goto writerr; - close(zfd); + if (close(zfd) == -1) + goto writerr; for (i = 0; i <= psample; i++) free((char *)zbar[i]); } @@ -233,7 +235,6 @@ int xres, y, ysize; COLOR vline[MAXDIV+1]; float zline[MAXDIV+1]; int b = ysize; - double z; register int i, j; for (i = 0; i < xres; i++) { @@ -319,8 +320,11 @@ int x, y; /* pixel position */ { static RAY thisray; /* our ray for this pixel */ - viewray(thisray.rorg, thisray.rdir, &ourview, - (x+pixjitter())/hresolu, (y+pixjitter())/vresolu); + if (viewray(thisray.rorg, thisray.rdir, &ourview, + (x+pixjitter())/hresolu, (y+pixjitter())/vresolu) < 0) { + setcolor(col, 0.0, 0.0, 0.0); + return(0.0); + } rayorigin(&thisray, NULL, PRIMARY, 1.0); @@ -328,7 +332,7 @@ int x, y; /* pixel position */ copycolor(col, thisray.rcol); /* return color */ - return(thisray.rot); /* return distance */ + return(thisray.rt); /* return distance */ }