--- ray/src/util/rad.c 1994/04/21 12:22:44 2.40 +++ ray/src/util/rad.c 1995/07/06 12:15:40 2.43 @@ -49,8 +49,9 @@ int onevalue(), catvalues(), boolvalue(), #define PENUMBRAS 20 /* shadow penumbras are desired */ #define VARIABILITY 21 /* level of light variability */ #define REPORT 22 /* report frequency and errfile */ +#define RAWSAVE 23 /* save raw picture file */ /* total number of variables */ -#define NVARS 23 +#define NVARS 24 VARIABLE vv[NVARS] = { /* variable-value pairs */ {"objects", 3, 0, NULL, catvalues}, @@ -76,6 +77,7 @@ VARIABLE vv[NVARS] = { /* variable-value pairs */ {"PENUMBRAS", 3, 0, NULL, boolvalue}, {"VARIABILITY", 3, 0, NULL, qualvalue}, {"REPORT", 3, 0, NULL, onevalue}, + {"RAWSAVE", 3, 0, NULL, boolvalue}, }; VARIABLE *matchvar(); @@ -117,6 +119,7 @@ time_t oct1date; /* date of post-mkillum octree (>= m int nowarn = 0; /* no warnings */ int explicate = 0; /* explicate variables */ int silent = 0; /* do work silently */ +int touchonly = 0; /* touch files only */ int noaction = 0; /* don't do anything */ int sayview = 0; /* print view out */ char *rvdevice = NULL; /* rview output device */ @@ -148,6 +151,9 @@ char *argv[]; case 'n': noaction++; break; + case 't': + touchonly++; + break; case 'e': explicate++; break; @@ -199,7 +205,7 @@ char *argv[]; exit(0); userr: fprintf(stderr, - "Usage: %s [-s][-n][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n", +"Usage: %s [-s][-n][-t][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n", progname); exit(1); } @@ -643,6 +649,10 @@ setdefaults() /* set default values for unassigned v vval(VARIABILITY) = "L"; vdef(VARIABILITY)++; } + if (!vdef(RAWSAVE)) { + vval(RAWSAVE) = "F"; + vdef(RAWSAVE)++; + } } @@ -685,20 +695,24 @@ oconv() /* run oconv and mkillum if necessary */ oconvopts(ocopts); /* get options */ if (octreedate < scenedate) { /* check date on original octree */ - /* build command */ - if (vdef(MATERIAL)) - sprintf(combuf, "oconv%s %s %s > %s", ocopts, - vval(MATERIAL), vval(SCENE), vval(OCTREE)); - else - sprintf(combuf, "oconv%s %s > %s", ocopts, - vval(SCENE), vval(OCTREE)); - - if (runcom(combuf)) { /* run it */ - fprintf(stderr, + if (touchonly && octreedate) + touch(vval(OCTREE)); + else { /* build command */ + if (vdef(MATERIAL)) + sprintf(combuf, "oconv%s %s %s > %s", ocopts, + vval(MATERIAL), vval(SCENE), + vval(OCTREE)); + else + sprintf(combuf, "oconv%s %s > %s", ocopts, + vval(SCENE), vval(OCTREE)); + + if (runcom(combuf)) { /* run it */ + fprintf(stderr, "%s: error generating octree\n\t%s removed\n", - progname, vval(OCTREE)); - unlink(vval(OCTREE)); - exit(1); + progname, vval(OCTREE)); + unlink(vval(OCTREE)); + exit(1); + } } octreedate = time((time_t *)NULL); if (octreedate < scenedate) /* in case clock is off */ @@ -711,59 +725,67 @@ oconv() /* run oconv and mkillum if necessary */ return; /* make octree0 */ if (oct0date < scenedate | oct0date < illumdate) { - /* build command */ + if (touchonly && oct0date) + touch(oct0name); + else { /* build command */ + if (octreedate) + sprintf(combuf, "oconv%s -i %s %s > %s", ocopts, + vval(OCTREE), vval(ILLUM), oct0name); + else if (vdef(MATERIAL)) + sprintf(combuf, "oconv%s %s %s > %s", ocopts, + vval(MATERIAL), vval(ILLUM), oct0name); + else + sprintf(combuf, "oconv%s %s > %s", ocopts, + vval(ILLUM), oct0name); + if (runcom(combuf)) { /* run it */ + fprintf(stderr, + "%s: error generating octree\n\t%s removed\n", + progname, oct0name); + unlink(oct0name); + exit(1); + } + } + oct0date = time((time_t *)NULL); + if (oct0date < octreedate) /* in case clock is off */ + oct0date = octreedate; + if (oct0date < illumdate) /* ditto */ + oct0date = illumdate; + } + if (touchonly && oct1date) + touch(oct1name); + else { + mkillumopts(mkopts); /* build mkillum command */ + mktemp(illumtmp); + sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts, + oct0name, vval(ILLUM), illumtmp); + if (runcom(combuf)) { /* run it */ + fprintf(stderr, "%s: error running mkillum\n", + progname); + unlink(illumtmp); + exit(1); + } + /* make octree1 (frozen) */ if (octreedate) - sprintf(combuf, "oconv%s -i %s %s > %s", ocopts, - vval(OCTREE), vval(ILLUM), oct0name); + sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts, + vval(OCTREE), illumtmp, oct1name); else if (vdef(MATERIAL)) - sprintf(combuf, "oconv%s %s %s > %s", ocopts, - vval(MATERIAL), vval(ILLUM), oct0name); + sprintf(combuf, "oconv%s -f %s %s > %s", ocopts, + vval(MATERIAL), illumtmp, oct1name); else - sprintf(combuf, "oconv%s %s > %s", ocopts, - vval(ILLUM), oct0name); + sprintf(combuf, "oconv%s -f %s > %s", ocopts, + illumtmp, oct1name); if (runcom(combuf)) { /* run it */ fprintf(stderr, "%s: error generating octree\n\t%s removed\n", - progname, oct0name); - unlink(oct0name); + progname, oct1name); + unlink(oct1name); exit(1); } - oct0date = time((time_t *)NULL); - if (oct0date < octreedate) /* in case clock is off */ - oct0date = octreedate; - if (oct0date < illumdate) /* ditto */ - oct0date = illumdate; + rmfile(illumtmp); } - mkillumopts(mkopts); /* build mkillum command */ - mktemp(illumtmp); - sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts, - oct0name, vval(ILLUM), illumtmp); - if (runcom(combuf)) { /* run it */ - fprintf(stderr, "%s: error running mkillum\n", progname); - unlink(illumtmp); - exit(1); - } - /* make octree1 (frozen) */ - if (octreedate) - sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts, - vval(OCTREE), illumtmp, oct1name); - else if (vdef(MATERIAL)) - sprintf(combuf, "oconv%s -f %s %s > %s", ocopts, - vval(MATERIAL), illumtmp, oct1name); - else - sprintf(combuf, "oconv%s -f %s > %s", ocopts, - illumtmp, oct1name); - if (runcom(combuf)) { /* run it */ - fprintf(stderr, - "%s: error generating octree\n\t%s removed\n", - progname, oct1name); - unlink(oct1name); - exit(1); - } oct1date = time((time_t *)NULL); if (oct1date < oct0date) /* in case clock is off */ oct1date = oct0date; - rmfile(illumtmp); } @@ -809,7 +831,10 @@ checkambfile() /* check date on ambient file */ if (!(afdate = fdate(vval(AMBFILE)))) return; if (oct1date > afdate) - rmfile(vval(AMBFILE)); + if (touchonly) + touch(vval(AMBFILE)); + else + rmfile(vval(AMBFILE)); } @@ -1023,7 +1048,7 @@ char *po; } po = addarg(po, "-pt .04"); if (vbool(PENUMBRAS)) - op = addarg(op, "-ds .1 -dj .7"); + op = addarg(op, "-ds .1 -dj .65"); else op = addarg(op, "-ds .2"); op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01"); @@ -1342,7 +1367,7 @@ char *opts, *po; char *vw; char combuf[512]; /* build command */ - if ((vw = getview(0, NULL)) == NULL) + if (touchonly || (vw = getview(0, NULL)) == NULL) return; if (sayview) printview(vw); @@ -1367,6 +1392,7 @@ char *opts, *po; char pfopts[128]; char vs[32], *vw; int vn, mult; + time_t rfdt, pfdt; /* get pfilt options */ pfiltopts(pfopts); /* get resolution, reporting */ @@ -1416,11 +1442,22 @@ char *opts, *po; sprintf(vs, "%d", vn); sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs); /* check date on picture */ - if (fdate(picfile) >= oct1date) + pfdt = fdate(picfile); + if (pfdt >= oct1date) continue; - /* build rpict command */ + /* get raw file name */ sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs); - if (fdate(rawfile) >= oct1date) /* recover */ + rfdt = fdate(rawfile); + if (touchonly) { /* update times only */ + if (rfdt) { + if (rfdt < oct1date) + touch(rawfile); + } else if (pfdt && pfdt < oct1date) + touch(picfile); + continue; + } + /* build rpict command */ + if (rfdt >= oct1date) /* recover */ sprintf(combuf, "rpict%s%s%s -ro %s %s", rep, po, opts, rawfile, oct1name); else { @@ -1462,12 +1499,32 @@ char *opts, *po; unlink(picfile); exit(1); } - /* remove raw file */ - rmfile(rawfile); + /* remove/rename raw file */ + if (vbool(RAWSAVE)) { + sprintf(combuf, "%s_%s.rwp", vval(PICTURE), vs); + mvfile(rawfile, combuf); + } else + rmfile(rawfile); } } +touch(fn) /* update a file */ +char *fn; +{ + if (!silent) + printf("\ttouch %s\n", fn); + if (noaction) + return(0); +#ifdef notused + if (access(fn, F_OK) == -1) /* create it */ + if (close(open(fn, O_WRONLY|O_CREAT, 0666)) == -1) + return(-1); +#endif + return(setfdate(fn, time((time_t *)NULL))); +} + + runcom(cs) /* run command */ char *cs; { @@ -1492,6 +1549,21 @@ char *fn; if (noaction) return(0); return(unlink(fn)); +} + + +mvfile(fold, fnew) /* move a file */ +char *fold, *fnew; +{ + if (!silent) +#ifdef MSDOS + printf("\trename %s %s\n", fold, fnew); +#else + printf("\tmv %s %s\n", fold, fnew); +#endif + if (noaction) + return(0); + return(rename(fold, fnew)); }