--- ray/src/common/mesh.c 2003/09/18 16:53:52 2.14 +++ ray/src/common/mesh.c 2004/03/16 19:56:27 2.18 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: mesh.c,v 2.14 2003/09/18 16:53:52 greg Exp $"; +static const char RCSid[] = "$Id: mesh.c,v 2.18 2004/03/16 19:56:27 greg Exp $"; #endif /* * Mesh support routines @@ -7,7 +7,10 @@ static const char RCSid[] = "$Id: mesh.c,v 2.14 2003/0 #include -#include "standard.h" +#include "rtio.h" +#include "rtmath.h" +#include "rterror.h" +#include "paths.h" #include "octree.h" #include "object.h" #include "otypes.h" @@ -18,7 +21,7 @@ typedef struct { int fl; uint32 xyz[3]; int32 norm; - uint16 uv[2]; + uint32 uv[2]; } MCVERT; #define MPATCHBLKSIZ 128 /* patch allocation block size */ @@ -235,7 +238,7 @@ int what; for (i = 0; i < 2; i++) vp->uv[i] = mp->uvlim[0][i] + (mp->uvlim[1][i] - mp->uvlim[0][i])* - (pp->uv[vid][i] + .5)*(1./65536.); + (pp->uv[vid][i] + .5)*(1./4294967296.); vp->fl |= MT_UV; } return(vp->fl); @@ -306,7 +309,7 @@ MESHVERT *vp; (vp->v[i] - mp->mcube.cuorg[i]) / mp->mcube.cusize); } - if (vp->fl & MT_N) + if (vp->fl & MT_N) /* assumes normalized! */ cv.norm = encodedir(vp->n); if (vp->fl & MT_UV) for (i = 0; i < 2; i++) { @@ -314,7 +317,7 @@ MESHVERT *vp; return(-1); if (vp->uv[i] >= mp->uvlim[1][i]) return(-1); - cv.uv[i] = (uint32)(65536. * + cv.uv[i] = (uint32)(4294967296. * (vp->uv[i] - mp->uvlim[0][i]) / (mp->uvlim[1][i] - mp->uvlim[0][i])); } @@ -372,8 +375,8 @@ MESHVERT *vp; } if (cv.fl & MT_UV) { if (pp->uv == NULL) { - pp->uv = (uint16 (*)[2])calloc(256, - 2*sizeof(uint16)); + pp->uv = (uint32 (*)[2])calloc(256, + 2*sizeof(uint32)); if (pp->uv == NULL) goto nomem; } @@ -543,8 +546,6 @@ register MESH *mp; if (nouvbounds && pp->uv != NULL) return("unreferenced uv coordinates"); } - if (pp->ntris + pp->nj1tris + pp->nj2tris <= 0) - error(WARNING, "no triangles in patch"); if (pp->ntris > 0 && pp->tri == NULL) return("missing patch triangle list"); if (pp->nj1tris > 0 && pp->j1tri == NULL) @@ -617,7 +618,7 @@ FILE *fp; (ms->npatches*sizeof(MESHPATCH) + vcnt*3*sizeof(uint32) + nscnt*sizeof(int32) + - uvscnt*2*sizeof(uint16) + + uvscnt*2*sizeof(uint32) + tcnt*sizeof(struct PTri) + t1cnt*sizeof(struct PJoin1) + t2cnt*sizeof(struct PJoin2))/(1024.*1024.));