--- ray/src/common/readmesh.c 2003/06/05 19:29:34 2.3 +++ ray/src/common/readmesh.c 2010/12/15 17:26:28 2.14 @@ -1,15 +1,24 @@ #ifndef lint -static const char RCSid[] = "$Id: readmesh.c,v 2.3 2003/06/05 19:29:34 schorsch Exp $"; +static const char RCSid[] = "$Id: readmesh.c,v 2.14 2010/12/15 17:26:28 greg Exp $"; #endif /* * Routines for reading a compiled mesh from a file */ +#include + +#include "platform.h" #include "standard.h" #include "octree.h" #include "object.h" #include "mesh.h" +#include "resolu.h" +#ifdef getc_unlocked /* avoid horrendous overhead of flockfile */ +#undef getc +#define getc getc_unlocked +#endif + static char *meshfn; /* input file name */ static FILE *meshfp; /* mesh file pointer */ static int objsize; /* sizeof(OBJECT) from writer */ @@ -73,21 +82,22 @@ gettree() /* get a pre-ordered octree */ register int i; switch (getc(meshfp)) { - case OT_EMPTY: - return(EMPTY); - case OT_FULL: - return(getfullnode()); - case OT_TREE: - if ((ot = octalloc()) == EMPTY) - mesherror(SYSTEM, "out of tree space in readmesh"); - for (i = 0; i < 8; i++) - octkid(ot, i) = gettree(); - return(ot); - case EOF: - mesherror(USER, "truncated mesh octree"); - default: - mesherror(USER, "damaged mesh octree"); + case OT_EMPTY: + return(EMPTY); + case OT_FULL: + return(getfullnode()); + case OT_TREE: + if ((ot = octalloc()) == EMPTY) + mesherror(SYSTEM, "out of tree space in readmesh"); + for (i = 0; i < 8; i++) + octkid(ot, i) = gettree(); + return(ot); + case EOF: + mesherror(USER, "truncated mesh octree"); + default: + mesherror(USER, "damaged mesh octree"); } + return (OCTREE)0; /* pro forma return */ } @@ -130,17 +140,17 @@ register MESHPATCH *pp; pp->nverts = mgetint(2); if (pp->nverts <= 0 || pp->nverts > 256) mesherror(USER, "bad number of patch vertices"); - pp->xyz = (uint4 (*)[3])malloc(pp->nverts*3*sizeof(uint4)); + pp->xyz = (uint32 (*)[3])malloc(pp->nverts*3*sizeof(uint32)); if (pp->xyz == NULL) goto nomem; if (flags & MT_N) { - pp->norm = (int4 *)calloc(pp->nverts, sizeof(int4)); + pp->norm = (int32 *)calloc(pp->nverts, sizeof(int32)); if (pp->norm == NULL) goto nomem; } else pp->norm = NULL; if (flags & MT_UV) { - pp->uv = (uint4 (*)[2])calloc(pp->nverts, 2*sizeof(uint4)); + pp->uv = (uint32 (*)[2])calloc(pp->nverts, 2*sizeof(uint32)); if (pp->uv == NULL) goto nomem; } else @@ -176,7 +186,7 @@ register MESHPATCH *pp; pp->tri = NULL; /* local triangle material(s) */ if (mgetint(2) > 1) { - pp->trimat = (int2 *)malloc(pp->ntris*sizeof(int2)); + pp->trimat = (int16 *)malloc(pp->ntris*sizeof(int16)); if (pp->trimat == NULL) goto nomem; for (i = 0; i < pp->ntris; i++)