--- ray/src/util/rad.c 2015/08/02 01:32:15 2.120 +++ ray/src/util/rad.c 2023/11/16 23:37:29 2.132 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rad.c,v 2.120 2015/08/02 01:32:15 greg Exp $"; +static const char RCSid[] = "$Id: rad.c,v 2.132 2023/11/16 23:37:29 greg Exp $"; #endif /* * Executive program for oconv, rpict and pfilt @@ -17,7 +17,7 @@ static const char RCSid[] = "$Id: rad.c,v 2.120 2015/0 #include "paths.h" #include "vars.h" -#ifdef _WIN32 +#if defined(_WIN32) || defined(_WIN64) #define DELCMD "del" #define RENAMECMD "rename" #else @@ -64,7 +64,7 @@ static const char RCSid[] = "$Id: rad.c,v 2.120 2015/0 int NVARS = 31; VARIABLE vv[] = { /* variable-value pairs */ - {"AMBFILE", 3, 0, NULL, onevalue}, + {"AMBFILE", 3, 0, NULL, strvalue}, {"DETAIL", 3, 0, NULL, qualvalue}, {"EXPOSURE", 3, 0, NULL, fltvalue}, {"EYESEP", 3, 0, NULL, fltvalue}, @@ -75,15 +75,15 @@ VARIABLE vv[] = { /* variable-value pairs */ {"mkpmap", 3, 0, NULL, catvalues}, {"objects", 3, 0, NULL, catvalues}, {"oconv", 3, 0, NULL, catvalues}, - {"OCTREE", 3, 0, NULL, onevalue}, - {"OPTFILE", 3, 0, NULL, onevalue}, - {"PCMAP", 2, 0, NULL, onevalue}, + {"OCTREE", 3, 0, NULL, strvalue}, + {"OPTFILE", 3, 0, NULL, strvalue}, + {"PCMAP", 2, 0, NULL, strvalue}, {"PENUMBRAS", 3, 0, NULL, boolvalue}, {"pfilt", 2, 0, NULL, catvalues}, - {"PGMAP", 2, 0, NULL, onevalue}, - {"PICTURE", 3, 0, NULL, onevalue}, + {"PGMAP", 2, 0, NULL, strvalue}, + {"PICTURE", 3, 0, NULL, strvalue}, {"QUALITY", 3, 0, NULL, qualvalue}, - {"RAWFILE", 3, 0, NULL, onevalue}, + {"RAWFILE", 3, 0, NULL, strvalue}, {"render", 3, 0, NULL, catvalues}, {"REPORT", 3, 0, NULL, onevalue}, {"RESOLUTION", 3, 0, NULL, onevalue}, @@ -93,7 +93,7 @@ VARIABLE vv[] = { /* variable-value pairs */ {"UP", 2, 0, NULL, onevalue}, {"VARIABILITY", 3, 0, NULL, qualvalue}, {"view", 2, 0, NULL, NULL}, - {"ZFILE", 2, 0, NULL, onevalue}, + {"ZFILE", 2, 0, NULL, strvalue}, {"ZONE", 2, 0, NULL, onevalue}, }; @@ -242,12 +242,18 @@ main( /* load variable values */ loadvars(rifname); /* get any additional assignments */ - for (i++; i < argc; i++) - if (setvariable(argv[i], matchvar) < 0) { - fprintf(stderr, "%s: unknown variable: %s\n", + for (i++; i < argc; i++) { + int rv = setvariable(argv[i], matchvar); + if (rv < 0) { + fprintf(stderr, "%s: unknown setting: %s\n", progname, argv[i]); quit(1); } + if (!rv) + fprintf(stderr, + "%s: bad variable assignment: %s (ignored)\n", + progname, argv[i]); + } /* check assignments */ checkvalues(); /* check files and dates */ @@ -556,9 +562,10 @@ oconv(void) /* run oconv and mkillum if necessary * return; /* make octree0 */ if ((oct0date < scenedate) | (oct0date < illumdate)) { - if (touchonly && oct0date) - touch(oct0name); - else { /* build command */ + if (touchonly && (oct0date || oct1date)) { + if (oct0date) + touch(oct0name); + } else { /* build command */ if (octreedate) sprintf(combuf, "%s%s -i %s %s > %s", c_oconv, ocopts, vval(OCTREE), @@ -583,7 +590,7 @@ oconv(void) /* run oconv and mkillum if necessary * oct0date = octreedate; if (oct0date < illumdate) /* ditto */ oct0date = illumdate; - } + } if (touchonly && oct1date) touch(oct1name); else { @@ -752,7 +759,10 @@ mkpmapopts( /* get mkpmap options */ { /* BEWARE: This may be called via setdefaults(), so no assumptions */ - *mo = '\0'; + if (nprocs > 1) + sprintf(mo, " -n %d", nprocs); + else + *mo = '\0'; if (!vdef(MKPMAP)) return; if (vval(MKPMAP)[0] != '-') { @@ -786,8 +796,8 @@ ambval(void) /* compute ambient value */ { if (vdef(EXPOSURE)) { if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-') - return(.5/pow(2.,vflt(EXPOSURE))); - return(.5/vflt(EXPOSURE)); + return(.18/pow(2.,vflt(EXPOSURE))); + return(.18/vflt(EXPOSURE)); } if (vlet(ZONE) == 'E') return(10.); @@ -806,6 +816,13 @@ renderopts( /* set rendering options */ { char pmapf[256], *bw; + if (vdef(PGMAP)) { + *op = '\0'; + bw = sskip2(vval(PGMAP), 2); + atos(pmapf, sizeof(pmapf), vval(PGMAP)); + op = addarg(addarg(op, "-ap"), pmapf); + if (atoi(bw) > 0) op = addarg(op, bw); + } switch(vscale(QUALITY)) { case LOW: lowqopts(op, po); @@ -817,20 +834,18 @@ renderopts( /* set rendering options */ hiqopts(op, po); break; } - if (vdef(PGMAP)) { - bw = sskip2(vval(PGMAP), 2); - atos(pmapf, sizeof(pmapf), vval(PGMAP)); - op = addarg(addarg(op, "-ap"), pmapf); - if (atoi(bw) > 0) op = addarg(op, bw); - } if (vdef(PCMAP)) { bw = sskip2(vval(PCMAP), 2); atos(pmapf, sizeof(pmapf), vval(PCMAP)); op = addarg(addarg(op, "-ap"), pmapf); if (atoi(bw) > 0) op = addarg(op, bw); } - if (vdef(RENDER)) + if (vdef(RENDER)) { op = addarg(op, vval(RENDER)); + bw = strstr(vval(RENDER), "-aa "); + if (bw != NULL && atof(bw+4) <= FTINY) + overture = 0; + } if (rvdevice != NULL) { if (vdef(RVU)) { if (vval(RVU)[0] != '-') { @@ -915,7 +930,7 @@ lowqopts( /* low quality rendering options */ d = ambval(); sprintf(op, " -av %.2g %.2g %.2g", d, d, d); op += strlen(op); - op = addarg(op, "-lr 6 -lw .003"); + op = addarg(op, "-lr 6 -lw .001"); } @@ -1069,11 +1084,11 @@ hiqopts( /* high quality rendering options */ d = ambval(); sprintf(op, " -av %.2g %.2g %.2g", d, d, d); op += strlen(op); - op = addarg(op, "-lr 12 -lw 1e-5"); + op = addarg(op, "-lr 12 -lw 5e-6"); } -#ifdef _WIN32 +#if defined(_WIN32) || defined(_WIN64) static void setenv( /* set an environment variable */ char *vname, @@ -1120,7 +1135,7 @@ xferopts( /* transfer options if indicated */ syserr(vval(OPTFILE)); sprintf(ro, " @%s", vval(OPTFILE)); } -#ifdef _WIN32 +#if defined(_WIN32) || defined(_WIN64) else if (n > 50) { setenv("ROPT", ro+1); strcpy(ro, " $ROPT"); @@ -1298,7 +1313,7 @@ specview( /* get proper view spec from vs */ if (cp == viewopts) /* append any additional options */ vs++; /* skip prefixed space if unneeded */ strcpy(cp, vs); -#ifdef _WIN32 +#if defined(_WIN32) || defined(_WIN64) if (strlen(viewopts) > 40) { setenv("VIEW", viewopts); return("$VIEW"); @@ -1344,7 +1359,7 @@ getview( /* get view n, or NULL if none */ } numview: mv = nvalue(VIEWS, n); /* use view n */ - if ((vn != NULL) & (mv != NULL)) + if ((vn != NULL) & (mv != NULL)) { if (*mv != '-') { char *mv2 = mv; while (*mv2 && !isspace(*mv2)) @@ -1352,7 +1367,7 @@ numview: *vn = '\0'; } else sprintf(vn, "%d", n+1); - + } return(specview(mv)); } @@ -1366,14 +1381,14 @@ myprintview( /* print out selected view */ VIEW vwr; char buf[128]; char *cp; -#ifdef _WIN32 +#if defined(_WIN32) || defined(_WIN64) /* XXX Should we allow something like this for all platforms? */ /* XXX Or is it still required at all? */ again: #endif if (vopts == NULL) return(-1); -#ifdef _WIN32 +#if defined(_WIN32) || defined(_WIN64) if (vopts[0] == '$') { vopts = getenv(vopts+1); goto again; @@ -1520,6 +1535,7 @@ rpict( /* run rpict and pfilt for each view */ fprintf(stderr, "%s: cannot create\n", pfile); quit(1); } + pfile[-5] = '\0'; pfile = NULL; } } @@ -1597,8 +1613,8 @@ rpict( /* run rpict and pfilt for each view */ } else { if (overture) { /* run overture calculation */ sprintf(combuf, - "%s%s %s%s -x 64 -y 64 -ps 1 %s > %s", - c_rpict, rep, vw, opts, + "%s%s %s%s%s -x 64 -y 64 -ps 1 %s > %s", + c_rpict, rep, vw, opts, po, oct1name, overfile); if (!do_rpiece || !next_process(0)) { if (runcom(combuf)) {