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

Comparing ray/src/common/mesh.c (file contents):
Revision 2.8 by greg, Fri Jun 20 00:25:49 2003 UTC vs.
Revision 2.10 by greg, Thu Jul 10 03:30:11 2003 UTC

# Line 5 | Line 5 | static const char RCSid[] = "$Id$";
5   * Mesh support routines
6   */
7  
8 + #include <string.h>
9 +
10   #include "standard.h"
11   #include "octree.h"
12   #include "object.h"
# Line 68 | Line 70 | register MCVERT        *v1, *v2;
70  
71  
72   MESH *
73 < getmesh(mname, flags)                   /* get mesh data */
73 > getmesh(mname, flags)                   /* get new mesh data reference */
74   char    *mname;
75   int     flags;
76   {
# Line 77 | Line 79 | int    flags;
79  
80          flags &= IO_LEGAL;
81          for (ms = mlist; ms != NULL; ms = ms->next)
82 <                if (!strcmp(mname, ms->name)) {
83 <                        if ((ms->ldflags & flags) == flags) {
84 <                                ms->nref++;
83 <                                return(ms);             /* loaded */
84 <                        }
85 <                        break;                  /* load the rest */
86 <                }
87 <        if (ms == NULL) {
82 >                if (!strcmp(mname, ms->name))
83 >                        break;
84 >        if (ms == NULL) {               /* load first time */
85                  ms = (MESH *)calloc(1, sizeof(MESH));
86                  if (ms == NULL)
87                          error(SYSTEM, "out of memory in getmesh");
88                  ms->name = savestr(mname);
92                ms->nref = 1;
89                  ms->mcube.cutree = EMPTY;
90                  ms->next = mlist;
91                  mlist = ms;
# Line 101 | Line 97 | int    flags;
97          flags &= ~ms->ldflags;
98          if (flags)
99                  readmesh(ms, pathname, flags);
100 +        ms->nref++;                     /* increase reference count */
101          return(ms);
102   }
103  
# Line 128 | Line 125 | int    flags;
125                  ins->msh = NULL;
126                  o->os = (char *)ins;
127          }
128 <        if (ins->msh == NULL || (ins->msh->ldflags & flags) != flags)
128 >        if (ins->msh == NULL)
129                  ins->msh = getmesh(o->oargs.sarg[0], flags);
130 +        else if ((flags &= ~ins->msh->ldflags))
131 +                readmesh(ins->msh,
132 +                        getpath(o->oargs.sarg[0], getrlibpath(), R_OK),
133 +                                flags);
134          return(ins);
135   }
136  
# Line 329 | Line 330 | MESHVERT       *vp;
330                  goto nomem;
331          if (lvp->key == NULL) {
332                  lvp->key = (char *)malloc(sizeof(MCVERT)+sizeof(int32));
333 <                bcopy((void *)&cv, (void *)lvp->key, sizeof(MCVERT));
333 >                memcpy((void *)lvp->key, (void *)&cv, sizeof(MCVERT));
334          }
335          if (lvp->data == NULL) {        /* new vertex */
336                  register MESHPATCH      *pp;
# Line 345 | Line 346 | MESHVERT       *vp;
346                                                  (void *)mp->patch,
347                                          (mp->npatches + MPATCHBLKSIZ)*
348                                                  sizeof(MESHPATCH));
349 <                                bzero((void *)(mp->patch + mp->npatches),
349 >                                memset((void *)(mp->patch + mp->npatches), '\0',
350                                          MPATCHBLKSIZ*sizeof(MESHPATCH));
351                          }
352                          if (mp->npatches++ >= 1L<<22)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines