Eliminate MAX_VISEDICTS. Unlimited visible entities.

The renderer can now render as many entities as can be crammed into the
currently visible set of nodes.
This commit is contained in:
Bill Currie 2010-12-03 14:54:39 +09:00
parent abe0c50a2a
commit a6941e27ef
9 changed files with 58 additions and 61 deletions

View file

@ -74,6 +74,8 @@ extern lightstyle_t r_lightstyle[MAX_LIGHTSTYLES];
typedef struct entity_s {
struct entity_s *next;
vec3_t origin;
vec3_t old_origin;
vec3_t angles;
@ -199,7 +201,7 @@ void R_LoadSkys (const char *);
void R_ClearEfrags (void);
void R_ClearEnts (void);
struct entity_s **R_NewEntity (void);
void R_EnqueueEntity (struct entity_s *ent);
dlight_t *R_AllocDlight (int key);
void R_DecayLights (double frametime);

View file

@ -306,8 +306,7 @@ extern int r_clipflags;
extern int r_dlightframecount;
extern qboolean r_fov_greater_than_90;
extern int r_numvisedicts;
extern struct entity_s *r_visedicts[];
extern struct entity_s *r_ent_queue;
struct dlight_s;
void R_StoreEfrags (const efrag_t *ppefrag);

View file

@ -533,6 +533,7 @@ gl_overbright_f (cvar_t *var)
int num, i, j;
model_t *m;
msurface_t *fa;
entity_t *ent;
if (!var)
return;
@ -578,8 +579,8 @@ gl_overbright_f (cvar_t *var)
if (!R_BuildLightMap)
return;
for (i = 0; i < r_numvisedicts; i++) {
m = r_visedicts[i]->model;
for (ent = r_ent_queue; ent; ent = ent->next) {
m = ent->model;
if (m->type != mod_brush)
continue;

View file

@ -219,16 +219,16 @@ R_RotateForEntity (entity_t *e)
static void
R_DrawEntitiesOnList (void)
{
int i;
entity_t *ent;
if (!r_drawentities->int_val)
return;
// LordHavoc: split into 3 loops to simplify state changes
for (i = 0; i < r_numvisedicts; i++) {
if (r_visedicts[i]->model->type != mod_brush)
for (ent = r_ent_queue; ent; ent = ent->next) {
if (ent->model->type != mod_brush)
continue;
currententity = r_visedicts[i];
currententity = ent;
R_DrawBrushModel (currententity);
}
@ -253,10 +253,10 @@ R_DrawEntitiesOnList (void)
qfglEnable (GL_NORMALIZE);
}
for (i = 0; i < r_numvisedicts; i++) {
if (r_visedicts[i]->model->type != mod_alias)
for (ent = r_ent_queue; ent; ent = ent->next) {
if (ent->model->type != mod_alias)
continue;
currententity = r_visedicts[i];
currententity = ent;
R_DrawAliasModel (currententity);
}
@ -289,10 +289,10 @@ R_DrawEntitiesOnList (void)
qfglEnable (GL_ALPHA_TEST);
if (gl_va_capable)
qfglInterleavedArrays (GL_T2F_C4UB_V3F, 0, spriteVertexArray);
for (i = 0; i < r_numvisedicts; i++) {
if (r_visedicts[i]->model->type != mod_sprite)
for (ent = r_ent_queue; ent; ent = ent->next) {
if (ent->model->type != mod_sprite)
continue;
currententity = r_visedicts[i];
currententity = ent;
R_DrawSpriteModel (currententity);
}
@ -540,7 +540,6 @@ static void
R_Mirror (void)
{
float d;
entity_t **ent;
msurface_t *s;
// if (!mirror) // FIXME: Broken
@ -560,9 +559,7 @@ R_Mirror (void)
r_refdef.viewangles[1] = atan2 (vpn[1], vpn[0]) / M_PI * 180;
r_refdef.viewangles[2] = -r_refdef.viewangles[2];
ent = R_NewEntity();
if (ent)
*ent = r_player_entity;
R_EnqueueEntity (r_player_entity);
gldepthmin = 0.5;
gldepthmax = 1;

View file

@ -232,11 +232,7 @@ R_StoreEfrags (const efrag_t *pefrag)
pent = pefrag->entity;
if (pent->visframe != r_framecount) {
entity_t **ent = R_NewEntity ();
if (!ent)
return;
*ent = pent;
R_EnqueueEntity (pent);
// mark that we've recorded this entity for this frame
pent->visframe = r_framecount;
}

View file

@ -49,22 +49,20 @@ static __attribute__ ((used)) const char rcsid[] =
#include "r_dynamic.h"
#define MAX_VISEDICTS 256
int r_numvisedicts;
entity_t *r_visedicts[MAX_VISEDICTS];
entity_t *r_ent_queue;
static entity_t **vis_tail = &r_ent_queue;
void
R_ClearEnts (void)
{
r_numvisedicts = 0;
r_ent_queue = 0;
vis_tail = &r_ent_queue;
}
entity_t **
R_NewEntity (void)
void
R_EnqueueEntity (entity_t *ent)
{
if (r_numvisedicts == MAX_VISEDICTS)
return NULL;
return &r_visedicts[r_numvisedicts++];
ent->next = 0;
*vis_tail = ent;
vis_tail = &ent->next;
}

View file

@ -409,9 +409,10 @@ R_MarkLeaves (void)
static void
R_DrawEntitiesOnList (void)
{
int i, j;
int j;
unsigned int lnum;
alight_t lighting;
entity_t *ent;
// FIXME: remove and do real lighting
float lightvec[3] = { -1, 0, 0 };
@ -422,8 +423,8 @@ R_DrawEntitiesOnList (void)
if (!r_drawentities->int_val)
return;
for (i = 0; i < r_numvisedicts; i++) {
currententity = r_visedicts[i];
for (ent = r_ent_queue; ent; ent = ent->next) {
currententity = ent;
switch (currententity->model->type) {
case mod_sprite:
@ -595,11 +596,12 @@ R_BmodelCheckBBox (model_t *clmodel, float *minmaxs)
static void
R_DrawBEntitiesOnList (void)
{
int i, j, clipflags;
int j, clipflags;
unsigned int k;
vec3_t oldorigin;
model_t *clmodel;
float minmaxs[6];
entity_t *ent;
if (!r_drawentities->int_val)
return;
@ -607,8 +609,8 @@ R_DrawBEntitiesOnList (void)
VectorCopy (modelorg, oldorigin);
insubmodel = true;
for (i = 0; i < r_numvisedicts; i++) {
currententity = r_visedicts[i];
for (ent = r_ent_queue; ent; ent = ent->next) {
currententity = ent;
switch (currententity->model->type) {
case mod_brush:

View file

@ -429,9 +429,10 @@ R_MarkLeaves (void)
static void
R_DrawEntitiesOnList (void)
{
int i, j;
int j;
unsigned int lnum;
alight_t lighting;
entity_t *ent;
// FIXME: remove and do real lighting
float lightvec[3] = { -1, 0, 0 };
@ -442,8 +443,8 @@ R_DrawEntitiesOnList (void)
if (!r_drawentities->int_val)
return;
for (i = 0; i < r_numvisedicts; i++) {
currententity = r_visedicts[i];
for (ent = r_ent_queue; ent; ent = ent->next) {
currententity = ent;
switch (currententity->model->type) {
case mod_sprite:
@ -614,11 +615,12 @@ R_BmodelCheckBBox (model_t *clmodel, float *minmaxs)
static void
R_DrawBEntitiesOnList (void)
{
int i, j, clipflags;
int j, clipflags;
unsigned int k;
vec3_t oldorigin;
model_t *clmodel;
float minmaxs[6];
entity_t *ent;
if (!r_drawentities->int_val)
return;
@ -626,8 +628,8 @@ R_DrawBEntitiesOnList (void)
VectorCopy (modelorg, oldorigin);
insubmodel = true;
for (i = 0; i < r_numvisedicts; i++) {
currententity = r_visedicts[i];
for (ent = r_ent_queue; ent; ent = ent->next) {
currententity = ent;
switch (currententity->model->type) {
case mod_brush:

View file

@ -769,8 +769,7 @@ CL_AddFlagModels (entity_t *ent, int team, int key)
16.0, 24.0, 24.0, 22.0, 18.0, 16.0, // 35-40 pain
};
float f;
int i;
entity_t **newent;
entity_t *fent;
vec3_t v_forward, v_right, v_up;
if (cl_flagindex == -1)
@ -786,21 +785,22 @@ CL_AddFlagModels (entity_t *ent, int team, int key)
f = 21.0; // 112-118 shotattack
}
newent = R_NewEntity ();
if (!newent)
return;
*newent = &cl_flag_ents[key];
(*newent)->model = cl.model_precache[cl_flagindex];
(*newent)->skinnum = team;
fent = &cl_flag_ents[key];
fent->model = cl.model_precache[cl_flagindex];
fent->skinnum = team;
AngleVectors (ent->angles, v_forward, v_right, v_up);
v_forward[2] = -v_forward[2]; // reverse z component
for (i = 0; i < 3; i++)
(*newent)->origin[i] = ent->origin[i] - f * v_forward[i] +
22.0 * v_right[i];
(*newent)->origin[2] -= 16.0;
VectorCopy (ent->angles, (*newent)->angles);
(*newent)->angles[2] -= 45.0;
VectorMultAdd (ent->origin, -f, v_forward, fent->origin);
VectorMultAdd (fent->origin, 22, v_right, fent->origin);
fent->origin[2] -= 16.0;
VectorCopy (ent->angles, fent->angles);
fent->angles[2] -= 45.0;
R_EnqueueEntity (fent); //FIXME should use efrag (needs smarter handling
//in the player code)
}
/*