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.3 by gregl, Thu Nov 20 18:03:43 1997 UTC vs.
Revision 3.4 by gregl, Fri Nov 21 09:52:06 1997 UTC

# Line 63 | Line 63 | int    really;
63   {
64          register int    i;
65  
66 <        if (tmTop != NULL)
67 <                tmClearHisto();
66 >        tmClearHisto();
67          bzero((char *)&qtrunk, sizeof(RTREE));
68          nexttwig = 0;
69          if (twigbundle == NULL)
# Line 85 | Line 84 | int    really;
84   static RLEAF *
85   newleaf()                       /* allocate a leaf from our pile */
86   {
87 <        if (tleaf++ >= nleaves)         /* get next leaf in ring */
87 >        RLEAF   *lp;
88 >        
89 >        lp = leafpile + tleaf++;
90 >        if (tleaf >= nleaves)           /* get next leaf in ring */
91                  tleaf = 0;
92          if (tleaf == bleaf)             /* need to shake some free */
93                  qtCompost(LFREEPCT);
94 <        return(leafpile + tleaf);
94 >        return(lp);
95   }
96  
97  
# Line 157 | Line 159 | qtCompost(pct)                 /* free up some leaves */
159   int     pct;
160   {
161          int     nused, nclear;
162 +
163 +        if (is_stump(&qtrunk))
164 +                return(0);
165                                  /* figure out how many leaves to clear */
166          nclear = nleaves * pct / 100;
167 +        nused = tleaf > bleaf ? tleaf-bleaf : tleaf+nleaves-bleaf;
168 +        nclear -= nleaves - nused;      /* less what's already free */
169          if (nclear <= 0)
170                  return(0);
164        nused = tleaf > bleaf ? tleaf-bleaf : tleaf+nleaves-bleaf;
171          if (nclear >= nused) {  /* clear them all */
172                  qtFreeTree(0);
173                  bleaf = tleaf = 0;
174                  return(nused);
175          }
176                                  /* else clear leaves from bottom */
177 <        bleaf = (bleaf + nclear) % nleaves;
177 >        bleaf += nclear;
178 >        if (bleaf >= nleaves) bleaf -= nleaves;
179          shaketree(&qtrunk);
180          return(nclear);
181   }
# Line 427 | Line 434 | int    x0, y0, x1, y1;
434  
435          if (is_stump(&qtrunk))
436                  return;
437 <        if ((lim[0][0]=x0) == 0 & (lim[1][0]=y0) == 0 &
438 <                (lim[0][1]=x1) == odev.hres & (lim[1][1]=y1) == odev.vres ||
439 <                        tmTop->lumap == NULL)
440 <                tmComputeMapping(0., 0., 0.);
437 >        if ((lim[0][0]=x0) <= 0 & (lim[1][0]=y0) <= 0 &
438 >                (lim[0][1]=x1) >= odev.hres-1 & (lim[1][1]=y1) >= odev.vres-1
439 >                        || tmTop->lumap == NULL)
440 >                if (tmComputeMapping(0., 0., 0.) != TM_E_OK)
441 >                        return;
442          redraw(ca, &qtrunk, 0, 0, odev.hres, odev.vres, lim);
443   }
444  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines