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.10 by greg, Thu Jul 10 03:30:11 2003 UTC vs.
Revision 2.18 by greg, Tue Mar 16 19:56:27 2004 UTC

# Line 7 | Line 7 | static const char RCSid[] = "$Id$";
7  
8   #include <string.h>
9  
10 < #include "standard.h"
10 > #include "rtio.h"
11 > #include "rtmath.h"
12 > #include "rterror.h"
13 > #include "paths.h"
14   #include "octree.h"
15   #include "object.h"
16   #include "otypes.h"
# Line 79 | Line 82 | int    flags;
82  
83          flags &= IO_LEGAL;
84          for (ms = mlist; ms != NULL; ms = ms->next)
85 <                if (!strcmp(mname, ms->name))
85 >                if (!strcmp(mname, ms->name)) {
86 >                        ms->nref++;     /* increase reference count */
87                          break;
88 +                }
89          if (ms == NULL) {               /* load first time */
90                  ms = (MESH *)calloc(1, sizeof(MESH));
91                  if (ms == NULL)
92                          error(SYSTEM, "out of memory in getmesh");
93                  ms->name = savestr(mname);
94 +                ms->nref = 1;
95                  ms->mcube.cutree = EMPTY;
96                  ms->next = mlist;
97                  mlist = ms;
# Line 97 | Line 103 | int    flags;
103          flags &= ~ms->ldflags;
104          if (flags)
105                  readmesh(ms, pathname, flags);
100        ms->nref++;                     /* increase reference count */
106          return(ms);
107   }
108  
# Line 304 | Line 309 | MESHVERT       *vp;
309                                  (vp->v[i] - mp->mcube.cuorg[i]) /
310                                  mp->mcube.cusize);
311          }
312 <        if (vp->fl & MT_N)
312 >        if (vp->fl & MT_N)              /* assumes normalized! */
313                  cv.norm = encodedir(vp->n);
314          if (vp->fl & MT_UV)
315                  for (i = 0; i < 2; i++) {
# Line 408 | Line 413 | OBJECT         mo;
413                  pn[i] = vid[i] >> 8;
414          }
415                                  /* normalize material index */
416 <        if (mo != OVOID)
416 >        if (mo != OVOID) {
417                  if ((mo -= mp->mat0) >= mp->nmats)
418                          mp->nmats = mo+1;
419                  else if (mo < 0)
420                          error(INTERNAL, "modifier range error in addmeshtri");
421 +        }
422                                  /* assign triangle */
423          if (pn[0] == pn[1] && pn[1] == pn[2]) { /* local case */
424                  pp = &mp->patch[pn[0]];
# Line 540 | Line 546 | register MESH  *mp;
546                                  if (nouvbounds && pp->uv != NULL)
547                                          return("unreferenced uv coordinates");
548                          }
543                        if (pp->ntris + pp->nj1tris + pp->nj2tris <= 0)
544                                error(WARNING, "no triangles in patch");
549                          if (pp->ntris > 0 && pp->tri == NULL)
550                                  return("missing patch triangle list");
551                          if (pp->nj1tris > 0 && pp->j1tri == NULL)
# Line 609 | Line 613 | FILE   *fp;
613                  t2cnt += pp->nj2tris;
614          }
615          fprintf(fp, "Mesh statistics:\n");
616 <        fprintf(fp, "\t%d materials\n", ms->nmats);
616 >        fprintf(fp, "\t%ld materials\n", ms->nmats);
617          fprintf(fp, "\t%d patches (%.2f MBytes)\n", ms->npatches,
618                          (ms->npatches*sizeof(MESHPATCH) +
619                          vcnt*3*sizeof(uint32) +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines