diff --git a/include/QF/model.h b/include/QF/model.h index 04fc0261c..27b226cf4 100644 --- a/include/QF/model.h +++ b/include/QF/model.h @@ -341,12 +341,10 @@ typedef struct { maliasframedesc_t frames[1]; } aliashdr_t; -#define MAXALIASVERTS 1024 #define MAXALIASFRAMES 256 -#define MAXALIASTRIS 2048 extern aliashdr_t *pheader; -extern stvert_t stverts[MAXALIASVERTS]; -extern mtriangle_t triangles[MAXALIASTRIS]; +extern stvert_t *stverts; +extern mtriangle_t *triangles; extern trivertx_t *poseverts[MAXALIASFRAMES]; //=================================================================== diff --git a/libs/models/alias/model_alias.c b/libs/models/alias/model_alias.c index 74e7a333f..371e289dc 100644 --- a/libs/models/alias/model_alias.c +++ b/libs/models/alias/model_alias.c @@ -58,8 +58,10 @@ static const char rcsid[] = aliashdr_t *pheader; -stvert_t stverts[MAXALIASVERTS]; -mtriangle_t triangles[MAXALIASTRIS]; +stvert_t *stverts; +mtriangle_t *triangles; +int stverts_size = 0; +int triangles_size = 0; // a pose is a single set of vertexes. a frame may be an animating // sequence of poses @@ -196,14 +198,27 @@ Mod_LoadAliasModel (model_t *mod, void *buffer, cache_allocator_t allocator) if (pmodel->numverts <= 0) Sys_Error ("model %s has no vertices", mod->name); - if (pmodel->numverts > MAXALIASVERTS) - Sys_Error ("model %s has too many vertices", mod->name); + if (pmodel->numverts > stverts_size) + { + stverts = realloc (stverts, pmodel->numverts * sizeof (stvert_t)); + if (!stverts) + Sys_Error ("model_alias: out of memory"); + stverts_size = pmodel->numverts; + } pmodel->numtris = LittleLong (pinmodel->numtris); if (pmodel->numtris <= 0) Sys_Error ("model %s has no triangles", mod->name); + if (pmodel->numtris > triangles_size) + { + triangles = realloc (triangles, pmodel->numtris * sizeof (mtriangle_t)); + if (!triangles) + Sys_Error ("model_alias: out of memory"); + triangles_size = pmodel->numtris; + } + pmodel->numframes = LittleLong (pinmodel->numframes); numframes = pmodel->numframes; if (numframes < 1)