--- ray/src/rt/rv2.c 1991/11/21 10:10:30 2.2 +++ ray/src/rt/rv2.c 1992/03/04 16:52:10 2.8 @@ -22,8 +22,15 @@ static char SCCSid[] = "$SunId$ LBL"; #include -#define CTRL(c) ('c'-'@') +#define CTRL(c) ((c)-'@') +#ifdef SMLFLT +#define sscanvec(s,v) (sscanf(s,"%f %f %f",v,v+1,v+2)==3) +#else +#define sscanvec(s,v) (sscanf(s,"%lf %lf %lf",v,v+1,v+2)==3) +#endif + + extern char VersionID[]; extern char *progname; extern char *octname; @@ -75,7 +82,7 @@ char *s; sprintf(buf, "view type (%c): ", ourview.type); (*dev->comout)(buf); (*dev->comin)(buf, NULL); - if (buf[0] == CTRL(C)) return; + if (buf[0] == CTRL('C')) return; if (buf[0] && buf[0] != ourview.type) { nv.type = buf[0]; change++; @@ -85,8 +92,8 @@ char *s; ourview.vp[0], ourview.vp[1], ourview.vp[2]); (*dev->comout)(buf); (*dev->comin)(buf, NULL); - if (buf[0] == CTRL(C)) return; - if (sscanf(buf, "%lf %lf %lf", &nv.vp[0], &nv.vp[1], &nv.vp[2]) == 3) + if (buf[0] == CTRL('C')) return; + if (sscanvec(buf, nv.vp)) change++; else VCOPY(nv.vp, ourview.vp); @@ -94,8 +101,8 @@ char *s; ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]); (*dev->comout)(buf); (*dev->comin)(buf, NULL); - if (buf[0] == CTRL(C)) return; - if (sscanf(buf,"%lf %lf %lf",&nv.vdir[0],&nv.vdir[1],&nv.vdir[2]) == 3) + if (buf[0] == CTRL('C')) return; + if (sscanvec(buf, nv.vdir)) change++; else VCOPY(nv.vdir, ourview.vdir); @@ -103,8 +110,8 @@ char *s; ourview.vup[0], ourview.vup[1], ourview.vup[2]); (*dev->comout)(buf); (*dev->comin)(buf, NULL); - if (buf[0] == CTRL(C)) return; - if (sscanf(buf,"%lf %lf %lf",&nv.vup[0],&nv.vup[1],&nv.vup[2]) == 3) + if (buf[0] == CTRL('C')) return; + if (sscanvec(buf, nv.vup)) change++; else VCOPY(nv.vup, ourview.vup); @@ -112,7 +119,7 @@ char *s; ourview.horiz, ourview.vert); (*dev->comout)(buf); (*dev->comin)(buf, NULL); - if (buf[0] == CTRL(C)) return; + if (buf[0] == CTRL('C')) return; if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) == 2) change++; else { @@ -122,7 +129,7 @@ char *s; ourview.hoff, ourview.voff); (*dev->comout)(buf); (*dev->comin)(buf, NULL); - if (buf[0] == CTRL(C)) return; + if (buf[0] == CTRL('C')) return; if (sscanf(buf, "%lf %lf", &nv.hoff, &nv.voff) == 2) change++; else { @@ -246,7 +253,6 @@ register char *s; getexposure(s) /* get new exposure */ char *s; { - double atof(), pow(), fabs(); char buf[128]; register char *cp; register PNODE *p; @@ -291,7 +297,7 @@ char *s; e *= atof(cp); } if (p != NULL) { /* relative setting */ - if (bright(p->v) <= FTINY) { + if (bright(p->v) < 1e-25) { error(COMMAND, "cannot normalize to zero"); return; } @@ -380,7 +386,6 @@ register char *s; extern double shadcert; extern COLOR ambval; extern double ambacc; - extern double minarad; extern int ambres; extern int ambdiv; extern int ambssamp; @@ -388,11 +393,13 @@ register char *s; extern int directinvis; extern double srcsizerat; extern int do_irrad; + extern double specjitter; + extern double specthresh; char buf[128]; if (s[0] == '\0') { (*dev->comout)( - "aa ab ad ar as av b dc di dj ds dt i lr lw sp st: "); + "aa ab ad ar as av b dc di dj ds dt i lr lw ps pt sj st: "); (*dev->comin)(buf, NULL); s = buf; } @@ -456,27 +463,38 @@ register char *s; break; case 'r': if (getparam(s+2, "ambient resolution", 'i', &ambres)) - minarad = ambres > 0 ? - thescene.cusize/ambres : 0.0; + setambres(ambres); break; default: goto badparam; } break; - case 's': /* sample */ + case 'p': /* pixel */ switch (s[1]) { - case 'p': /* pixel */ - if (getparam(s+2, "sample pixel", 'i', &psample)) + case 's': /* sample */ + if (getparam(s+2, "pixel sample", 'i', &psample)) pdepth = 0; break; case 't': /* threshold */ - if (getparam(s+2, "sample threshold", 'r', &maxdiff)) + if (getparam(s+2, "pixel threshold", 'r', &maxdiff)) pdepth = 0; break; default: goto badparam; } break; + case 's': /* specular */ + switch (s[1]) { + case 'j': /* jitter */ + getparam(s+2, "specular jitter", 'r', &specjitter); + break; + case 't': /* threshold */ + getparam(s+2, "specular threshold", 'r', &specthresh); + break; + default: + goto badparam; + } + break; case '\0': /* nothing */ break; default:; @@ -496,9 +514,8 @@ char *s; int x, y; RAY thisray; - if (sscanf(s, "%lf %lf %lf %lf %lf %lf", - &thisray.rorg[0], &thisray.rorg[1], &thisray.rorg[2], - &thisray.rdir[0], &thisray.rdir[1], &thisray.rdir[2]) != 6) { + if (!sscanvec(s, thisray.rorg) || + !sscanvec(sskip(sskip(sskip(s))), thisray.rdir)) { if (dev->getcur == NULL) return;