--- ray/src/rt/rv2.c 1992/01/15 16:55:21 2.5 +++ ray/src/rt/rv2.c 1992/04/06 18:04:19 2.9 @@ -1,4 +1,4 @@ -/* Copyright (c) 1991 Regents of the University of California */ +/* Copyright (c) 1992 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -24,6 +24,13 @@ static char SCCSid[] = "$SunId$ LBL"; #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; @@ -58,6 +65,16 @@ char *s; int change = 0; VIEW nv; + while (isspace(*s)) + s++; + if (*s == '-') { /* command line parameters */ + copystruct(&nv, &ourview); + if (sscanview(&nv, s)) + newview(&nv); + else + error(COMMAND, "bad view option(s)"); + return; + } if (sscanf(s, "%s", buf) == 1) { /* write parameters to a file */ if ((fname = getpath(buf, NULL, 0)) == NULL || (fp = fopen(fname, "a")) == NULL) { @@ -86,7 +103,7 @@ char *s; (*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 (sscanvec(buf, nv.vp)) change++; else VCOPY(nv.vp, ourview.vp); @@ -95,7 +112,7 @@ char *s; (*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 (sscanvec(buf, nv.vdir)) change++; else VCOPY(nv.vdir, ourview.vdir); @@ -104,7 +121,7 @@ char *s; (*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 (sscanvec(buf, nv.vup)) change++; else VCOPY(nv.vup, ourview.vup); @@ -290,7 +307,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; } @@ -379,7 +396,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; @@ -457,8 +473,7 @@ 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; @@ -509,9 +524,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;