Improve IQM loading

- Only allocate memory for vertex arrays that are present in the IQM
file and are actually used (may not have colors or blend index/weights,
don't load tangents in opengl1). (Colors is fixed to next commit.)
- Explicitly handle loading IQM files without meshes (bones only).
- Better IQM validation. Header data offset 0 mean data is not present
in file. Check if required vertex arrays are present.

This involved a lot of white space changes and moving code around.
This commit is contained in:
Zack Middleton 2018-07-27 17:40:16 -05:00
parent 6c3d92133d
commit fdc08e860e
4 changed files with 924 additions and 751 deletions

View file

@ -599,6 +599,7 @@ typedef struct {
int num_poses;
struct srfIQModel_s *surfaces;
int *triangles;
float *positions;
float *texcoords;
float *normals;
@ -609,18 +610,17 @@ typedef struct {
byte *b;
} blendWeights;
byte *colors;
int *triangles;
// depending upon the exporter, blend indices and weights might be int/float
// as opposed to the recommended byte/byte, for example Noesis exports
// int/float whereas the official IQM tool exports byte/byte
byte blendWeightsType; // IQM_UBYTE or IQM_FLOAT
char *jointNames;
int *jointParents;
float *jointMats;
float *poseMats;
float *bounds;
char *names;
} iqmData_t;
// inter-quake-model surface