--- ray/src/common/mesh.c 2003/04/23 00:52:33 2.6 +++ ray/src/common/mesh.c 2003/06/30 14:59:11 2.9 @@ -1,10 +1,12 @@ #ifndef lint -static const char RCSid[] = "$Id: mesh.c,v 2.6 2003/04/23 00:52:33 greg Exp $"; +static const char RCSid[] = "$Id: mesh.c,v 2.9 2003/06/30 14:59:11 schorsch Exp $"; #endif /* * Mesh support routines */ +#include + #include "standard.h" #include "octree.h" #include "object.h" @@ -14,9 +16,9 @@ static const char RCSid[] = "$Id: mesh.c,v 2.6 2003/04 /* An encoded mesh vertex */ typedef struct { int fl; - uint4 xyz[3]; - int4 norm; - uint4 uv[2]; + uint32 xyz[3]; + int32 norm; + uint32 uv[2]; } MCVERT; #define MPATCHBLKSIZ 128 /* patch allocation block size */ @@ -94,7 +96,7 @@ int flags; ms->next = mlist; mlist = ms; } - if ((pathname = getpath(mname, getlibpath(), R_OK)) == NULL) { + if ((pathname = getpath(mname, getrlibpath(), R_OK)) == NULL) { sprintf(errmsg, "cannot find mesh file \"%s\"", mname); error(USER, errmsg); } @@ -136,7 +138,7 @@ int flags; int getmeshtrivid(tvid, mo, mp, ti) /* get triangle vertex ID's */ -int4 tvid[3]; +int32 tvid[3]; OBJECT *mo; MESH *mp; OBJECT ti; @@ -199,7 +201,7 @@ int getmeshvert(vp, mp, vid, what) /* get triangle vertex from ID */ MESHVERT *vp; MESH *mp; -int4 vid; +int32 vid; int what; { int pn = vid >> 8; @@ -269,7 +271,7 @@ MESH *mp; OBJECT ti; int wha; { - int4 tvid[3]; + int32 tvid[3]; if (!getmeshtrivid(tvid, mo, mp, ti)) return(0); @@ -282,7 +284,7 @@ int wha; } -int4 +int32 addmeshvert(mp, vp) /* find/add a mesh vertex */ register MESH *mp; MESHVERT *vp; @@ -299,7 +301,7 @@ MESHVERT *vp; return(-1); if (vp->v[i] >= mp->mcube.cuorg[i] + mp->mcube.cusize) return(-1); - cv.xyz[i] = (uint4)(4294967296. * + cv.xyz[i] = (uint32)(4294967296. * (vp->v[i] - mp->mcube.cuorg[i]) / mp->mcube.cusize); } @@ -311,7 +313,7 @@ MESHVERT *vp; return(-1); if (vp->uv[i] >= mp->uvlim[1][i]) return(-1); - cv.uv[i] = (uint4)(4294967296. * + cv.uv[i] = (uint32)(4294967296. * (vp->uv[i] - mp->uvlim[0][i]) / (mp->uvlim[1][i] - mp->uvlim[0][i])); } @@ -328,8 +330,8 @@ MESHVERT *vp; if (lvp == NULL) goto nomem; if (lvp->key == NULL) { - lvp->key = (char *)malloc(sizeof(MCVERT)+sizeof(int4)); - bcopy((void *)&cv, (void *)lvp->key, sizeof(MCVERT)); + lvp->key = (char *)malloc(sizeof(MCVERT)+sizeof(int32)); + memcpy((void *)lvp->key, (void *)&cv, sizeof(MCVERT)); } if (lvp->data == NULL) { /* new vertex */ register MESHPATCH *pp; @@ -345,7 +347,7 @@ MESHVERT *vp; (void *)mp->patch, (mp->npatches + MPATCHBLKSIZ)* sizeof(MESHPATCH)); - bzero((void *)(mp->patch + mp->npatches), + memset((void *)(mp->patch + mp->npatches), '\0', MPATCHBLKSIZ*sizeof(MESHPATCH)); } if (mp->npatches++ >= 1L<<22) @@ -353,7 +355,7 @@ MESHVERT *vp; } pp = &mp->patch[mp->npatches-1]; if (pp->xyz == NULL) { - pp->xyz = (uint4 (*)[3])calloc(256, 3*sizeof(int4)); + pp->xyz = (uint32 (*)[3])calloc(256, 3*sizeof(int32)); if (pp->xyz == NULL) goto nomem; } @@ -361,7 +363,7 @@ MESHVERT *vp; pp->xyz[pp->nverts][i] = cv.xyz[i]; if (cv.fl & MT_N) { if (pp->norm == NULL) { - pp->norm = (int4 *)calloc(256, sizeof(int4)); + pp->norm = (int32 *)calloc(256, sizeof(int32)); if (pp->norm == NULL) goto nomem; } @@ -369,8 +371,8 @@ MESHVERT *vp; } if (cv.fl & MT_UV) { if (pp->uv == NULL) { - pp->uv = (uint4 (*)[2])calloc(256, - 2*sizeof(uint4)); + pp->uv = (uint32 (*)[2])calloc(256, + 2*sizeof(uint32)); if (pp->uv == NULL) goto nomem; } @@ -379,9 +381,9 @@ MESHVERT *vp; } pp->nverts++; lvp->data = lvp->key + sizeof(MCVERT); - *(int4 *)lvp->data = (mp->npatches-1) << 8 | (pp->nverts-1); + *(int32 *)lvp->data = (mp->npatches-1) << 8 | (pp->nverts-1); } - return(*(int4 *)lvp->data); + return(*(int32 *)lvp->data); nomem: error(SYSTEM, "out of memory in addmeshvert"); return(-1); @@ -394,7 +396,7 @@ MESH *mp; MESHVERT tv[3]; OBJECT mo; { - int4 vid[3], t; + int32 vid[3], t; int pn[3], i; register MESHPATCH *pp; @@ -428,8 +430,8 @@ OBJECT mo; if (pp->ntris == 0) pp->solemat = mo; else if (pp->trimat == NULL && mo != pp->solemat) { - pp->trimat = (int2 *)malloc( - 512*sizeof(int2)); + pp->trimat = (int16 *)malloc( + 512*sizeof(int16)); if (pp->trimat == NULL) goto nomem; for (i = pp->ntris; i--; ) @@ -611,9 +613,9 @@ FILE *fp; fprintf(fp, "\t%d materials\n", ms->nmats); fprintf(fp, "\t%d patches (%.2f MBytes)\n", ms->npatches, (ms->npatches*sizeof(MESHPATCH) + - vcnt*3*sizeof(uint4) + - nscnt*sizeof(int4) + - uvscnt*2*sizeof(uint4) + + vcnt*3*sizeof(uint32) + + nscnt*sizeof(int32) + + uvscnt*2*sizeof(uint32) + tcnt*sizeof(struct PTri) + t1cnt*sizeof(struct PJoin1) + t2cnt*sizeof(struct PJoin2))/(1024.*1024.));