ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rhd_qtree2r.c
(Generate patch)

Comparing ray/src/hd/rhd_qtree2r.c (file contents):
Revision 3.1 by gregl, Tue Nov 25 16:51:41 1997 UTC vs.
Revision 3.2 by gregl, Tue Nov 25 17:33:02 1997 UTC

# Line 25 | Line 25 | int    l[2][2];
25          mx = (x0 + x1) >> 1;
26          my = (y0 + y1) >> 1;
27                                          /* see what to do */
28 <        if (l[0][0] >= mx)
28 >        if (l[0][0] > mx)
29                  quads &= ~(CHF(2)|CHF(0));
30          else if (l[0][1] < mx)
31                  quads &= ~(CHF(3)|CHF(1));
32 <        if (l[1][0] >= my)
32 >        if (l[1][0] > my)
33                  quads &= ~(CHF(1)|CHF(0));
34          else if (l[1][1] < my)
35                  quads &= ~(CHF(3)|CHF(2));
# Line 51 | Line 51 | int    x0, y0, x1, y1;
51          int     csm[3], nc;
52          register BYTE   *cp;
53          BYTE    rgb[3];
54 +        double  dpth2[4], d2;
55          int     gaps = 0;
56          int     mx, my;
57          register int    i;
58 +                                        /* compute leaf depths */
59 +        d2 = FHUGE*FHUGE;
60 +        for (i = 0; i < 4; i++)
61 +                if (tp->flgs & LFF(i)) {
62 +                        FVECT   dv;
63 +                        register float  *wp = qtL.wp[tp->k[i].li];
64 +
65 +                        dv[0] = wp[0] - odev.v.vp[0];
66 +                        dv[1] = wp[1] - odev.v.vp[1];
67 +                        dv[2] = wp[2] - odev.v.vp[2];
68 +                        dpth2[i] = DOT(dv,dv);
69 +                        if (dpth2[i] < d2)
70 +                                d2 = dpth2[i];
71 +                }
72 +        d2 *= (1.+qtDepthEps)*(1.+qtDepthEps);
73                                          /* compute midpoint */
74          mx = (x0 + x1) >> 1;
75          my = (y0 + y1) >> 1;
76 +                                        /* draw leaves */
77          csm[0] = csm[1] = csm[2] = nc = 0;
61                                        /* do leaves first */
78          for (i = 0; i < 4; i++) {
79 <                if (tp->flgs & LFF(i)) {
79 >                if (tp->flgs & LFF(i) && dpth2[i] <= d2) {
80                          cp = qtL.rgb[tp->k[i].li];
81                          csm[0] += cp[0]; csm[1] += cp[1]; csm[2] += cp[2];
82                          nc++;
# Line 70 | Line 86 | int    x0, y0, x1, y1;
86                  } else if ((tp->flgs & CHBRF(i)) == CHF(i))
87                          gaps |= 1<<i;   /* empty stem */
88          }
89 <                                        /* now do branches */
89 >                                        /* do branches */
90          for (i = 0; i < 4; i++)
91                  if ((tp->flgs & CHBRF(i)) == CHBRF(i)) {
92                          update(rgb, tp->k[i].b, i&01 ? mx : x0, i&02 ? my : y0,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines