| 25 |
|
#define sscanvec(s,v) (sscanf(s,"%lf %lf %lf",v,v+1,v+2)==3) |
| 26 |
|
#endif |
| 27 |
|
|
| 28 |
< |
static int niflush; /* flushes since newimage() */ |
| 28 |
> |
static unsigned long niflush; /* flushes since newimage() */ |
| 29 |
|
|
| 30 |
|
int |
| 31 |
|
getrect( /* get a box */ |
| 146 |
|
return(gcol); |
| 147 |
|
} |
| 148 |
|
|
| 149 |
+ |
static void |
| 150 |
+ |
recolor( /* recolor the given node */ |
| 151 |
+ |
PNODE *p |
| 152 |
+ |
) |
| 153 |
+ |
{ |
| 154 |
+ |
while (p->kid != NULL) { /* need to propogate down */ |
| 155 |
+ |
int mx = (p->xmin + p->xmax) >> 1; |
| 156 |
+ |
int my = (p->ymin + p->ymax) >> 1; |
| 157 |
+ |
int ki; |
| 158 |
+ |
if (p->x >= mx) |
| 159 |
+ |
ki = (p->y >= my) ? UR : DR; |
| 160 |
+ |
else |
| 161 |
+ |
ki = (p->y >= my) ? UL : DL; |
| 162 |
+ |
pcopy(p, p->kid+ki); |
| 163 |
+ |
p = p->kid + ki; |
| 164 |
+ |
} |
| 165 |
|
|
| 166 |
+ |
(*dev->paintr)(greyscale?greyof(p->v):p->v, |
| 167 |
+ |
p->xmin, p->ymin, p->xmax, p->ymax); |
| 168 |
+ |
} |
| 169 |
+ |
|
| 170 |
|
int |
| 171 |
|
paint( /* compute and paint a rectangle */ |
| 172 |
|
PNODE *p |
| 175 |
|
extern int ray_pnprocs; |
| 176 |
|
static unsigned long lastflush = 0; |
| 177 |
|
static RAY thisray; |
| 178 |
+ |
int flushintvl; |
| 179 |
|
double h, v; |
| 180 |
|
|
| 181 |
|
if (p->xmax - p->xmin <= 0 || p->ymax - p->ymin <= 0) { /* empty */ |
| 206 |
|
copycolor(p->v, thisray.rcol); |
| 207 |
|
scalecolor(p->v, exposure); |
| 208 |
|
|
| 209 |
< |
(*dev->paintr)(greyscale?greyof(p->v):p->v, |
| 189 |
< |
p->xmin, p->ymin, p->xmax, p->ymax); |
| 209 |
> |
recolor(p); /* paint it */ |
| 210 |
|
|
| 211 |
< |
if (dev->flush != NULL && raynum - lastflush >= ray_pnprocs * |
| 212 |
< |
(ambounce > 0 && niflush < WFLUSH ? niflush : WFLUSH)) { |
| 211 |
> |
if (ambounce <= 0) /* shall we check for input? */ |
| 212 |
> |
flushintvl = ray_pnprocs*WFLUSH; |
| 213 |
> |
else if (niflush < WFLUSH) |
| 214 |
> |
flushintvl = ray_pnprocs*niflush/(ambounce+1); |
| 215 |
> |
else |
| 216 |
> |
flushintvl = ray_pnprocs*WFLUSH/(ambounce+1); |
| 217 |
> |
|
| 218 |
> |
if (dev->flush != NULL && raynum - lastflush >= flushintvl) { |
| 219 |
|
lastflush = raynum; |
| 220 |
|
(*dev->flush)(); |
| 221 |
|
niflush++; |
| 225 |
|
|
| 226 |
|
|
| 227 |
|
int |
| 228 |
< |
waitrays(void) /* finish up pending rays */ |
| 228 |
> |
waitrays(void) /* finish up pending rays */ |
| 229 |
|
{ |
| 230 |
|
int nwaited = 0; |
| 231 |
|
int rval; |
| 235 |
|
PNODE *p = (PNODE *)raydone.rno; |
| 236 |
|
copycolor(p->v, raydone.rcol); |
| 237 |
|
scalecolor(p->v, exposure); |
| 238 |
< |
(*dev->paintr)(greyscale?greyof(p->v):p->v, |
| 213 |
< |
p->xmin, p->ymin, p->xmax, p->ymax); |
| 238 |
> |
recolor(p); |
| 239 |
|
nwaited++; |
| 240 |
|
} |
| 241 |
|
if (rval < 0) |
| 373 |
|
} |
| 374 |
|
} |
| 375 |
|
return(p); |
| 376 |
+ |
} |
| 377 |
+ |
|
| 378 |
+ |
|
| 379 |
+ |
void |
| 380 |
+ |
compavg( /* recompute averages */ |
| 381 |
+ |
PNODE *p |
| 382 |
+ |
) |
| 383 |
+ |
{ |
| 384 |
+ |
int i, navg; |
| 385 |
+ |
|
| 386 |
+ |
if (p->kid == NULL) |
| 387 |
+ |
return; |
| 388 |
+ |
|
| 389 |
+ |
setcolor(p->v, .0, .0, .0); |
| 390 |
+ |
navg = 0; |
| 391 |
+ |
for (i = 0; i < 4; i++) { |
| 392 |
+ |
if (p->kid[i].xmin >= p->kid[i].xmax) continue; |
| 393 |
+ |
if (p->kid[i].ymin >= p->kid[i].ymax) continue; |
| 394 |
+ |
compavg(p->kid+i); |
| 395 |
+ |
addcolor(p->v, p->kid[i].v); |
| 396 |
+ |
navg++; |
| 397 |
+ |
} |
| 398 |
+ |
if (navg > 1) |
| 399 |
+ |
scalecolor(p->v, 1./navg); |
| 400 |
|
} |
| 401 |
|
|
| 402 |
|
|