--- ray/src/rt/rv2.c 1991/08/26 10:12:02 1.26 +++ ray/src/rt/rv2.c 1991/10/22 11:58:17 1.31 @@ -22,7 +22,9 @@ static char SCCSid[] = "$SunId$ LBL"; #define CTRL(c) ('c'-'@') +extern char VersionID[]; extern char *progname; +extern char *octname; getframe(s) /* get a new frame */ @@ -319,10 +321,10 @@ register union {int i; double d; COLOR C;} *ptr; (*dev->comout)(buf); (*dev->comin)(buf, NULL); if (sscanf(buf, "%d", &i0) != 1) - break; + return(0); } ptr->i = i0; - break; + return(1); case 'r': /* real */ if (sscanf(str, "%lf", &d0) != 1) { (*dev->comout)(dsc); @@ -330,10 +332,10 @@ register union {int i; double d; COLOR C;} *ptr; (*dev->comout)(buf); (*dev->comin)(buf, NULL); if (sscanf(buf, "%lf", &d0) != 1) - break; + return(0); } ptr->d = d0; - break; + return(1); case 'b': /* boolean */ if (sscanf(str, "%1s", buf) != 1) { (*dev->comout)(dsc); @@ -342,10 +344,10 @@ register union {int i; double d; COLOR C;} *ptr; (*dev->comin)(buf, NULL); if (buf[0] == '\0' || index("yY+1tTnN-0fF", buf[0]) == NULL) - break; + return(0); } ptr->i = index("yY+1tT", buf[0]) != NULL; - break; + return(1); case 'C': /* color */ if (sscanf(str, "%lf %lf %lf", &d0, &d1, &d2) != 3) { (*dev->comout)(dsc); @@ -356,10 +358,10 @@ register union {int i; double d; COLOR C;} *ptr; (*dev->comout)(buf); (*dev->comin)(buf, NULL); if (sscanf(buf, "%lf %lf %lf", &d0, &d1, &d2) != 3) - break; + return(0); } setcolor(ptr->C, d0, d1, d2); - break; + return(1); } } @@ -382,12 +384,13 @@ register char *s; extern int ambssamp; extern int ambounce; extern int directinvis; + extern double srcsizerat; extern int do_irrad; char buf[128]; if (s[0] == '\0') { (*dev->comout)( - "aa ab ad ar as av b dc di dj dt i lr lw sp st: "); + "aa ab ad ar as av b dc di dj ds dt i lr lw sp st: "); (*dev->comin)(buf, NULL); s = buf; } @@ -419,6 +422,9 @@ register char *s; getparam(s+2, "direct invisibility", 'b', &directinvis); break; + case 's': /* sampling */ + getparam(s+2, "direct sampling", 'r', &srcsizerat); + break; default: goto badparam; } @@ -447,8 +453,9 @@ register char *s; getparam(s+2, "ambient bounces", 'i', &ambounce); break; case 'r': - getparam(s+2, "ambient resolution", 'i', &ambres); - minarad = ambres > 0 ? thescene.cusize/ambres : 0.0; + if (getparam(s+2, "ambient resolution", 'i', &ambres)) + minarad = ambres > 0 ? + thescene.cusize/ambres : 0.0; break; default: goto badparam; @@ -457,12 +464,12 @@ register char *s; case 's': /* sample */ switch (s[1]) { case 'p': /* pixel */ - getparam(s+2, "sample pixel", 'i', &psample); - pdepth = 0; + if (getparam(s+2, "sample pixel", 'i', &psample)) + pdepth = 0; break; case 't': /* threshold */ - getparam(s+2, "sample threshold", 'r', &maxdiff); - pdepth = 0; + if (getparam(s+2, "sample threshold", 'r', &maxdiff)) + pdepth = 0; break; default: goto badparam; @@ -564,7 +571,11 @@ char *s; /* write header */ fputs(progname, fp); fprintview(&ourview, fp); - putc('\n', fp); + if (octname != NULL) + fprintf(fp, " %s\n", octname); + else + putc('\n', fp); + fprintf(fp, "SOFTWARE= %s\n", VersionID); if (exposure != 1.0) fputexpos(exposure, fp); if (dev->pixaspect != 1.0) @@ -574,14 +585,18 @@ char *s; fputresolu(YMAJOR|YDECR, hresolu, vresolu, fp); scanline = (COLR *)malloc(hresolu*sizeof(COLR)); - if (scanline == NULL) - error(SYSTEM, "out of memory in writepict"); + if (scanline == NULL) { + error(COMMAND, "not enough memory!"); + fclose(fp); + unlink(fname); + return; + } for (y = vresolu-1; y >= 0; y--) { getpictcolrs(y, scanline, &ptrunk, hresolu, vresolu); if (fwritecolrs(scanline, hresolu, fp) < 0) break; } + free((char *)scanline); if (fclose(fp) < 0) error(COMMAND, "write error"); - free((char *)scanline); }