| 62 |
|
{ |
| 63 |
|
register int i; |
| 64 |
|
|
| 65 |
< |
qtrunk.flgs = CH_ANY; |
| 66 |
< |
nexttwig = 0; |
| 65 |
> |
qtrunk.flgs = CH_ANY; /* chop down tree */ |
| 66 |
|
if (twigbundle == NULL) |
| 67 |
|
return; |
| 68 |
+ |
i = (TBUNDLESIZ-1+nexttwig)/TBUNDLESIZ; |
| 69 |
+ |
nexttwig = 0; |
| 70 |
|
if (!really) { /* just clear allocated blocks */ |
| 71 |
< |
for (i = 0; twigbundle[i] != NULL; i++) |
| 71 |
> |
while (i--) |
| 72 |
|
bzero((char *)twigbundle[i], TBUNDLESIZ*sizeof(RTREE)); |
| 73 |
|
return; |
| 74 |
|
} |
| 365 |
|
|
| 366 |
|
|
| 367 |
|
static |
| 368 |
< |
redraw(ca, tp, x0, y0, x1, y1, l) /* redraw portion of a tree */ |
| 368 |
< |
BYTE ca[3]; /* returned average color */ |
| 368 |
> |
redraw(tp, x0, y0, x1, y1, l) /* mark portion of a tree for redraw */ |
| 369 |
|
register RTREE *tp; |
| 370 |
|
int x0, y0, x1, y1; |
| 371 |
|
int l[2][2]; |
| 372 |
|
{ |
| 373 |
– |
int csm[3], nc; |
| 374 |
– |
register BYTE *cp; |
| 375 |
– |
BYTE rgb[3]; |
| 373 |
|
int quads = CH_ANY; |
| 374 |
|
int mx, my; |
| 375 |
|
register int i; |
| 379 |
|
/* see what to do */ |
| 380 |
|
if (l[0][0] >= mx) |
| 381 |
|
quads &= ~(CHF(2)|CHF(0)); |
| 382 |
< |
else if (l[0][1] <= mx) |
| 382 |
> |
else if (l[0][1] < mx) |
| 383 |
|
quads &= ~(CHF(3)|CHF(1)); |
| 384 |
|
if (l[1][0] >= my) |
| 385 |
|
quads &= ~(CHF(1)|CHF(0)); |
| 386 |
< |
else if (l[1][1] <= my) |
| 386 |
> |
else if (l[1][1] < my) |
| 387 |
|
quads &= ~(CHF(3)|CHF(2)); |
| 388 |
< |
tp->flgs &= ~quads; /* mark them done */ |
| 389 |
< |
csm[0] = csm[1] = csm[2] = nc = 0; |
| 393 |
< |
/* do leaves first */ |
| 388 |
> |
tp->flgs |= quads; /* mark quadrants for update */ |
| 389 |
> |
/* climb the branches */ |
| 390 |
|
for (i = 0; i < 4; i++) |
| 391 |
< |
if (quads & CHF(i) && tp->flgs & LFF(i)) { |
| 392 |
< |
dev_paintr(cp=qtL.rgb[tp->k[i].li], |
| 397 |
< |
i&01 ? mx : x0, i&02 ? my : y0, |
| 398 |
< |
i&01 ? x1 : mx, i&02 ? y1 : my); |
| 399 |
< |
csm[0] += cp[0]; csm[1] += cp[1]; csm[2] += cp[2]; |
| 400 |
< |
nc++; |
| 401 |
< |
quads &= ~CHF(i); |
| 402 |
< |
} |
| 403 |
< |
/* now do branches */ |
| 404 |
< |
for (i = 0; i < 4; i++) |
| 405 |
< |
if (quads & CHF(i) && tp->flgs & BRF(i)) { |
| 406 |
< |
redraw(rgb, tp->k[i].b, i&01 ? mx : x0, i&02 ? my : y0, |
| 391 |
> |
if (tp->flgs & BRF(i) && quads & CHF(i)) |
| 392 |
> |
redraw(tp->k[i].b, i&01 ? mx : x0, i&02 ? my : y0, |
| 393 |
|
i&01 ? x1 : mx, i&02 ? y1 : my, l); |
| 408 |
– |
csm[0] += rgb[0]; csm[1] += rgb[1]; csm[2] += rgb[2]; |
| 409 |
– |
nc++; |
| 410 |
– |
quads &= ~CHF(i); |
| 411 |
– |
} |
| 412 |
– |
if (nc > 1) { |
| 413 |
– |
ca[0] = csm[0]/nc; ca[1] = csm[1]/nc; ca[2] = csm[2]/nc; |
| 414 |
– |
} else { |
| 415 |
– |
ca[0] = csm[0]; ca[1] = csm[1]; ca[2] = csm[2]; |
| 416 |
– |
} |
| 417 |
– |
if (!quads) return; |
| 418 |
– |
/* fill in gaps with average */ |
| 419 |
– |
for (i = 0; i < 4; i++) |
| 420 |
– |
if (quads & CHF(i)) |
| 421 |
– |
dev_paintr(ca, i&01 ? mx : x0, i&02 ? my : y0, |
| 422 |
– |
i&01 ? x1 : mx, i&02 ? y1 : my); |
| 394 |
|
} |
| 395 |
|
|
| 396 |
|
|
| 449 |
|
int x0, y0, x1, y1; |
| 450 |
|
{ |
| 451 |
|
int lim[2][2]; |
| 481 |
– |
BYTE ca[3]; |
| 452 |
|
|
| 453 |
|
if (is_stump(&qtrunk)) |
| 454 |
|
return; |
| 455 |
|
if (!qtMapLeaves((lim[0][0]=x0) <= 0 & (lim[1][0]=y0) <= 0 & |
| 456 |
|
(lim[0][1]=x1) >= odev.hres-1 & (lim[1][1]=y1) >= odev.vres-1)) |
| 457 |
|
return; |
| 458 |
< |
redraw(ca, &qtrunk, 0, 0, odev.hres, odev.vres, lim); |
| 458 |
> |
redraw(&qtrunk, 0, 0, odev.hres, odev.vres, lim); |
| 459 |
|
} |
| 460 |
|
|
| 461 |
|
|