--- ray/src/util/rad.c 1993/04/06 17:21:04 2.7 +++ ray/src/util/rad.c 1993/07/16 12:41:21 2.15 @@ -105,6 +105,7 @@ extern long fdate(), time(); long scenedate; /* date of latest scene or object file */ long octreedate; /* date of octree */ +long matdate; /* date of latest material file */ int explicate = 0; /* explicate variables */ int silent = 0; /* do work silently */ @@ -423,6 +424,9 @@ checkfiles() /* check for existence and modified tim vnam(OCTREE), vnam(SCENE)); exit(1); } + matdate = -1; + if (vdef(MATERIAL)) + matdate = checklast(vval(MATERIAL)); } @@ -561,11 +565,12 @@ checkambfile() /* check date on ambient file */ { long afdate; - if (vdef(AMBFILE)) { - afdate = fdate(vval(AMBFILE)); - if (afdate >= 0 & octreedate > afdate) - rmfile(vval(AMBFILE)); - } + if (!vdef(AMBFILE)) + return; + if ((afdate = fdate(vval(AMBFILE))) < 0) + return; + if (octreedate > afdate | matdate > afdate) + rmfile(vval(AMBFILE)); } @@ -784,31 +789,26 @@ xferopts(ro) /* transfer options if indicated */ char *ro; { int fd, n; + register char *cp; n = strlen(ro); if (n < 2) return; if (vdef(OPTFILE)) { - if ((fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) + for (cp = ro; cp[1]; cp++) + if (isspace(cp[1]) && cp[2] == '-' && isalpha(cp[3])) + *cp = '\n'; + else + *cp = cp[1]; + *cp = '\n'; + fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666); + if (fd < 0 || write(fd, ro, n) != n || close(fd) < 0) syserr(vval(OPTFILE)); - if (write(fd, ro+1, n-1) != n-1) - syserr(vval(OPTFILE)); - write(fd, "\n", 1); - close(fd); - sprintf(ro, " \"^%s\"", vval(OPTFILE)); + sprintf(ro, " @%s", vval(OPTFILE)); } #ifdef MSDOS else if (n > 50) { - register char *evp = bmalloc(n+6); - if (evp == NULL) - syserr(progname); - strcpy(evp, "ROPT="); - strcat(evp, ro); - if (putenv(evp) != 0) { - fprintf(stderr, "%s: out of environment space\n", - progname); - exit(1); - } + setenv("ROPT", ro+1); strcpy(ro, " $ROPT"); } #endif @@ -823,8 +823,14 @@ register char *po; po = addarg(po, "-1 -e"); po = addarg(po, vval(EXPOSURE)); } - if (vscale(QUALITY) == HIGH) - po = addarg(po, "-r .65"); + switch (vscale(QUALITY)) { + case MEDIUM: + po = addarg(po, "-r 1"); + break; + case HIGH: + po = addarg(po, "-m .25"); + break; + } if (vdef(PFILT)) po = addarg(po, vval(PFILT)); } @@ -948,8 +954,13 @@ register char *vs; cp += strlen(cp); } } - /* append any additional options */ - strcpy(cp, vs); + strcpy(cp, vs); /* append any additional options */ +#ifdef MSDOS + if (strlen(viewopts) > 40) { + setenv("VIEW", viewopts); + return("$VIEW"); + } +#endif return(viewopts); } @@ -957,11 +968,11 @@ register char *vs; char * getview(n, vn) /* get view n, or NULL if none */ int n; -char *vn; +char *vn; /* returned view name */ { - register char *mv; + register char *mv = NULL; - if (viewselect != NULL) { + if (viewselect != NULL) { /* command-line selected */ if (n) /* only do one */ return(NULL); if (viewselect[0] == '-') { /* already specified */ @@ -980,13 +991,14 @@ char *vn; return(specview(mv)); return(specview(viewselect)); /* standard view? */ } - if (vn != NULL && (mv = nvalue(vv+VIEW, n)) != NULL) { + mv = nvalue(vv+VIEW, n); /* use view n */ + if (vn != NULL & mv != NULL) { if (*mv != '-') while (*mv && !isspace(*mv)) *vn++ = *mv++; *vn = '\0'; } - return(specview(nvalue(vv+VIEW, n))); /* use view n */ + return(specview(mv)); } @@ -1014,6 +1026,7 @@ char *opts; char pfopts[128]; char vs[32], *vw; int vn, mult; + long lastdate; /* get pfilt options */ pfiltopts(pfopts); /* get resolution, reporting */ @@ -1044,6 +1057,8 @@ char *opts; else badvalue(REPORT); } + /* get update time */ + lastdate = octreedate > matdate ? octreedate : matdate; /* do each view */ vn = 0; while ((vw = getview(vn++, vs)) != NULL) { @@ -1051,11 +1066,11 @@ char *opts; sprintf(vs, "%d", vn); sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs); /* check date on picture */ - if (fdate(picfile) > octreedate) + if (fdate(picfile) >= lastdate) continue; /* build rpict command */ sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs); - if (fdate(rawfile) > octreedate) /* recover */ + if (fdate(rawfile) >= octreedate) /* recover */ sprintf(combuf, "rpict%s%s -ro %s %s", rep, opts, rawfile, vval(OCTREE)); else { @@ -1128,6 +1143,26 @@ char *fn; return(0); return(unlink(fn)); } + + +#ifdef MSDOS +setenv(vname, value) /* set an environment variable */ +char *vname, *value; +{ + register char *evp; + + evp = bmalloc(strlen(vname)+strlen(value)+2); + if (evp == NULL) + syserr(progname); + sprintf(evp, "%s=%s", vname, value); + if (putenv(evp) != 0) { + fprintf(stderr, "%s: out of environment space\n", progname); + exit(1); + } + if (!silent) + printf("set %s\n", evp); +} +#endif badvalue(vc) /* report bad variable value and exit */