19 |
|
|
20 |
|
|
21 |
|
void |
22 |
+ |
quit(code) /* quit program */ |
23 |
+ |
int code; |
24 |
+ |
{ |
25 |
+ |
if (ray_pnprocs > 0) /* close children if any */ |
26 |
+ |
ray_pclose(0); |
27 |
+ |
else if (!ray_pnprocs) /* in parent */ |
28 |
+ |
devclose(); |
29 |
+ |
exit(code); |
30 |
+ |
} |
31 |
+ |
|
32 |
+ |
|
33 |
+ |
void |
34 |
|
devopen( /* open device driver */ |
35 |
|
char *dname |
36 |
|
) |
97 |
|
(*dev->comout)(buf); |
98 |
|
refine(&ptrunk, pdepth+1); |
99 |
|
} |
88 |
– |
if (waitrays() < 0) |
89 |
– |
quit(1); |
100 |
|
if (dev->inpready) /* noticed some input */ |
101 |
|
command(": "); |
102 |
|
else /* finished this depth */ |
119 |
|
; |
120 |
|
if (*args) *args++ = '\0'; |
121 |
|
else *++args = '\0'; |
122 |
+ |
|
123 |
+ |
if (waitrays() < 0) /* clear ray queue */ |
124 |
+ |
quit(1); |
125 |
|
|
126 |
|
switch (inpbuf[0]) { |
127 |
|
case 'f': /* new frame (|focus|free) */ |
189 |
|
break; |
190 |
|
case 'm': /* move camera (or memstats) */ |
191 |
|
if (badcom("move")) |
179 |
– |
#ifdef MSTATS |
180 |
– |
{ |
181 |
– |
if (badcom("memory")) |
182 |
– |
goto commerr; |
183 |
– |
printmemstats(stderr); |
184 |
– |
break; |
185 |
– |
} |
186 |
– |
#else |
192 |
|
goto commerr; |
188 |
– |
#endif |
193 |
|
getmove(args); |
194 |
|
break; |
195 |
|
case 'r': /* rotate/repaint */ |
283 |
|
/* sample the image */ |
284 |
|
for (y = 0; /* y < ysiz */ ; y++) { |
285 |
|
for (x = 0; x < xsiz-1; x++) { |
286 |
< |
if (dev->inpready || errno == ENOMEM) |
286 |
> |
if (dev->inpready) |
287 |
|
goto escape; |
288 |
|
/* |
289 |
|
* Test super-pixel to the right. |
297 |
|
if (y >= ysiz-1) |
298 |
|
break; |
299 |
|
for (x = 0; x < xsiz; x++) { |
300 |
< |
if (dev->inpready || errno == ENOMEM) |
300 |
> |
if (dev->inpready) |
301 |
|
goto escape; |
302 |
|
/* |
303 |
|
* Find super-pixel at this position in next row. |
331 |
|
{ |
332 |
|
int growth; |
333 |
|
int mx, my; |
330 |
– |
int i; |
334 |
|
|
335 |
|
if (dev->inpready) /* quit for input */ |
336 |
|
return(0); |
398 |
|
growth += refine(p->kid+DR, pd-1); |
399 |
|
if (my < pframe.u) |
400 |
|
growth += refine(p->kid+UR, pd-1); |
398 |
– |
} |
399 |
– |
/* recompute sum */ |
400 |
– |
if (growth) { |
401 |
– |
setcolor(p->v, 0.0, 0.0, 0.0); |
402 |
– |
for (i = 0; i < 4; i++) |
403 |
– |
addcolor(p->v, p->kid[i].v); |
404 |
– |
scalecolor(p->v, 0.25); |
401 |
|
} |
402 |
|
return(growth); |
403 |
|
} |