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

Comparing ray/src/hd/rhd_qtree.c (file contents):
Revision 3.5 by gregl, Fri Nov 21 13:35:57 1997 UTC vs.
Revision 3.7 by gregl, Tue Nov 25 11:15:20 1997 UTC

# Line 10 | Line 10 | static char SCCSid[] = "$SunId$ SGI";
10  
11   #include "standard.h"
12   #include "rhd_qtree.h"
13 +                                /* quantity of leaves to free at a time */
14 + #ifndef LFREEPCT
15 + #define LFREEPCT        25
16 + #endif
17  
18   RTREE   qtrunk;                 /* our quadtree trunk */
19   double  qtDepthEps = .02;       /* epsilon to compare depths (z fraction) */
# Line 58 | Line 62 | int    really;
62   {
63          register int    i;
64  
65 <        qtrunk.flgs = 0;
62 <        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          }
# Line 323 | Line 328 | qtMapLeaves(redo)              /* map our leaves to RGB */
328   int     redo;
329   {
330          int     aorg, alen, borg, blen;
331 +                                        /* recompute mapping? */
332 +        if (redo)
333 +                qtL.tml = qtL.bl;
334                                          /* already done? */
335          if (qtL.tml == qtL.tl)
336                  return(1);
329        if (redo)
330                qtL.tml = qtL.bl;
337                                          /* compute segments */
338          aorg = qtL.tml;
339          if (qtL.tl >= aorg) {
# Line 359 | Line 365 | int    redo;
365  
366  
367   static
368 < redraw(ca, tp, x0, y0, x1, y1, l)       /* redraw portion of a tree */
363 < 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   {
368        int     csm[3], nc;
369        register BYTE   *cp;
370        BYTE    rgb[3];
373          int     quads = CH_ANY;
374          int     mx, my;
375          register int    i;
# Line 377 | Line 379 | int    l[2][2];
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;
388 <                                        /* 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],
392 <                                        i&01 ? mx : x0, i&02 ? my : y0,
393 <                                        i&01 ? x1 : mx, i&02 ? y1 : my);
394 <                        csm[0] += cp[0]; csm[1] += cp[1]; csm[2] += cp[2];
395 <                        nc++;
396 <                        quads &= ~CHF(i);
397 <                }
398 <                                        /* now do branches */
399 <        for (i = 0; i < 4; i++)
400 <                if (quads & CHF(i) && tp->flgs & BRF(i)) {
401 <                        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);
403                        csm[0] += rgb[0]; csm[1] += rgb[1]; csm[2] += rgb[2];
404                        nc++;
405                        quads &= ~CHF(i);
406                }
407        if (nc > 1) {
408                ca[0] = csm[0]/nc; ca[1] = csm[1]/nc; ca[2] = csm[2]/nc;
409        } else {
410                ca[0] = csm[0]; ca[1] = csm[1]; ca[2] = csm[2];
411        }
412        if (!quads) return;
413                                        /* fill in gaps with average */
414        for (i = 0; i < 4; i++)
415                if (quads & CHF(i))
416                        dev_paintr(ca, i&01 ? mx : x0, i&02 ? my : y0,
417                                        i&01 ? x1 : mx, i&02 ? y1 : my);
394   }
395  
396  
# Line 473 | Line 449 | qtRedraw(x0, y0, x1, y1)       /* redraw part or all of our
449   int     x0, y0, x1, y1;
450   {
451          int     lim[2][2];
476        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  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines