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.14 by greg, Thu Sep 18 16:53:52 2003 UTC

# Line 18 | Line 18 | typedef struct {
18          int             fl;
19          uint32          xyz[3];
20          int32           norm;
21 <        uint32          uv[2];
21 >        uint16          uv[2];
22   } MCVERT;
23  
24   #define  MPATCHBLKSIZ   128             /* patch allocation block size */
# Line 70 | 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 80 | 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++;
85 <                                return(ms);             /* loaded */
86 <                        }
87 <                        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 130 | 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 234 | Line 235 | int            what;
235                  for (i = 0; i < 2; i++)
236                          vp->uv[i] = mp->uvlim[0][i] +
237                                  (mp->uvlim[1][i] - mp->uvlim[0][i])*
238 <                                (pp->uv[vid][i] + .5)*(1./4294967296.);
238 >                                (pp->uv[vid][i] + .5)*(1./65536.);
239                  vp->fl |= MT_UV;
240          }
241          return(vp->fl);
# Line 313 | Line 314 | MESHVERT       *vp;
314                                  return(-1);
315                          if (vp->uv[i] >= mp->uvlim[1][i])
316                                  return(-1);
317 <                        cv.uv[i] = (uint32)(4294967296. *
317 >                        cv.uv[i] = (uint32)(65536. *
318                                          (vp->uv[i] - mp->uvlim[0][i]) /
319                                          (mp->uvlim[1][i] - mp->uvlim[0][i]));
320                  }
# Line 371 | Line 372 | MESHVERT       *vp;
372                  }
373                  if (cv.fl & MT_UV) {
374                          if (pp->uv == NULL) {
375 <                                pp->uv = (uint32 (*)[2])calloc(256,
376 <                                                2*sizeof(uint32));
375 >                                pp->uv = (uint16 (*)[2])calloc(256,
376 >                                                2*sizeof(uint16));
377                                  if (pp->uv == NULL)
378                                          goto nomem;
379                          }
# Line 409 | 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 610 | 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) +
619                          nscnt*sizeof(int32) +
620 <                        uvscnt*2*sizeof(uint32) +
620 >                        uvscnt*2*sizeof(uint16) +
621                          tcnt*sizeof(struct PTri) +
622                          t1cnt*sizeof(struct PJoin1) +
623                          t2cnt*sizeof(struct PJoin2))/(1024.*1024.));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines