--- ray/src/hd/rhd_qtree.c 1997/11/24 15:16:10 3.6 +++ ray/src/hd/rhd_qtree.c 1997/11/25 14:24:39 3.8 @@ -62,12 +62,13 @@ int really; { register int i; - qtrunk.flgs = CH_ANY; - nexttwig = 0; + qtrunk.flgs = CH_ANY; /* chop down tree */ if (twigbundle == NULL) return; + i = (TBUNDLESIZ-1+nexttwig)/TBUNDLESIZ; + nexttwig = 0; if (!really) { /* just clear allocated blocks */ - for (i = 0; twigbundle[i] != NULL; i++) + while (i--) bzero((char *)twigbundle[i], TBUNDLESIZ*sizeof(RTREE)); return; } @@ -364,15 +365,11 @@ int redo; static -redraw(ca, tp, x0, y0, x1, y1, l) /* redraw portion of a tree */ -BYTE ca[3]; /* returned average color */ +redraw(tp, x0, y0, x1, y1, l) /* mark portion of a tree for redraw */ register RTREE *tp; int x0, y0, x1, y1; int l[2][2]; { - int csm[3], nc; - register BYTE *cp; - BYTE rgb[3]; int quads = CH_ANY; int mx, my; register int i; @@ -382,44 +379,18 @@ int l[2][2]; /* see what to do */ if (l[0][0] >= mx) quads &= ~(CHF(2)|CHF(0)); - else if (l[0][1] <= mx) + else if (l[0][1] < mx) quads &= ~(CHF(3)|CHF(1)); if (l[1][0] >= my) quads &= ~(CHF(1)|CHF(0)); - else if (l[1][1] <= my) + else if (l[1][1] < my) quads &= ~(CHF(3)|CHF(2)); - tp->flgs &= ~quads; /* mark them done */ - csm[0] = csm[1] = csm[2] = nc = 0; - /* do leaves first */ + tp->flgs |= quads; /* mark quadrants for update */ + /* climb the branches */ for (i = 0; i < 4; i++) - if (quads & CHF(i) && tp->flgs & LFF(i)) { - dev_paintr(cp=qtL.rgb[tp->k[i].li], - i&01 ? mx : x0, i&02 ? my : y0, - i&01 ? x1 : mx, i&02 ? y1 : my); - csm[0] += cp[0]; csm[1] += cp[1]; csm[2] += cp[2]; - nc++; - quads &= ~CHF(i); - } - /* now do branches */ - for (i = 0; i < 4; i++) - if (quads & CHF(i) && tp->flgs & BRF(i)) { - redraw(rgb, tp->k[i].b, i&01 ? mx : x0, i&02 ? my : y0, + if (tp->flgs & BRF(i) && quads & CHF(i)) + redraw(tp->k[i].b, i&01 ? mx : x0, i&02 ? my : y0, i&01 ? x1 : mx, i&02 ? y1 : my, l); - csm[0] += rgb[0]; csm[1] += rgb[1]; csm[2] += rgb[2]; - nc++; - quads &= ~CHF(i); - } - if (nc > 1) { - ca[0] = csm[0]/nc; ca[1] = csm[1]/nc; ca[2] = csm[2]/nc; - } else { - ca[0] = csm[0]; ca[1] = csm[1]; ca[2] = csm[2]; - } - if (!quads) return; - /* fill in gaps with average */ - for (i = 0; i < 4; i++) - if (quads & CHF(i)) - dev_paintr(ca, i&01 ? mx : x0, i&02 ? my : y0, - i&01 ? x1 : mx, i&02 ? y1 : my); } @@ -441,15 +412,14 @@ int x0, y0, x1, y1; csm[0] = csm[1] = csm[2] = nc = 0; /* do leaves first */ for (i = 0; i < 4; i++) { - if (!(tp->flgs & CHF(i))) - continue; if (tp->flgs & LFF(i)) { - dev_paintr(cp=qtL.rgb[tp->k[i].li], - i&01 ? mx : x0, i&02 ? my : y0, - i&01 ? x1 : mx, i&02 ? y1 : my); + cp = qtL.rgb[tp->k[i].li]; csm[0] += cp[0]; csm[1] += cp[1]; csm[2] += cp[2]; nc++; - } else if (!(tp->flgs & BRF(i))) + if (tp->flgs & CHF(i)) + dev_paintr(cp, i&01 ? mx : x0, i&02 ? my : y0, + i&01 ? x1 : mx, i&02 ? y1 : my); + } else if ((tp->flgs & CHBRF(i)) == CHF(i)) gaps |= 1<= odev.hres-1 & (lim[1][1]=y1) >= odev.vres-1)) return; - redraw(ca, &qtrunk, 0, 0, odev.hres, odev.vres, lim); + redraw(&qtrunk, 0, 0, odev.hres, odev.vres, lim); }