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

Comparing ray/src/common/rglinst.c (file contents):
Revision 3.7 by greg, Wed Apr 23 02:28:06 2003 UTC vs.
Revision 3.18 by greg, Sat Jun 7 05:09:45 2025 UTC

# Line 7 | Line 7 | static const char      RCSid[] = "$Id$";
7  
8   #include "copyright.h"
9  
10 + #include <stdio.h>
11 + #include <string.h>
12 + #include <time.h>
13 +
14 + #include "platform.h"
15 + #include "resolu.h"
16   #include "radogl.h"
17   #include "octree.h"
18  
# Line 19 | Line 25 | typedef struct {
25          char    octfile[256];                   /* octree file path */
26   } OCTINST;                              /* octree to instantiate */
27  
28 < static double  ogetflt();
29 < static long  ogetint();
30 < static char  *ogetstr();
31 < static int  loadobj();
32 < static void  skiptree();
33 < static void  octerror();
34 < static OCTINST  *getoct();
28 > static double  ogetflt(void);
29 > static long  ogetint(int);
30 > static char  *ogetstr(char *);
31 > static int  loadobj(void);
32 > static void  skiptree(void);
33 > static void  octerror(int etyp, char *msg);
34 > static OCTINST  *getoct(char *);
35  
36   static char  *infn;                     /* input file name */
37   static FILE  *infp;                     /* input file stream */
38   static int  objsize;                    /* size of stored OBJECT's */
39   static short  otypmap[NUMOTYPE+8];      /* object type map */
40  
41 < static unsigned long    imhash(mod) char *mod; {return((unsigned long)mod);}
41 > static unsigned long    imhash(const char *mod) {return((unsigned long)mod);}
42   static LUTAB    imtab = {imhash,NULL,NULL,NULL,0,NULL,0};
43  
44   static LUTAB    ottab = LU_SINIT(free,free);
# Line 54 | Line 60 | register OBJREC        *o;
60                                  o->oargs.nsargs-1)
61                          objerror(o, USER, "bad transform");
62                  glPushAttrib(GL_TRANSFORM_BIT);
63 <                if (xfs.sca < 1.-FTINY | xfs.sca > 1.+FTINY)
63 >                if ((xfs.sca < 1.-FTINY) | (xfs.sca > 1.+FTINY))
64                          glEnable(GL_NORMALIZE);
65                  glMatrixMode(GL_MODELVIEW);
66                  glPushMatrix();
# Line 82 | Line 88 | register OBJREC        *o;
88  
89  
90   static int
91 < buildoctlist(lp)                        /* build octree list */
92 < LUENT   *lp;
91 > buildoctlist(lp, p)                     /* build octree list */
92 > const LUENT     *lp;
93 > void    *p;
94   {
95          int     old_dolights = dolights, old_domats = domats;
96          register OCTINST        *op = (OCTINST *)lp->data;
# Line 110 | Line 117 | loadoctrees()                          /* load octrees we've saved up */
117          while (ottab.tsiz) {
118                  if (!levelsleft--)
119                          error(USER, "too many octree levels -- instance loop?");
120 <                copystruct(&looptab, &ottab);
120 >                looptab = ottab;
121                  ottab.tsiz = 0;
122 <                nocts += lu_doall(&looptab, buildoctlist);
122 >                nocts += lu_doall(&looptab, buildoctlist, NULL);
123                  lu_done(&looptab);
124          }
125          return(nocts);
# Line 123 | Line 130 | static OCTINST *
130   getoct(name)                            /* get/assign octree list id */
131   char    *name;
132   {
126        extern char     *getpath(), *getlibpath();
133          char    *path;
134          register LUENT  *lp;
135          register OCTINST        *op;
# Line 137 | Line 143 | char   *name;
143                  strcpy(lp->key, name);
144          }
145          if ((op = (OCTINST *)lp->data) == NULL) {
146 <                path = getpath(name, getlibpath(), R_OK);
146 >                path = getpath(name, getrlibpath(), R_OK);
147                  if (path == NULL) {
148                          sprintf(errmsg, "cannot find octree \"%s\"", name);
149 <                        error(USER, errmsg);
149 >                        error(SYSTEM, errmsg);
150                  }
151                  op = (OCTINST *)(lp->data = (char *)malloc(sizeof(OCTINST)));
152                  strcpy(op->octfile, path);
# Line 151 | Line 157 | char   *name;
157          return(op);
158   memerr:
159          error(SYSTEM, "out of memory in getoct");
160 +        return NULL; /* pro forma return */
161   }
162  
163  
# Line 169 | Line 176 | FVECT  cent;
176                  sprintf(errmsg, "cannot open octree file \"%s\"", fname);
177                  error(SYSTEM, errmsg);
178          }
179 < #ifdef MSDOS
173 <        setmode(fileno(infp), O_BINARY);
174 < #endif
179 >        SET_FILE_BINARY(infp);
180                                          /* get header */
181          if (checkheader(infp, OCTFMT, NULL) < 0)
182                  octerror(USER, "not an octree");
183                                          /* check format */
184          if ((objsize = ogetint(2)-OCTMAGIC) <= 0 ||
185                          objsize > MAXOBJSIZ || objsize > sizeof(long))
186 <                octerror("incompatible octree format");
186 >                octerror(USER, "incompatible octree format");
187          if (cent != NULL) {             /* get boundaries (compute center) */
188                  for (i = 0; i < 3; i++)
189                          cent[i] = atof(ogetstr(sbuf));
# Line 208 | Line 213 | char  *fname;
213          
214          infn = fname;
215          infp = fopen(fname, "r");       /* assume already checked */
216 < #ifdef MSDOS
212 <        setmode(fileno(infp), O_BINARY);
213 < #endif
216 >        SET_FILE_BINARY(infp);
217                                          /* skip header */
218          getheader(infp, NULL, NULL);
219                                          /* get format */
# Line 337 | Line 340 | loadobj()                              /* get next object */
340                                          /* get name id */
341          ob.oname = ogetstr(idbuf);
342                                          /* get string arguments */
343 <        if (ob.oargs.nsargs = ogetint(2)) {
343 >        if ((ob.oargs.nsargs = ogetint(2))) {
344                  ob.oargs.sarg = (char **)malloc
345                                  (ob.oargs.nsargs*sizeof(char *));
346                  if (ob.oargs.sarg == NULL)
# Line 359 | Line 362 | loadobj()                              /* get next object */
362                  ob.oargs.iarg = NULL;
363   #endif
364                                          /* get real arguments */
365 <        if (ob.oargs.nfargs = ogetint(2)) {
366 <                ob.oargs.farg = (FLOAT *)malloc
367 <                                (ob.oargs.nfargs*sizeof(FLOAT));
365 >        if ((ob.oargs.nfargs = ogetint(2))) {
366 >                ob.oargs.farg = (RREAL *)malloc
367 >                                (ob.oargs.nfargs*sizeof(RREAL));
368                  if (ob.oargs.farg == NULL)
369                          goto memerr;
370                  for (i = 0; i < ob.oargs.nfargs; i++)
# Line 372 | Line 375 | loadobj()                              /* get next object */
375          (*ofun[ob.otype].funp)(&ob);
376                                          /* record material if modifier */
377          if (ismodifier(ob.otype)) {
378 <                if ((lep = lu_find(&imtab, (char *)nobjects)) == NULL)
378 >                if ((lep = lu_find(&imtab, (char *)(size_t)nobjects)) == NULL)
379                          goto memerr;
380 <                lep->key = (char *)nobjects;
380 >                lep->key = (char *)(size_t)nobjects;
381                  lep->data = (char *)getmatp(ob.oname);
382          }
383          freefargs(&ob.oargs);           /* free arguments */
384          return(nobjects++);             /* return object id */
385   memerr:
386          error(SYSTEM, "out of memory in loadobj");
387 +        return OVOID; /* pro forma return */
388   }
389  
390  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines