mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-13 08:27:39 +00:00
slaying hardcoded mdl vertex and triangle limit
This commit is contained in:
parent
36bb62c3c5
commit
6ec47e6be6
2 changed files with 21 additions and 8 deletions
|
@ -341,12 +341,10 @@ typedef struct {
|
||||||
maliasframedesc_t frames[1];
|
maliasframedesc_t frames[1];
|
||||||
} aliashdr_t;
|
} aliashdr_t;
|
||||||
|
|
||||||
#define MAXALIASVERTS 1024
|
|
||||||
#define MAXALIASFRAMES 256
|
#define MAXALIASFRAMES 256
|
||||||
#define MAXALIASTRIS 2048
|
|
||||||
extern aliashdr_t *pheader;
|
extern aliashdr_t *pheader;
|
||||||
extern stvert_t stverts[MAXALIASVERTS];
|
extern stvert_t *stverts;
|
||||||
extern mtriangle_t triangles[MAXALIASTRIS];
|
extern mtriangle_t *triangles;
|
||||||
extern trivertx_t *poseverts[MAXALIASFRAMES];
|
extern trivertx_t *poseverts[MAXALIASFRAMES];
|
||||||
|
|
||||||
//===================================================================
|
//===================================================================
|
||||||
|
|
|
@ -58,8 +58,10 @@ static const char rcsid[] =
|
||||||
|
|
||||||
aliashdr_t *pheader;
|
aliashdr_t *pheader;
|
||||||
|
|
||||||
stvert_t stverts[MAXALIASVERTS];
|
stvert_t *stverts;
|
||||||
mtriangle_t triangles[MAXALIASTRIS];
|
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
|
// a pose is a single set of vertexes. a frame may be an animating
|
||||||
// sequence of poses
|
// sequence of poses
|
||||||
|
@ -196,14 +198,27 @@ Mod_LoadAliasModel (model_t *mod, void *buffer, cache_allocator_t allocator)
|
||||||
if (pmodel->numverts <= 0)
|
if (pmodel->numverts <= 0)
|
||||||
Sys_Error ("model %s has no vertices", mod->name);
|
Sys_Error ("model %s has no vertices", mod->name);
|
||||||
|
|
||||||
if (pmodel->numverts > MAXALIASVERTS)
|
if (pmodel->numverts > stverts_size)
|
||||||
Sys_Error ("model %s has too many vertices", mod->name);
|
{
|
||||||
|
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);
|
pmodel->numtris = LittleLong (pinmodel->numtris);
|
||||||
|
|
||||||
if (pmodel->numtris <= 0)
|
if (pmodel->numtris <= 0)
|
||||||
Sys_Error ("model %s has no triangles", mod->name);
|
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);
|
pmodel->numframes = LittleLong (pinmodel->numframes);
|
||||||
numframes = pmodel->numframes;
|
numframes = pmodel->numframes;
|
||||||
if (numframes < 1)
|
if (numframes < 1)
|
||||||
|
|
Loading…
Reference in a new issue