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" |
92 |
|
default: |
93 |
|
mesherror(USER, "damaged mesh octree"); |
94 |
|
} |
95 |
< |
return NULL; /* pro forma return */ |
95 |
> |
return (OCTREE)NULL; /* pro forma return */ |
96 |
|
} |
97 |
|
|
98 |
|
|
135 |
|
pp->nverts = mgetint(2); |
136 |
|
if (pp->nverts <= 0 || pp->nverts > 256) |
137 |
|
mesherror(USER, "bad number of patch vertices"); |
138 |
< |
pp->xyz = (uint4 (*)[3])malloc(pp->nverts*3*sizeof(uint4)); |
138 |
> |
pp->xyz = (uint32 (*)[3])malloc(pp->nverts*3*sizeof(uint32)); |
139 |
|
if (pp->xyz == NULL) |
140 |
|
goto nomem; |
141 |
|
if (flags & MT_N) { |
142 |
< |
pp->norm = (int4 *)calloc(pp->nverts, sizeof(int4)); |
142 |
> |
pp->norm = (int32 *)calloc(pp->nverts, sizeof(int32)); |
143 |
|
if (pp->norm == NULL) |
144 |
|
goto nomem; |
145 |
|
} else |
146 |
|
pp->norm = NULL; |
147 |
|
if (flags & MT_UV) { |
148 |
< |
pp->uv = (uint4 (*)[2])calloc(pp->nverts, 2*sizeof(uint4)); |
148 |
> |
pp->uv = (uint16 (*)[2])calloc(pp->nverts, 2*sizeof(uint16)); |
149 |
|
if (pp->uv == NULL) |
150 |
|
goto nomem; |
151 |
|
} else |
162 |
|
if (flags & MT_UV) |
163 |
|
for (i = 0; i < pp->nverts; i++) |
164 |
|
for (j = 0; j < 2; j++) |
165 |
< |
pp->uv[i][j] = mgetint(4); |
165 |
> |
pp->uv[i][j] = mgetint(2); |
166 |
|
/* local triangles */ |
167 |
|
pp->ntris = mgetint(2); |
168 |
|
if (pp->ntris < 0 || pp->ntris > 512) |
181 |
|
pp->tri = NULL; |
182 |
|
/* local triangle material(s) */ |
183 |
|
if (mgetint(2) > 1) { |
184 |
< |
pp->trimat = (int2 *)malloc(pp->ntris*sizeof(int2)); |
184 |
> |
pp->trimat = (int16 *)malloc(pp->ntris*sizeof(int16)); |
185 |
|
if (pp->trimat == NULL) |
186 |
|
goto nomem; |
187 |
|
for (i = 0; i < pp->ntris; i++) |