mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
no more hardcoded MAXALIASVERTS limit
This commit is contained in:
parent
cb6ef3e225
commit
1e57bcdca2
2 changed files with 40 additions and 16 deletions
|
@ -40,6 +40,8 @@ static const char rcsid[] =
|
|||
#include "d_ifacea.h"
|
||||
#include "r_local.h"
|
||||
|
||||
#include "stdlib.h"
|
||||
|
||||
#define LIGHT_MIN 5 // lowest light value we'll allow, to
|
||||
// avoid the need for inner-loop light
|
||||
// clamping
|
||||
|
@ -667,24 +669,34 @@ R_AliasSetupFrame (void)
|
|||
((byte *) paliashdr + paliasgroup->frames[i].frame);
|
||||
}
|
||||
|
||||
#define MAXALIASVERTS 1024
|
||||
finalvert_t *finalverts;
|
||||
auxvert_t *auxverts;
|
||||
int maxaliasverts = 0;
|
||||
|
||||
void
|
||||
R_AliasDrawModel (alight_t *plighting)
|
||||
{
|
||||
finalvert_t finalverts[MAXALIASVERTS +
|
||||
((CACHE_SIZE - 1) / sizeof (finalvert_t)) + 1];
|
||||
auxvert_t auxverts[MAXALIASVERTS];
|
||||
|
||||
r_amodels_drawn++;
|
||||
|
||||
paliashdr = Cache_Get (¤tentity->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
|
||||
pfinalverts = (finalvert_t *)
|
||||
(((long) &finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
|
||||
pauxverts = &auxverts[0];
|
||||
|
||||
paliashdr = Cache_Get (¤tentity->model->cache);
|
||||
pmdl = (mdl_t *) ((byte *) paliashdr + paliashdr->model);
|
||||
|
||||
R_AliasSetupSkin ();
|
||||
R_AliasSetUpTransform (currententity->trivial_accept);
|
||||
R_AliasSetupLighting (plighting);
|
||||
|
|
|
@ -40,6 +40,8 @@ static const char rcsid[] =
|
|||
#include "d_ifacea.h"
|
||||
#include "r_local.h"
|
||||
|
||||
#include "stdlib.h"
|
||||
|
||||
#define LIGHT_MIN 5 // lowest light value we'll allow, to
|
||||
// avoid the need for inner-loop light
|
||||
// clamping
|
||||
|
@ -659,24 +661,34 @@ R_AliasSetupFrame (void)
|
|||
}
|
||||
|
||||
|
||||
#define MAXALIASVERTS 1024
|
||||
finalvert_t *finalverts;
|
||||
auxvert_t *auxverts;
|
||||
int maxaliasverts = 0;
|
||||
|
||||
void
|
||||
R_AliasDrawModel (alight_t *plighting)
|
||||
{
|
||||
finalvert_t finalverts[MAXALIASVERTS +
|
||||
((CACHE_SIZE - 1) / sizeof (finalvert_t)) + 1];
|
||||
auxvert_t auxverts[MAXALIASVERTS];
|
||||
|
||||
r_amodels_drawn++;
|
||||
|
||||
paliashdr = Cache_Get (¤tentity->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
|
||||
pfinalverts = (finalvert_t *)
|
||||
(((long) &finalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
|
||||
pauxverts = &auxverts[0];
|
||||
|
||||
paliashdr = Cache_Get (¤tentity->model->cache);
|
||||
pmdl = (mdl_t *) ((byte *) paliashdr + paliashdr->model);
|
||||
|
||||
R_AliasSetupSkin ();
|
||||
R_AliasSetUpTransform (currententity->trivial_accept);
|
||||
R_AliasSetupLighting (plighting);
|
||||
|
|
Loading…
Reference in a new issue