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.9 by schorsch, Mon Jun 30 14:59:11 2003 UTC vs.
Revision 2.19 by schorsch, Sun Mar 28 20:33:12 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 27 | Line 30 | typedef struct {
30  
31   static MESH     *mlist = NULL;          /* list of loaded meshes */
32  
33 + static lut_keycmpf_t cvcmp;
34 + static lut_hashf_t cvhash;
35  
36 +
37   static unsigned long
38 < cvhash(cvp)                             /* hash an encoded vertex */
39 < MCVERT  *cvp;
38 > cvhash(p)                               /* hash an encoded vertex */
39 > //MCVERT        *cvp;
40 > void    *p;
41   {
42 +        MCVERT  *cvp = p;
43          unsigned long   hval;
44          
45          if (!(cvp->fl & MT_V))
# Line 46 | Line 54 | MCVERT *cvp;
54  
55  
56   static int
57 < cvcmp(v1, v2)                           /* compare encoded vertices */
58 < register MCVERT *v1, *v2;
57 > cvcmp(vv1, vv2)                         /* compare encoded vertices */
58 > //register MCVERT       *v1, *v2;
59 > const void      *vv1, *vv2;
60   {
61 +        const MCVERT    *v1 = vv1, *v2 = vv2;
62          if (v1->fl != v2->fl)
63                  return(1);
64          if (v1->xyz[0] != v2->xyz[0])
# Line 70 | Line 80 | register MCVERT        *v1, *v2;
80  
81  
82   MESH *
83 < getmesh(mname, flags)                   /* get mesh data */
83 > getmesh(mname, flags)                   /* get new mesh data reference */
84   char    *mname;
85   int     flags;
86   {
# Line 80 | Line 90 | int    flags;
90          flags &= IO_LEGAL;
91          for (ms = mlist; ms != NULL; ms = ms->next)
92                  if (!strcmp(mname, ms->name)) {
93 <                        if ((ms->ldflags & flags) == flags) {
94 <                                ms->nref++;
85 <                                return(ms);             /* loaded */
86 <                        }
87 <                        break;                  /* load the rest */
93 >                        ms->nref++;     /* increase reference count */
94 >                        break;
95                  }
96 <        if (ms == NULL) {
96 >        if (ms == NULL) {               /* load first time */
97                  ms = (MESH *)calloc(1, sizeof(MESH));
98                  if (ms == NULL)
99                          error(SYSTEM, "out of memory in getmesh");
# Line 130 | Line 137 | int    flags;
137                  ins->msh = NULL;
138                  o->os = (char *)ins;
139          }
140 <        if (ins->msh == NULL || (ins->msh->ldflags & flags) != flags)
140 >        if (ins->msh == NULL)
141                  ins->msh = getmesh(o->oargs.sarg[0], flags);
142 +        else if ((flags &= ~ins->msh->ldflags))
143 +                readmesh(ins->msh,
144 +                        getpath(o->oargs.sarg[0], getrlibpath(), R_OK),
145 +                                flags);
146          return(ins);
147   }
148  
# Line 305 | Line 316 | MESHVERT       *vp;
316                                  (vp->v[i] - mp->mcube.cuorg[i]) /
317                                  mp->mcube.cusize);
318          }
319 <        if (vp->fl & MT_N)
319 >        if (vp->fl & MT_N)              /* assumes normalized! */
320                  cv.norm = encodedir(vp->n);
321          if (vp->fl & MT_UV)
322                  for (i = 0; i < 2; i++) {
# Line 409 | Line 420 | OBJECT         mo;
420                  pn[i] = vid[i] >> 8;
421          }
422                                  /* normalize material index */
423 <        if (mo != OVOID)
423 >        if (mo != OVOID) {
424                  if ((mo -= mp->mat0) >= mp->nmats)
425                          mp->nmats = mo+1;
426                  else if (mo < 0)
427                          error(INTERNAL, "modifier range error in addmeshtri");
428 +        }
429                                  /* assign triangle */
430          if (pn[0] == pn[1] && pn[1] == pn[2]) { /* local case */
431                  pp = &mp->patch[pn[0]];
# Line 541 | Line 553 | register MESH  *mp;
553                                  if (nouvbounds && pp->uv != NULL)
554                                          return("unreferenced uv coordinates");
555                          }
544                        if (pp->ntris + pp->nj1tris + pp->nj2tris <= 0)
545                                error(WARNING, "no triangles in patch");
556                          if (pp->ntris > 0 && pp->tri == NULL)
557                                  return("missing patch triangle list");
558                          if (pp->nj1tris > 0 && pp->j1tri == NULL)
# Line 610 | Line 620 | FILE   *fp;
620                  t2cnt += pp->nj2tris;
621          }
622          fprintf(fp, "Mesh statistics:\n");
623 <        fprintf(fp, "\t%d materials\n", ms->nmats);
623 >        fprintf(fp, "\t%ld materials\n", ms->nmats);
624          fprintf(fp, "\t%d patches (%.2f MBytes)\n", ms->npatches,
625                          (ms->npatches*sizeof(MESHPATCH) +
626                          vcnt*3*sizeof(uint32) +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines