no more hardcoded MAXALIASVERTS limit

This commit is contained in:
Seth Galbraith 2002-01-05 17:56:33 +00:00
parent cb6ef3e225
commit 1e57bcdca2
2 changed files with 40 additions and 16 deletions

View file

@ -40,6 +40,8 @@ static const char rcsid[] =
#include "d_ifacea.h" #include "d_ifacea.h"
#include "r_local.h" #include "r_local.h"
#include "stdlib.h"
#define LIGHT_MIN 5 // lowest light value we'll allow, to #define LIGHT_MIN 5 // lowest light value we'll allow, to
// avoid the need for inner-loop light // avoid the need for inner-loop light
// clamping // clamping
@ -667,24 +669,34 @@ R_AliasSetupFrame (void)
((byte *) paliashdr + paliasgroup->frames[i].frame); ((byte *) paliashdr + paliasgroup->frames[i].frame);
} }
#define MAXALIASVERTS 1024 finalvert_t *finalverts;
auxvert_t *auxverts;
int maxaliasverts = 0;
void void
R_AliasDrawModel (alight_t *plighting) R_AliasDrawModel (alight_t *plighting)
{ {
finalvert_t finalverts[MAXALIASVERTS +
((CACHE_SIZE - 1) / sizeof (finalvert_t)) + 1];
auxvert_t auxverts[MAXALIASVERTS];
r_amodels_drawn++; r_amodels_drawn++;
paliashdr = Cache_Get (&currententity->model->cache);
pmdl = (mdl_t *) ((byte *) paliashdr + paliashdr->model);
if (pmdl->numverts > maxaliasverts)
{
finalverts = realloc (finalverts, (CACHE_SIZE - 1) +
sizeof (finalvert_t) * (pmdl->numverts + 1));
auxverts = realloc (auxverts,
sizeof (auxvert_t) * pmdl->numverts);
if (!finalverts || !auxverts)
Sys_Error ("R_AliasDrawModel: out of memory");
maxaliasverts = pmdl->numverts;
}
// cache align // cache align
pfinalverts = (finalvert_t *) pfinalverts = (finalvert_t *)
(((long) &finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1)); (((long) &finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
pauxverts = &auxverts[0]; pauxverts = &auxverts[0];
paliashdr = Cache_Get (&currententity->model->cache);
pmdl = (mdl_t *) ((byte *) paliashdr + paliashdr->model);
R_AliasSetupSkin (); R_AliasSetupSkin ();
R_AliasSetUpTransform (currententity->trivial_accept); R_AliasSetUpTransform (currententity->trivial_accept);
R_AliasSetupLighting (plighting); R_AliasSetupLighting (plighting);

View file

@ -40,6 +40,8 @@ static const char rcsid[] =
#include "d_ifacea.h" #include "d_ifacea.h"
#include "r_local.h" #include "r_local.h"
#include "stdlib.h"
#define LIGHT_MIN 5 // lowest light value we'll allow, to #define LIGHT_MIN 5 // lowest light value we'll allow, to
// avoid the need for inner-loop light // avoid the need for inner-loop light
// clamping // clamping
@ -659,24 +661,34 @@ R_AliasSetupFrame (void)
} }
#define MAXALIASVERTS 1024 finalvert_t *finalverts;
auxvert_t *auxverts;
int maxaliasverts = 0;
void void
R_AliasDrawModel (alight_t *plighting) R_AliasDrawModel (alight_t *plighting)
{ {
finalvert_t finalverts[MAXALIASVERTS +
((CACHE_SIZE - 1) / sizeof (finalvert_t)) + 1];
auxvert_t auxverts[MAXALIASVERTS];
r_amodels_drawn++; r_amodels_drawn++;
paliashdr = Cache_Get (&currententity->model->cache);
pmdl = (mdl_t *) ((byte *) paliashdr + paliashdr->model);
if (pmdl->numverts > maxaliasverts)
{
finalverts = realloc (finalverts, (CACHE_SIZE - 1) +
sizeof (finalvert_t) * (pmdl->numverts + 1));
auxverts = realloc (auxverts,
sizeof (auxvert_t) * pmdl->numverts);
if (!finalverts || !auxverts)
Sys_Error ("R_AliasDrawModel: out of memory");
maxaliasverts = pmdl->numverts;
}
// cache align // cache align
pfinalverts = (finalvert_t *) pfinalverts = (finalvert_t *)
(((long) &finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1)); (((long) &finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
pauxverts = &auxverts[0]; pauxverts = &auxverts[0];
paliashdr = Cache_Get (&currententity->model->cache);
pmdl = (mdl_t *) ((byte *) paliashdr + paliashdr->model);
R_AliasSetupSkin (); R_AliasSetupSkin ();
R_AliasSetUpTransform (currententity->trivial_accept); R_AliasSetUpTransform (currententity->trivial_accept);
R_AliasSetupLighting (plighting); R_AliasSetupLighting (plighting);