--- ray/src/gen/mkillum.c 2007/09/18 19:51:07 2.30 +++ ray/src/gen/mkillum.c 2016/09/15 22:34:41 2.42 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: mkillum.c,v 2.30 2007/09/18 19:51:07 greg Exp $"; +static const char RCSid[] = "$Id: mkillum.c,v 2.42 2016/09/15 22:34:41 greg Exp $"; #endif /* * Make illum sources for optimizing rendering process @@ -8,9 +8,8 @@ static const char RCSid[] = "$Id: mkillum.c,v 2.30 200 #include #include -#include "platform.h" +#include "paths.h" /* win_popen() */ #include "mkillum.h" -#include "random.h" /* default parameters */ #define SAMPDENS 48 /* points per projected steradian */ @@ -25,14 +24,12 @@ static const char RCSid[] = "$Id: mkillum.c,v 2.30 200 struct illum_args thisillum = { /* our illum and default values */ 0, - UDzpos, DFLMAT, DFLDAT, 0, VOIDID, SAMPDENS, NSAMPS, - NULL, 0., }; @@ -48,10 +45,10 @@ int doneheader = 0; /* printed header yet? */ int warnings = 1; /* print warnings? */ void init(char *octnm, int np); -void filter(register FILE *infp, char *name); +void filter(FILE *infp, char *name); void xoptions(char *s, char *nm); void printopts(void); -void printhead(register int ac, register char **av); +void printhead(int ac, char **av); void xobject(FILE *fp, char *nm); @@ -64,14 +61,13 @@ main( /* compute illum distributions using rtrace */ int nprocs = 1; FILE *fp; int rval; - register int i; + int i; /* set global arguments */ gargv = argv; progname = gargv[0]; /* set up rendering defaults */ - dstrsrc = 0.25; + dstrsrc = 0.5; directrelay = 3; - directvis = 0; ambounce = 2; /* get options from command line */ for (i = 1; i < argc; i++) { @@ -152,7 +148,7 @@ init(char *octnm, int np) /* start rendering process( void eputs( /* put string to stderr */ - register char *s + char *s ) { static int midline = 0; @@ -177,14 +173,24 @@ char *s; void +quit(ec) /* make sure exit is called */ +int ec; +{ + if (ray_pnprocs > 0) /* close children if any */ + ray_pclose(0); + exit(ec); +} + + +void filter( /* process stream */ - register FILE *infp, + FILE *infp, char *name ) { char buf[512]; FILE *pfp; - register int c; + int c; while ((c = getc(infp)) != EOF) { if (isspace(c)) @@ -216,11 +222,10 @@ xoptions( /* process options in string s */ char *nm ) { - extern FILE *freopen(); char buf[64]; int negax; int nerrs = 0; - register char *cp; + char *cp; if (strncmp(s, "#@mkillum", 9) || !isspace(s[9])) { fputs(s, stdout); /* not for us */ @@ -298,22 +303,16 @@ xoptions( /* process options in string s */ } cp = sskip(cp); continue; - case 'd': /* sample density / BSDF data */ + case 'd': /* sample density */ if (*++cp != '=') break; - if (thisillum.sd != NULL) { - free_BSDF(thisillum.sd); - thisillum.sd = NULL; - } if (!*++cp || isspace(*cp)) continue; - if (isintd(++cp, " \t\n\r")) { + if (isintd(cp, " \t\n\r")) { thisillum.sampdens = atoi(cp); } else { - atos(buf, sizeof(buf), cp); - thisillum.sd = load_BSDF(buf); - if (thisillum.sd == NULL) - break; + error(WARNING, "direct BSDF input unsupported"); + goto opterr; } cp = sskip(cp); continue; @@ -359,40 +358,6 @@ xoptions( /* process options in string s */ } doneheader = 0; continue; - case 'u': /* up direction */ - if (*++cp != '=') - break; - if (!*++cp || isspace(*cp)) { - thisillum.udir = UDunknown; - continue; - } - negax = 0; - if (*cp == '+') - cp++; - else if (*cp == '-') { - negax++; - cp++; - } - switch (*cp++) { - case 'x': - case 'X': - thisillum.udir = negax ? UDxneg : UDxpos; - break; - case 'y': - case 'Y': - thisillum.udir = negax ? UDyneg : UDypos; - break; - case 'z': - case 'Z': - thisillum.udir = negax ? UDxneg : UDxpos; - break; - default: - thisillum.udir = UDunknown; - break; - } - if (thisillum.udir == UDunknown || !isspace(*cp)) - break; - continue; case '!': /* processed file! */ sprintf(errmsg, "(%s): already processed!", nm); error(WARNING, errmsg); @@ -435,38 +400,16 @@ printopts(void) /* print out option default values * printf("l+\t\t\t\t# light type on\n"); else printf("l-\t\t\t\t# light type off\n"); - printf("d=%d\t\t\t\t# density of points\n", thisillum.sampdens); - printf("s=%d\t\t\t\t# samples per point\n", thisillum.nsamps); + printf("d=%d\t\t\t\t# density of directions\n", thisillum.sampdens); + printf("s=%d\t\t\t\t# samples per direction\n", thisillum.nsamps); printf("b=%f\t\t\t# minimum average brightness\n", thisillum.minbrt); - switch (thisillum.udir) { - case UDzneg: - fputs("u=-Z\t\t\t\t# up is negative Z\n", stdout); - break; - case UDyneg: - fputs("u=-Y\t\t\t\t# up is negative Y\n", stdout); - break; - case UDxneg: - fputs("u=-X\t\t\t\t# up is negative X\n", stdout); - break; - case UDxpos: - fputs("u=+X\t\t\t\t# up is positive X\n", stdout); - break; - case UDypos: - fputs("u=+Y\t\t\t\t# up is positive Y\n", stdout); - break; - case UDzpos: - fputs("u=+Z\t\t\t\t# up is positive Z\n", stdout); - break; - case UDunknown: - break; - } } void printhead( /* print out header */ - register int ac, - register char **av + int ac, + char **av ) { putchar('#');