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.13 by schorsch, Mon Jul 21 22:30:17 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 78 | Line 80 | int    flags;
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 */
83 >                        ms->nref++;     /* increase reference count */
84 >                        break;
85                  }
86 <        if (ms == NULL) {
86 >        if (ms == NULL) {               /* load first time */
87                  ms = (MESH *)calloc(1, sizeof(MESH));
88                  if (ms == NULL)
89                          error(SYSTEM, "out of memory in getmesh");
# Line 128 | Line 127 | int    flags;
127                  ins->msh = NULL;
128                  o->os = (char *)ins;
129          }
130 <        if (ins->msh == NULL || (ins->msh->ldflags & flags) != flags)
130 >        if (ins->msh == NULL)
131                  ins->msh = getmesh(o->oargs.sarg[0], flags);
132 +        else if ((flags &= ~ins->msh->ldflags))
133 +                readmesh(ins->msh,
134 +                        getpath(o->oargs.sarg[0], getrlibpath(), R_OK),
135 +                                flags);
136          return(ins);
137   }
138  
# Line 329 | Line 332 | MESHVERT       *vp;
332                  goto nomem;
333          if (lvp->key == NULL) {
334                  lvp->key = (char *)malloc(sizeof(MCVERT)+sizeof(int32));
335 <                bcopy((void *)&cv, (void *)lvp->key, sizeof(MCVERT));
335 >                memcpy((void *)lvp->key, (void *)&cv, sizeof(MCVERT));
336          }
337          if (lvp->data == NULL) {        /* new vertex */
338                  register MESHPATCH      *pp;
# Line 345 | Line 348 | MESHVERT       *vp;
348                                                  (void *)mp->patch,
349                                          (mp->npatches + MPATCHBLKSIZ)*
350                                                  sizeof(MESHPATCH));
351 <                                bzero((void *)(mp->patch + mp->npatches),
351 >                                memset((void *)(mp->patch + mp->npatches), '\0',
352                                          MPATCHBLKSIZ*sizeof(MESHPATCH));
353                          }
354                          if (mp->npatches++ >= 1L<<22)
# Line 407 | Line 410 | OBJECT         mo;
410                  pn[i] = vid[i] >> 8;
411          }
412                                  /* normalize material index */
413 <        if (mo != OVOID)
413 >        if (mo != OVOID) {
414                  if ((mo -= mp->mat0) >= mp->nmats)
415                          mp->nmats = mo+1;
416                  else if (mo < 0)
417                          error(INTERNAL, "modifier range error in addmeshtri");
418 +        }
419                                  /* assign triangle */
420          if (pn[0] == pn[1] && pn[1] == pn[2]) { /* local case */
421                  pp = &mp->patch[pn[0]];
# Line 608 | Line 612 | FILE   *fp;
612                  t2cnt += pp->nj2tris;
613          }
614          fprintf(fp, "Mesh statistics:\n");
615 <        fprintf(fp, "\t%d materials\n", ms->nmats);
615 >        fprintf(fp, "\t%ld materials\n", ms->nmats);
616          fprintf(fp, "\t%d patches (%.2f MBytes)\n", ms->npatches,
617                          (ms->npatches*sizeof(MESHPATCH) +
618                          vcnt*3*sizeof(uint32) +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines