| 5 |
|
* Routines for reading a compiled mesh from a file |
| 6 |
|
*/ |
| 7 |
|
|
| 8 |
< |
#include "standard.h" |
| 8 |
> |
#include <time.h> |
| 9 |
> |
|
| 10 |
|
#include "platform.h" |
| 11 |
+ |
#include "standard.h" |
| 12 |
|
#include "octree.h" |
| 13 |
|
#include "object.h" |
| 14 |
|
#include "mesh.h" |
| 15 |
|
#include "resolu.h" |
| 16 |
|
|
| 17 |
+ |
#ifdef getc_unlocked /* avoid horrendous overhead of flockfile */ |
| 18 |
+ |
#undef getc |
| 19 |
+ |
#define getc getc_unlocked |
| 20 |
+ |
#endif |
| 21 |
+ |
|
| 22 |
|
static char *meshfn; /* input file name */ |
| 23 |
|
static FILE *meshfp; /* mesh file pointer */ |
| 24 |
|
static int objsize; /* sizeof(OBJECT) from writer */ |
| 97 |
|
default: |
| 98 |
|
mesherror(USER, "damaged mesh octree"); |
| 99 |
|
} |
| 100 |
< |
return NULL; /* pro forma return */ |
| 100 |
> |
return (OCTREE)NULL; /* pro forma return */ |
| 101 |
|
} |
| 102 |
|
|
| 103 |
|
|
| 140 |
|
pp->nverts = mgetint(2); |
| 141 |
|
if (pp->nverts <= 0 || pp->nverts > 256) |
| 142 |
|
mesherror(USER, "bad number of patch vertices"); |
| 143 |
< |
pp->xyz = (uint4 (*)[3])malloc(pp->nverts*3*sizeof(uint4)); |
| 143 |
> |
pp->xyz = (uint32 (*)[3])malloc(pp->nverts*3*sizeof(uint32)); |
| 144 |
|
if (pp->xyz == NULL) |
| 145 |
|
goto nomem; |
| 146 |
|
if (flags & MT_N) { |
| 147 |
< |
pp->norm = (int4 *)calloc(pp->nverts, sizeof(int4)); |
| 147 |
> |
pp->norm = (int32 *)calloc(pp->nverts, sizeof(int32)); |
| 148 |
|
if (pp->norm == NULL) |
| 149 |
|
goto nomem; |
| 150 |
|
} else |
| 151 |
|
pp->norm = NULL; |
| 152 |
|
if (flags & MT_UV) { |
| 153 |
< |
pp->uv = (uint4 (*)[2])calloc(pp->nverts, 2*sizeof(uint4)); |
| 153 |
> |
pp->uv = (uint32 (*)[2])calloc(pp->nverts, 2*sizeof(uint32)); |
| 154 |
|
if (pp->uv == NULL) |
| 155 |
|
goto nomem; |
| 156 |
|
} else |
| 186 |
|
pp->tri = NULL; |
| 187 |
|
/* local triangle material(s) */ |
| 188 |
|
if (mgetint(2) > 1) { |
| 189 |
< |
pp->trimat = (int2 *)malloc(pp->ntris*sizeof(int2)); |
| 189 |
> |
pp->trimat = (int16 *)malloc(pp->ntris*sizeof(int16)); |
| 190 |
|
if (pp->trimat == NULL) |
| 191 |
|
goto nomem; |
| 192 |
|
for (i = 0; i < pp->ntris; i++) |