--- ray/src/rt/rpict.c 1990/01/19 00:00:19 1.17 +++ ray/src/rt/rpict.c 1990/11/01 12:06:01 1.23 @@ -18,7 +18,7 @@ static char SCCSid[] = "$SunId$ LBL"; #else #include #endif -#include +#include #include "view.h" @@ -141,7 +141,8 @@ char *zfile, *oldfile; fputresolu(YMAJOR|YDECR, hresolu, vresolu, stdout); /* recover file and compute first */ i = salvage(oldfile); - if (zfd != -1 && lseek(zfd, (long)i*hresolu*sizeof(float), 0) == -1) + if (zfd != -1 && i > 0 && + lseek(zfd, (long)i*hresolu*sizeof(float), 0) == -1) error(SYSTEM, "z file seek error in render"); ypos = vresolu-1 - i; fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample); @@ -149,7 +150,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; @@ -182,7 +183,8 @@ char *zfile, *oldfile; 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]); } @@ -234,7 +236,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++) { @@ -320,8 +321,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); @@ -329,7 +333,7 @@ int x, y; /* pixel position */ copycolor(col, thisray.rcol); /* return color */ - return(thisray.rot); /* return distance */ + return(thisray.rt); /* return distance */ }