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.1 by gregl, Wed Nov 19 18:01:03 1997 UTC vs.
Revision 3.2 by gregl, Thu Nov 20 11:38:26 1997 UTC

# Line 11 | Line 11 | static char SCCSid[] = "$SunId$ SGI";
11   #include "standard.h"
12   #include "rhd_qtree.h"
13  
14 static RLEAF    *leafpile;      /* our collection of leaf values */
15 static int      nleaves;        /* count of leaves in our pile */
16 static int      bleaf, tleaf;   /* bottom and top (next) leaf index (ring) */
17
14   RTREE   qtrunk;                 /* our quadtree trunk */
15   double  qtDepthEps = .02;       /* epsilon to compare depths (z fraction) */
16   int     qtMinNodesiz = 2;       /* minimum node dimension (pixels) */
17  
18 + static RLEAF    *leafpile;      /* our collection of leaf values */
19 + static int      nleaves;        /* count of leaves in our pile */
20 + static int      bleaf, tleaf;   /* bottom and top (next) leaf index (ring) */
21 +
22   #define TBUNDLESIZ      409     /* number of twigs in a bundle */
23  
24   static RTREE    **twigbundle;   /* free twig blocks (NULL term.) */
# Line 59 | Line 59 | memerr:
59  
60  
61   static
62 < freetwigs(really)               /* free allocated twigs */
62 > freetree(really)                /* free allocated twigs */
63   int     really;
64   {
65          register int    i;
# Line 101 | Line 101 | int    n;
101          unsigned        nbytes;
102          register unsigned       i;
103  
104 <        freetwigs(0);           /* make sure tree is empty */
104 >        freetree(0);            /* make sure tree is empty */
105          if (n <= 0)
106                  return(0);
107          if (nleaves >= n)
# Line 124 | Line 124 | int    n;
124  
125   qtFreeLeaves()                  /* free our allocated leaves and twigs */
126   {
127 <        freetwigs(1);           /* free tree also */
127 >        freetree(1);            /* free tree also */
128          if (nleaves <= 0)
129                  return;
130          free((char *)leafpile);
# Line 140 | Line 140 | register RTREE *tp;
140          register int    i, li;
141  
142          for (i = 0; i < 4; i++)
143 <                if (tp->flgs & BRF(i)) {
144 <                        if (shaketree(tp->k[i].b))
145 <                                tp->flgs |= CHF(i);
146 <                } else if (tp->k[i].l != NULL) {
143 >                if (tp->flgs & BRF(i))
144 >                        shaketree(tp->k[i].b);
145 >                else if (tp->k[i].l != NULL) {
146                          li = tp->k[i].l - leafpile;
147                          if (bleaf < tleaf ? (li < bleaf || li >= tleaf) :
148                                          (li < bleaf && li >= tleaf)) {
149                                  tmAddHisto(&tp->k[i].l->brt, 1, -1);
150                                  tp->k[i].l = NULL;
152                                tp->flgs |= CHF(i);
151                          }
152                  }
155        return(tp->flgs & CH_ANY);
153   }
154  
155  
# Line 167 | Line 164 | int    pct;
164                  return(0);
165          nused = tleaf > bleaf ? tleaf-bleaf : tleaf+nleaves-bleaf;
166          if (nclear >= nused) {  /* clear them all */
167 <                freetwigs(0);
167 >                freetree(0);
168                  bleaf = tleaf = 0;
169                  return(nused);
170          }
# Line 265 | Line 262 | qtReplant()                    /* replant our tree using new view */
262  
263          if (bleaf == tleaf)             /* anything to replant? */
264                  return;
265 <        freetwigs(0);                   /* blow the tree away */
265 >        freetree(0);                    /* blow the tree away */
266                                          /* now rebuild it */
267          for (i = bleaf; i != tleaf; ) {
268                  addleaf(leafpile+i);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines