--- ray/src/rt/rview.c 1991/10/21 12:58:00 1.21 +++ ray/src/rt/rview.c 1992/11/19 20:25:55 2.9 @@ -1,4 +1,4 @@ -/* Copyright (c) 1987 Regents of the University of California */ +/* Copyright (c) 1992 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -26,23 +26,26 @@ int ndims = 0; /* number of sampling dimensions */ int samplendx = 0; /* index for this sample */ int psample = 8; /* pixel sample size */ -double maxdiff = .15; /* max. sample difference */ +double maxdiff = .15; /* max. sample difference */ -double exposure = 1.0; /* exposure for scene */ +double exposure = 1.0; /* exposure for scene */ -double dstrsrc = 0.0; /* square source distribution */ -double shadthresh = .1; /* shadow threshold */ -double shadcert = .25; /* shadow certainty */ +double dstrsrc = 0.0; /* square source distribution */ +double shadthresh = .1; /* shadow threshold */ +double shadcert = .25; /* shadow certainty */ int directrelay = 0; /* number of source relays */ int vspretest = 128; /* virtual source pretest density */ -int directinvis = 0; /* sources invisible? */ -double srcsizerat = 0.; /* maximum ratio source size/dist. */ +int directvis = 1; /* sources visible? */ +double srcsizerat = 0.; /* maximum ratio source size/dist. */ +double specthresh = .3; /* specular sampling threshold */ +double specjitter = 1.; /* specular sampling jitter */ + int maxdepth = 4; /* maximum recursion depth */ -double minweight = 1e-2; /* minimum ray weight */ +double minweight = 1e-2; /* minimum ray weight */ COLOR ambval = BLKCOLOR; /* ambient value */ -double ambacc = 0.2; /* ambient accuracy */ +double ambacc = 0.2; /* ambient accuracy */ int ambres = 8; /* ambient resolution */ int ambdiv = 32; /* ambient divisions */ int ambssamp = 0; /* ambient super-samples */ @@ -65,7 +68,7 @@ static char *reserve_mem = NULL; /* pre-allocated res #define RESERVE_AMT 32768 /* amount of memory to reserve */ -#define CTRL(c) ('c'-'@') +#define CTRL(c) ((c)-'@') quit(code) /* quit program */ @@ -92,11 +95,13 @@ char *dname; error(USER, errmsg); } else return; +#ifndef NIX /* not there, try exec */ if ((dev = comm_init(dname, id)) == NULL) { sprintf(errmsg, "cannot start device \"%s\"", dname); error(USER, errmsg); } +#endif } @@ -169,8 +174,7 @@ freereserves() /* free memory reserves */ command(prompt) /* get/execute command */ char *prompt; { -#define badcom(s) strncmp(s, inpbuf, args-inpbuf-1) - double atof(); +#define badcom(s) strncmp(s, inpbuf, args-inpbuf-1) char inpbuf[256]; char *args; again: @@ -223,7 +227,16 @@ again: break; case 'm': /* move camera */ if (badcom("move")) +#ifdef MSTATS + { + if (badcom("memory")) + goto commerr; + printmemstats(stderr); + break; + } +#else goto commerr; +#endif getmove(args); break; case 'r': /* rotate/repaint */ @@ -240,7 +253,7 @@ again: goto commerr; getpivot(args); break; - case CTRL(R): /* redraw */ + case CTRL('R'): /* redraw */ redraw(); break; case 'w': /* write */ @@ -252,10 +265,10 @@ again: if (badcom("quit")) goto commerr; quit(0); - case CTRL(C): /* interrupt */ + case CTRL('C'): /* interrupt */ goto again; -#ifdef SIGTSTP - case CTRL(Z): /* stop */ +#ifdef SIGTSTP + case CTRL('Z'): /* stop */ devclose(); kill(0, SIGTSTP); /* pc stops here */ @@ -275,7 +288,7 @@ commerr: error(COMMAND, errmsg); break; } -#undef badcom +#undef badcom } @@ -285,11 +298,11 @@ rsample() /* sample the image */ RECT r; PNODE *p; register RECT *rl; - register PNODE **pl; + register PNODE **pl; register int x; /* * We initialize the bottom row in the image at our current - * resolution. During sampling, we check super-pixels to the + * resolution. During sampling, we check super-pixels to the * right and above by calling bigdiff(). If there is a significant * difference, we subsample the super-pixels. The testing process * includes initialization of the next row. @@ -300,8 +313,10 @@ rsample() /* sample the image */ if (rl == NULL) return; pl = (PNODE **)malloc(xsiz*sizeof(PNODE *)); - if (pl == NULL) + if (pl == NULL) { + free((char *)rl); return; + } /* * Initialize the bottom row. */ @@ -367,7 +382,7 @@ escape: int refine(p, xmin, ymin, xmax, ymax, pd) /* refine a node */ -register PNODE *p; +register PNODE *p; int xmin, ymin, xmax, ymax; int pd; { @@ -391,7 +406,7 @@ int pd; return(0); /* * The following paint order can leave a black pixel - * when redraw() is called in (*dev->paintr)(). + * if redraw() is called in (*dev->paintr)(). */ if (p->x >= mx && p->y >= my) pcopy(p, p->kid+UR);