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

Comparing ray/src/hd/sm_ogl.c (file contents):
Revision 3.4 by gwlarson, Thu Sep 3 11:29:00 1998 UTC vs.
Revision 3.5 by gwlarson, Fri Sep 11 11:52:26 1998 UTC

# Line 16 | Line 16 | static char SCCSid[] = "$SunId$ SGI";
16   #include <GL/glu.h>
17   #include <glut.h>
18   #endif
19 #include "object.h"
19   #include "sm_list.h"
20   #include "sm_geom.h"
21   #include "sm.h"
# Line 41 | Line 40 | typedef struct {
40          QTRAVG          av;     /* node average */
41   } QT_LUENT;             /* lookup table entry */
42  
43 < static QT_LUENT *qt_htbl = NULL;        /* quadtree hash table */
44 < static int      qt_hsiz = 0;            /* quadtree hash table size */
43 > static QT_LUENT *qt_htbl = NULL;        /* quadtree cache */
44 > static int      qt_hsiz = 0;            /* quadtree cache size */
45  
46  
47   int
48   mark_active_tris(qtptr,arg)
49   QUADTREE *qtptr;
50 < char *arg;
50 > int *arg;
51   {
52    QUADTREE qt = *qtptr;
53 <  OBJECT os[QT_MAX_SET+1],*optr;
53 >  OBJECT *os,*optr;
54    register int i,t_id;
55  
56    if (!QT_IS_LEAF(qt))
57      return(TRUE);
58    /* For each triangle in the set, set the which flag*/
59 <  qtgetset(os,qt);
59 >  os = qtqueryset(qt);
60  
61    for (i = QT_SET_CNT(os), optr = QT_SET_PTR(os); i > 0; i--)
62    {
# Line 140 | Line 139 | smClean()
139   }
140  
141   int
142 < qtHash_init(nel)                /* initialize for at least nel elements */
142 > qtCache_init(nel)               /* initialize for at least nel elements */
143   int     nel;
144   {
145          static int  hsiztab[] = {
# Line 171 | Line 170 | int    nel;
170   }
171  
172   QT_LUENT *
173 < qtHash_find(qt)                 /* find a quadtree table entry */
173 > qtCache_find(qt)                /* find a quadtree table entry */
174   QUADTREE qt;
175   {
176          int     i, n;
177          register int    ndx;
178          register QT_LUENT       *le;
179  
180 <        if (qt_hsiz == 0)
181 <                qtHash_init(1);
180 >        if (qt_hsiz == 0 && !qtCache_init(1))
181 >                return(NULL);
182   tryagain:                               /* hash table lookup */
183          ndx = (unsigned long)qt % qt_hsiz;
184          for (i = 0, n = 1; i < qt_hsiz; i++, n += 2) {
# Line 192 | Line 191 | tryagain:                              /* hash table lookup */
191                                          /* table is full, reallocate */
192          le = qt_htbl;
193          ndx = qt_hsiz;
194 <        if (!qtHash_init(ndx+1)) {      /* no more memory! */
194 >        if (!qtCache_init(ndx+1)) {     /* no more memory! */
195                  qt_htbl = le;
196                  qt_hsiz = ndx;
197                  return(NULL);
198          }
199 <        if (!ndx)
201 <                goto tryagain;
202 <                                        /* copy old table to new */
199 >                                        /* copy old table to new and free */
200          while (ndx--)
201                  if (!QT_IS_EMPTY(le[ndx].qt))
202 <                        copystruct(qtHash_find(le[ndx].qt), &le[ndx]);
202 >                        copystruct(qtCache_find(le[ndx].qt), &le[ndx]);
203          free((char *)le);
204          goto tryagain;                  /* should happen only once! */
205   }
# Line 242 | Line 239 | int lvl;
239    if (QT_IS_TREE(qt) && !QT_IS_FLAG(qt))        /* not in our frustum */
240      return(NULL);
241                                          /* else look up node */
242 <  if ((le = qtHash_find(qt)) == NULL)
242 >  if ((le = qtCache_find(qt)) == NULL)
243      error(SYSTEM, "out of memory in qtRender_level");
244    if (QT_IS_TREE(qt) && (QT_IS_EMPTY(le->qt) || lvl > 0))
245    {                                     /* compute children */
# Line 271 | Line 268 | int lvl;
268      }
269      else
270      {                                   /* from triangle set */
271 <      OBJECT os[QT_MAX_SET+1];
271 >      OBJECT *os;
272        int s0, s1, s2;
273  
274 <      qtgetset(os,qt);
274 >      os = qtqueryset(qt);
275        for (n = os[0]; n; n--)
276        {
277          qtTri_from_id(os[n],a,b,c,NULL,NULL,NULL,&s0,&s1,&s2);
# Line 752 | Line 749 | smUpdate(view,qual)
749    {
750      smClean_notify = FALSE;
751      smNew_tri_cnt = 0;
752 <    qtHash_init(0);
752 >    qtCache_init(0);
753    }
754  
755   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines