1 |
< |
/* Copyright (c) 1987 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
26 |
|
int samplendx = 0; /* index for this sample */ |
27 |
|
|
28 |
|
int psample = 8; /* pixel sample size */ |
29 |
< |
double maxdiff = .15; /* max. sample difference */ |
29 |
> |
double maxdiff = .15; /* max. sample difference */ |
30 |
|
|
31 |
< |
double exposure = 1.0; /* exposure for scene */ |
31 |
> |
double exposure = 1.0; /* exposure for scene */ |
32 |
|
|
33 |
< |
double dstrsrc = 0.0; /* square source distribution */ |
34 |
< |
double shadthresh = .1; /* shadow threshold */ |
35 |
< |
double shadcert = .25; /* shadow certainty */ |
33 |
> |
double dstrsrc = 0.0; /* square source distribution */ |
34 |
> |
double shadthresh = .1; /* shadow threshold */ |
35 |
> |
double shadcert = .25; /* shadow certainty */ |
36 |
|
int directrelay = 0; /* number of source relays */ |
37 |
|
int vspretest = 128; /* virtual source pretest density */ |
38 |
< |
int directinvis = 0; /* sources invisible? */ |
39 |
< |
double srcsizerat = 0.; /* maximum ratio source size/dist. */ |
38 |
> |
int directvis = 1; /* sources visible? */ |
39 |
> |
double srcsizerat = 0.; /* maximum ratio source size/dist. */ |
40 |
|
|
41 |
+ |
double specthresh = .3; /* specular sampling threshold */ |
42 |
+ |
double specjitter = 1.; /* specular sampling jitter */ |
43 |
+ |
|
44 |
|
int maxdepth = 4; /* maximum recursion depth */ |
45 |
< |
double minweight = 1e-2; /* minimum ray weight */ |
45 |
> |
double minweight = 1e-2; /* minimum ray weight */ |
46 |
|
|
47 |
|
COLOR ambval = BLKCOLOR; /* ambient value */ |
48 |
< |
double ambacc = 0.2; /* ambient accuracy */ |
48 |
> |
double ambacc = 0.2; /* ambient accuracy */ |
49 |
|
int ambres = 8; /* ambient resolution */ |
50 |
|
int ambdiv = 32; /* ambient divisions */ |
51 |
|
int ambssamp = 0; /* ambient super-samples */ |
58 |
|
|
59 |
|
struct driver *dev = NULL; /* driver functions */ |
60 |
|
|
61 |
+ |
char rifname[128]; /* rad input file name */ |
62 |
+ |
|
63 |
|
VIEW oldview; /* previous view parameters */ |
64 |
|
|
65 |
|
PNODE ptrunk; /* the base of our image */ |
70 |
|
|
71 |
|
#define RESERVE_AMT 32768 /* amount of memory to reserve */ |
72 |
|
|
73 |
< |
#define CTRL(c) ('c'-'@') |
73 |
> |
#define CTRL(c) ((c)-'@') |
74 |
|
|
75 |
|
|
76 |
|
quit(code) /* quit program */ |
77 |
|
int code; |
78 |
|
{ |
79 |
+ |
#ifdef MSTATS |
80 |
+ |
if (code == 2 && errno == ENOMEM) |
81 |
+ |
printmemstats(stderr); |
82 |
+ |
#endif |
83 |
|
devclose(); |
84 |
|
exit(code); |
85 |
|
} |
101 |
|
error(USER, errmsg); |
102 |
|
} else |
103 |
|
return; |
104 |
+ |
#ifndef NIX |
105 |
|
/* not there, try exec */ |
106 |
|
if ((dev = comm_init(dname, id)) == NULL) { |
107 |
|
sprintf(errmsg, "cannot start device \"%s\"", dname); |
108 |
|
error(USER, errmsg); |
109 |
|
} |
110 |
+ |
#endif |
111 |
|
} |
112 |
|
|
113 |
|
|
180 |
|
command(prompt) /* get/execute command */ |
181 |
|
char *prompt; |
182 |
|
{ |
183 |
< |
#define badcom(s) strncmp(s, inpbuf, args-inpbuf-1) |
173 |
< |
double atof(); |
183 |
> |
#define badcom(s) strncmp(s, inpbuf, args-inpbuf-1) |
184 |
|
char inpbuf[256]; |
185 |
|
char *args; |
186 |
|
again: |
191 |
|
else *++args = '\0'; |
192 |
|
|
193 |
|
switch (inpbuf[0]) { |
194 |
< |
case 'f': /* new frame */ |
195 |
< |
if (badcom("frame")) |
196 |
< |
goto commerr; |
194 |
> |
case 'f': /* new frame (or free mem.) */ |
195 |
> |
if (badcom("frame")) { |
196 |
> |
if (badcom("free")) |
197 |
> |
goto commerr; |
198 |
> |
free_objmem(); |
199 |
> |
break; |
200 |
> |
} |
201 |
|
getframe(args); |
202 |
|
break; |
203 |
|
case 'v': /* view */ |
210 |
|
goto commerr; |
211 |
|
lastview(args); |
212 |
|
break; |
213 |
+ |
case 'V': /* save view */ |
214 |
+ |
if (badcom("V")) |
215 |
+ |
goto commerr; |
216 |
+ |
saveview(args); |
217 |
+ |
break; |
218 |
+ |
case 'L': /* load view */ |
219 |
+ |
if (badcom("L")) |
220 |
+ |
goto commerr; |
221 |
+ |
loadview(args); |
222 |
+ |
break; |
223 |
|
case 'e': /* exposure */ |
224 |
|
if (badcom("exposure")) |
225 |
|
goto commerr; |
245 |
|
goto commerr; |
246 |
|
getaim(args); |
247 |
|
break; |
248 |
< |
case 'm': /* move camera */ |
248 |
> |
case 'm': /* move camera (or memstats) */ |
249 |
|
if (badcom("move")) |
250 |
+ |
#ifdef MSTATS |
251 |
+ |
{ |
252 |
+ |
if (badcom("memory")) |
253 |
+ |
goto commerr; |
254 |
+ |
printmemstats(stderr); |
255 |
+ |
break; |
256 |
+ |
} |
257 |
+ |
#else |
258 |
|
goto commerr; |
259 |
+ |
#endif |
260 |
|
getmove(args); |
261 |
|
break; |
262 |
|
case 'r': /* rotate/repaint */ |
273 |
|
goto commerr; |
274 |
|
getpivot(args); |
275 |
|
break; |
276 |
< |
case CTRL(R): /* redraw */ |
276 |
> |
case CTRL('R'): /* redraw */ |
277 |
|
redraw(); |
278 |
|
break; |
279 |
|
case 'w': /* write */ |
285 |
|
if (badcom("quit")) |
286 |
|
goto commerr; |
287 |
|
quit(0); |
288 |
< |
case CTRL(C): /* interrupt */ |
288 |
> |
case CTRL('C'): /* interrupt */ |
289 |
|
goto again; |
290 |
< |
#ifdef SIGTSTP |
291 |
< |
case CTRL(Z): /* stop */ |
290 |
> |
#ifdef SIGTSTP |
291 |
> |
case CTRL('Z'): /* stop */ |
292 |
|
devclose(); |
293 |
|
kill(0, SIGTSTP); |
294 |
|
/* pc stops here */ |
308 |
|
error(COMMAND, errmsg); |
309 |
|
break; |
310 |
|
} |
311 |
< |
#undef badcom |
311 |
> |
#undef badcom |
312 |
|
} |
313 |
|
|
314 |
|
|
318 |
|
RECT r; |
319 |
|
PNODE *p; |
320 |
|
register RECT *rl; |
321 |
< |
register PNODE **pl; |
321 |
> |
register PNODE **pl; |
322 |
|
register int x; |
323 |
|
/* |
324 |
|
* We initialize the bottom row in the image at our current |
325 |
< |
* resolution. During sampling, we check super-pixels to the |
325 |
> |
* resolution. During sampling, we check super-pixels to the |
326 |
|
* right and above by calling bigdiff(). If there is a significant |
327 |
|
* difference, we subsample the super-pixels. The testing process |
328 |
|
* includes initialization of the next row. |
333 |
|
if (rl == NULL) |
334 |
|
return; |
335 |
|
pl = (PNODE **)malloc(xsiz*sizeof(PNODE *)); |
336 |
< |
if (pl == NULL) |
336 |
> |
if (pl == NULL) { |
337 |
> |
free((char *)rl); |
338 |
|
return; |
339 |
+ |
} |
340 |
|
/* |
341 |
|
* Initialize the bottom row. |
342 |
|
*/ |
402 |
|
|
403 |
|
int |
404 |
|
refine(p, xmin, ymin, xmax, ymax, pd) /* refine a node */ |
405 |
< |
register PNODE *p; |
405 |
> |
register PNODE *p; |
406 |
|
int xmin, ymin, xmax, ymax; |
407 |
|
int pd; |
408 |
|
{ |
426 |
|
return(0); |
427 |
|
/* |
428 |
|
* The following paint order can leave a black pixel |
429 |
< |
* when redraw() is called in (*dev->paintr)(). |
429 |
> |
* if redraw() is called in (*dev->paintr)(). |
430 |
|
*/ |
431 |
|
if (p->x >= mx && p->y >= my) |
432 |
|
pcopy(p, p->kid+UR); |