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.6 by schorsch, Thu Jan 1 11:21:55 2004 UTC

# Line 1 | Line 1
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   */
# Line 12 | Line 9 | static char SCCSid[] = "$SunId$ SGI";
9   #include "rhd_qtree.h"
10  
11  
12 < static
13 < redraw(tp, x0, y0, x1, y1, l)   /* mark portion of a tree for redraw */
14 < register RTREE  *tp;
15 < int     x0, y0, x1, y1;
16 < int     l[2][2];
12 > static void redraw(RTREE *tp, int x0, int y0, int x1, int y1, int l[2][2]);
13 > static void update( BYTE ca[3], RTREE *tp, int x0, int y0, int x1, int y1);
14 >
15 >
16 > static void
17 > redraw( /* mark portion of a tree for redraw */
18 >        register RTREE  *tp,
19 >        int     x0,
20 >        int     y0,
21 >        int     x1,
22 >        int     y1,
23 >        int     l[2][2]
24 > )
25   {
26          int     quads = CH_ANY;
27          int     mx, my;
# Line 25 | Line 30 | int    l[2][2];
30          mx = (x0 + x1) >> 1;
31          my = (y0 + y1) >> 1;
32                                          /* see what to do */
33 <        if (l[0][0] >= mx)
34 <                quads &= ~(CHF(2)|CHF(0));
33 >        if (l[0][0] > mx)
34 >                quads &= ~(CHF(UL)|CHF(DL));
35          else if (l[0][1] < mx)
36 <                quads &= ~(CHF(3)|CHF(1));
37 <        if (l[1][0] >= my)
38 <                quads &= ~(CHF(1)|CHF(0));
36 >                quads &= ~(CHF(UR)|CHF(DR));
37 >        if (l[1][0] > my)
38 >                quads &= ~(CHF(DR)|CHF(DL));
39          else if (l[1][1] < my)
40 <                quads &= ~(CHF(3)|CHF(2));
40 >                quads &= ~(CHF(UR)|CHF(UL));
41          tp->flgs |= quads;              /* mark quadrants for update */
42                                          /* climb the branches */
43          for (i = 0; i < 4; i++)
# Line 42 | Line 47 | int    l[2][2];
47   }
48  
49  
50 < static
51 < update(ca, tp, x0, y0, x1, y1)  /* update tree display as needed */
52 < BYTE    ca[3];          /* returned average color */
53 < register RTREE  *tp;
54 < int     x0, y0, x1, y1;
50 > static void
51 > update( /* update tree display as needed */
52 >        BYTE    ca[3],          /* returned average color */
53 >        register RTREE  *tp,
54 >        int     x0,
55 >        int     y0,
56 >        int     x1,
57 >        int     y1
58 > )
59   {
60          int     csm[3], nc;
61          register BYTE   *cp;
62          BYTE    rgb[3];
63 +        double  dpth2[4], d2;
64          int     gaps = 0;
65          int     mx, my;
66          register int    i;
67 +                                        /* compute leaf depths */
68 +        d2 = FHUGE*FHUGE;
69 +        for (i = 0; i < 4; i++)
70 +                if (tp->flgs & LFF(i)) {
71 +                        FVECT   dv;
72 +                        register float  *wp = qtL.wp[tp->k[i].li];
73 +
74 +                        dv[0] = wp[0] - odev.v.vp[0];
75 +                        dv[1] = wp[1] - odev.v.vp[1];
76 +                        dv[2] = wp[2] - odev.v.vp[2];
77 +                        dpth2[i] = DOT(dv,dv);
78 +                        if (dpth2[i] < d2)
79 +                                d2 = dpth2[i];
80 +                }
81 +        d2 *= (1.+qtDepthEps)*(1.+qtDepthEps);
82                                          /* compute midpoint */
83          mx = (x0 + x1) >> 1;
84          my = (y0 + y1) >> 1;
85 +                                        /* draw leaves */
86          csm[0] = csm[1] = csm[2] = nc = 0;
61                                        /* do leaves first */
87          for (i = 0; i < 4; i++) {
88 <                if (tp->flgs & LFF(i)) {
88 >                if (tp->flgs & LFF(i) && dpth2[i] <= d2) {
89                          cp = qtL.rgb[tp->k[i].li];
90                          csm[0] += cp[0]; csm[1] += cp[1]; csm[2] += cp[2];
91                          nc++;
# Line 70 | Line 95 | int    x0, y0, x1, y1;
95                  } else if ((tp->flgs & CHBRF(i)) == CHF(i))
96                          gaps |= 1<<i;   /* empty stem */
97          }
98 <                                        /* now do branches */
98 >                                        /* do branches */
99          for (i = 0; i < 4; i++)
100                  if ((tp->flgs & CHBRF(i)) == CHBRF(i)) {
101                          update(rgb, tp->k[i].b, i&01 ? mx : x0, i&02 ? my : y0,
# Line 92 | Line 117 | int    x0, y0, x1, y1;
117   }
118  
119  
120 < qtRedraw(x0, y0, x1, y1)        /* redraw part or all of our screen */
121 < int     x0, y0, x1, y1;
120 > extern void
121 > qtRedraw(       /* redraw part or all of our screen */
122 >        int     x0,
123 >        int     y0,
124 >        int     x1,
125 >        int     y1
126 > )
127   {
128          int     lim[2][2];
129  
130          if (is_stump(&qtrunk))
131                  return;
132 <        if (!qtMapLeaves((lim[0][0]=x0) <= 0 & (lim[1][0]=y0) <= 0 &
133 <                (lim[0][1]=x1) >= odev.hres-1 & (lim[1][1]=y1) >= odev.vres-1))
132 >        if (!qtMapLeaves(((lim[0][0]=x0) <= 0) & ((lim[1][0]=y0) <= 0) &
133 >                ((lim[0][1]=x1) >= odev.hres-1) & ((lim[1][1]=y1) >= odev.vres-1)))
134                  return;
135          redraw(&qtrunk, 0, 0, odev.hres, odev.vres, lim);
136   }
137  
138  
139 < qtUpdate()                      /* update our tree display */
139 > extern void
140 > qtUpdate(void)                  /* update our tree display */
141   {
142          BYTE    ca[3];
143  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines