1 |
– |
/* Copyright (c) 1997 Silicon Graphics, Inc. */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ SGI"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Quadtree display support routines for rectangle output. |
6 |
|
*/ |
22 |
|
mx = (x0 + x1) >> 1; |
23 |
|
my = (y0 + y1) >> 1; |
24 |
|
/* see what to do */ |
25 |
< |
if (l[0][0] >= mx) |
26 |
< |
quads &= ~(CHF(2)|CHF(0)); |
25 |
> |
if (l[0][0] > mx) |
26 |
> |
quads &= ~(CHF(UL)|CHF(DL)); |
27 |
|
else if (l[0][1] < mx) |
28 |
< |
quads &= ~(CHF(3)|CHF(1)); |
29 |
< |
if (l[1][0] >= my) |
30 |
< |
quads &= ~(CHF(1)|CHF(0)); |
28 |
> |
quads &= ~(CHF(UR)|CHF(DR)); |
29 |
> |
if (l[1][0] > my) |
30 |
> |
quads &= ~(CHF(DR)|CHF(DL)); |
31 |
|
else if (l[1][1] < my) |
32 |
< |
quads &= ~(CHF(3)|CHF(2)); |
32 |
> |
quads &= ~(CHF(UR)|CHF(UL)); |
33 |
|
tp->flgs |= quads; /* mark quadrants for update */ |
34 |
|
/* climb the branches */ |
35 |
|
for (i = 0; i < 4; i++) |
48 |
|
int csm[3], nc; |
49 |
|
register BYTE *cp; |
50 |
|
BYTE rgb[3]; |
51 |
+ |
double dpth2[4], d2; |
52 |
|
int gaps = 0; |
53 |
|
int mx, my; |
54 |
|
register int i; |
55 |
+ |
/* compute leaf depths */ |
56 |
+ |
d2 = FHUGE*FHUGE; |
57 |
+ |
for (i = 0; i < 4; i++) |
58 |
+ |
if (tp->flgs & LFF(i)) { |
59 |
+ |
FVECT dv; |
60 |
+ |
register float *wp = qtL.wp[tp->k[i].li]; |
61 |
+ |
|
62 |
+ |
dv[0] = wp[0] - odev.v.vp[0]; |
63 |
+ |
dv[1] = wp[1] - odev.v.vp[1]; |
64 |
+ |
dv[2] = wp[2] - odev.v.vp[2]; |
65 |
+ |
dpth2[i] = DOT(dv,dv); |
66 |
+ |
if (dpth2[i] < d2) |
67 |
+ |
d2 = dpth2[i]; |
68 |
+ |
} |
69 |
+ |
d2 *= (1.+qtDepthEps)*(1.+qtDepthEps); |
70 |
|
/* compute midpoint */ |
71 |
|
mx = (x0 + x1) >> 1; |
72 |
|
my = (y0 + y1) >> 1; |
73 |
+ |
/* draw leaves */ |
74 |
|
csm[0] = csm[1] = csm[2] = nc = 0; |
61 |
– |
/* do leaves first */ |
75 |
|
for (i = 0; i < 4; i++) { |
76 |
< |
if (tp->flgs & LFF(i)) { |
76 |
> |
if (tp->flgs & LFF(i) && dpth2[i] <= d2) { |
77 |
|
cp = qtL.rgb[tp->k[i].li]; |
78 |
|
csm[0] += cp[0]; csm[1] += cp[1]; csm[2] += cp[2]; |
79 |
|
nc++; |
83 |
|
} else if ((tp->flgs & CHBRF(i)) == CHF(i)) |
84 |
|
gaps |= 1<<i; /* empty stem */ |
85 |
|
} |
86 |
< |
/* now do branches */ |
86 |
> |
/* do branches */ |
87 |
|
for (i = 0; i < 4; i++) |
88 |
|
if ((tp->flgs & CHBRF(i)) == CHBRF(i)) { |
89 |
|
update(rgb, tp->k[i].b, i&01 ? mx : x0, i&02 ? my : y0, |
112 |
|
|
113 |
|
if (is_stump(&qtrunk)) |
114 |
|
return; |
115 |
< |
if (!qtMapLeaves((lim[0][0]=x0) <= 0 & (lim[1][0]=y0) <= 0 & |
116 |
< |
(lim[0][1]=x1) >= odev.hres-1 & (lim[1][1]=y1) >= odev.vres-1)) |
115 |
> |
if (!qtMapLeaves(((lim[0][0]=x0) <= 0) & ((lim[1][0]=y0) <= 0) & |
116 |
> |
((lim[0][1]=x1) >= odev.hres-1) & ((lim[1][1]=y1) >= odev.vres-1))) |
117 |
|
return; |
118 |
|
redraw(&qtrunk, 0, 0, odev.hres, odev.vres, lim); |
119 |
|
} |