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

Comparing ray/src/hd/rhd_geom.c (file contents):
Revision 3.4 by gwlarson, Wed Dec 23 17:43:20 1998 UTC vs.
Revision 3.11 by schorsch, Thu Jun 26 00:58:10 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1998 Silicon Graphics, Inc. */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ SGI";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Geometry drawing operations for OpenGL driver.
6   */
# Line 19 | Line 16 | static char SCCSid[] = "$SunId$ SGI";
16   #endif
17  
18   int     gmPortals = 0;                  /* current portal GL list id */
19 + static int      Nlists = 0;             /* number of lists allocated */
20   static char     *curportlist[MAXPORT];  /* current portal list */
21   static char     *newportlist[MAXPORT];  /* new portal file list */
22  
23   static struct gmEntry {
24          char    *gfile;                 /* geometry file name */
25          FVECT   cent;                   /* centroid */
26 <        FLOAT   rad;                    /* radius */
26 >        RREAL   rad;                    /* radius */
27          int     listid;                 /* display list identifier */
28 +        int     nlists;                 /* number of lists allocated */
29   } gmCurrent[MAXGEO], gmNext[MAXGEO];    /* current and next list */
30  
31   #define FORALLGEOM(ot,i)        for (i=0;i<MAXGEO&&ot[i].gfile!=NULL;i++)
32  
33   #define FORALLPORT(pl,i)                for (i=0;i<MAXPORT&&pl[i]!=NULL;i++)
34  
35 < extern char     *atos(), *sskip(), *sskip2();
35 > extern char     *nextword();
36  
37  
38   gmNewGeom(file)                 /* add new geometry to next list */
# Line 55 | Line 54 | char   *file;
54                          return;
55                  }
56                                          /* else load new octree */
57 <        gmNext[i].gfile = file;
57 >        gmNext[i].gfile = savestr(file);
58          dolights = 0;
59          domats = 1;
60 <        gmNext[i].listid = rgl_octlist(file, gmNext[i].cent, &gmNext[i].rad);
60 >        gmNext[i].listid = rgl_octlist(file, gmNext[i].cent, &gmNext[i].rad,
61 >                                        &gmNext[i].nlists);
62 >        gmNext[i].rad *= 1.732;         /* go to corners */
63   #ifdef DEBUG
64          fprintf(stderr, "Loaded octree \"%s\" into listID %d with radius %f\n",
65                          file, gmNext[i].listid, gmNext[i].rad);
# Line 74 | Line 75 | gmEndGeom()                    /* make next list current */
75                  FORALLGEOM(gmNext, j)
76                          if (gmNext[j].listid == gmCurrent[i].listid)
77                                  break;
78 <                if (j >= MAXGEO || gmNext[j].gfile == NULL)
79 <                        glDeleteLists(gmCurrent[i].listid, 1);  /* not found */
78 >                if (j >= MAXGEO || gmNext[j].gfile == NULL) {
79 >                        glDeleteLists(gmCurrent[i].listid,      /* not found */
80 >                                        gmCurrent[i].nlists);
81 >                        freestr(gmCurrent[i].gfile);
82 >                }
83          }
84 <        bcopy((char *)gmNext, (char *)gmCurrent, sizeof(gmNext));
85 <        bzero((char *)gmNext, sizeof(gmNext));
84 >        bcopy((void *)gmNext, (void *)gmCurrent, sizeof(gmNext));
85 >        bzero((void *)gmNext, sizeof(gmNext));
86   }
87  
88  
89   int
90 < gmDrawGeom()                    /* draw current list of octrees (and ports) */
90 > gmDrawGeom()                    /* draw current list of octrees */
91   {
92          register int    n;
93  
# Line 144 | Line 148 | char   *pflist;
148  
149          if (pflist == NULL)
150                  return;
151 <        while (*pflist) {
148 <                atos(newfile, sizeof(newfile), pflist);
149 <                if (!*newfile)
150 <                        break;
151 <                pflist = sskip(pflist);
151 >        while ((pflist = nextword(newfile, sizeof(newfile), pflist)) != NULL) {
152                  FORALLPORT(newportlist,i)
153                          if (!strcmp(newportlist[i], newfile))
154                                  goto endloop;   /* in list already */
# Line 178 | Line 178 | gmEndPortal()                  /* close portal list and return GL lis
178          FORALLPORT(newportlist, n);
179          if (!n) {                       /* free old GL list */
180                  if (gmPortals)
181 <                        glDeleteLists(gmPortals, 1);
181 >                        glDeleteLists(gmPortals, Nlists);
182                  gmPortals = 0;
183          } else
184                  qsort(newportlist, n, sizeof(char *), sstrcmp);
# Line 191 | Line 191 | gmEndPortal()                  /* close portal list and return GL lis
191                          FORALLPORT(newportlist, n);
192                          dolights = 0;
193                          domats = 0;
194 <                        gmPortals = rgl_filelist(n, newportlist);
194 >                        gmPortals = rgl_filelist(n, newportlist, &Nlists);
195                          break;
196                  }
197          FORALLPORT(curportlist, n)              /* free old file list */
198                  freestr(curportlist[n]);
199 <        bcopy((char *)newportlist, (char *)curportlist, sizeof(newportlist));
200 <        bzero((char *)newportlist, sizeof(newportlist));
199 >        bcopy((void *)newportlist, (void *)curportlist, sizeof(newportlist));
200 >        bzero((void *)newportlist, sizeof(newportlist));
201          return(gmPortals);                      /* return GL list id */
202   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines