cl.num_entities = 0;
cl.num_static_entities = 0;
- cl.num_temp_entities = 0;
cl.num_brushmodel_entities = 0;
// tweak these if the game runs out
cl.max_entities = 256;
cl.max_static_entities = 256;
- cl.max_temp_entities = 512;
cl.max_effects = 256;
cl.max_beams = 256;
cl.max_dlights = MAX_DLIGHTS;
cl.entities = (entity_t *)Mem_Alloc(cls.levelmempool, cl.max_entities * sizeof(entity_t));
cl.entities_active = (unsigned char *)Mem_Alloc(cls.levelmempool, cl.max_brushmodel_entities * sizeof(unsigned char));
cl.static_entities = (entity_t *)Mem_Alloc(cls.levelmempool, cl.max_static_entities * sizeof(entity_t));
- cl.temp_entities = (entity_t *)Mem_Alloc(cls.levelmempool, cl.max_temp_entities * sizeof(entity_t));
cl.effects = (cl_effect_t *)Mem_Alloc(cls.levelmempool, cl.max_effects * sizeof(cl_effect_t));
cl.beams = (beam_t *)Mem_Alloc(cls.levelmempool, cl.max_beams * sizeof(beam_t));
cl.dlights = (dlight_t *)Mem_Alloc(cls.levelmempool, cl.max_dlights * sizeof(dlight_t));
void CL_ClearTempEntities (void)
{
- cl.num_temp_entities = 0;
+ r_refdef.numtempentities = 0;
}
-entity_t *CL_NewTempEntity(void)
+entity_render_t *CL_NewTempEntity(void)
{
- entity_t *ent;
+ entity_render_t *render;
if (r_refdef.numentities >= r_refdef.maxentities)
return NULL;
- if (cl.num_temp_entities >= cl.max_temp_entities)
+ if (r_refdef.numtempentities >= r_refdef.maxtempentities)
return NULL;
- ent = &cl.temp_entities[cl.num_temp_entities++];
- memset (ent, 0, sizeof(*ent));
- r_refdef.entities[r_refdef.numentities++] = &ent->render;
+ render = &r_refdef.tempentities[r_refdef.numtempentities++];
+ memset (render, 0, sizeof(*render));
+ r_refdef.entities[r_refdef.numentities++] = render;
- ent->render.alpha = 1;
- VectorSet(ent->render.colormod, 1, 1, 1);
- return ent;
+ render->alpha = 1;
+ VectorSet(render->colormod, 1, 1, 1);
+ return render;
}
void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float framerate)
void CL_AddQWCTFFlagModel(entity_t *player, int skin)
{
float f;
- entity_t *flag;
+ entity_render_t *flagrender;
matrix4x4_t flagmatrix;
// this code taken from QuakeWorld
}
// end of code taken from QuakeWorld
- flag = CL_NewTempEntity();
- if (!flag)
+ flagrender = CL_NewTempEntity();
+ if (!flagrender)
return;
- flag->render.model = cl.model_precache[cl.qw_modelindex_flag];
- flag->render.skinnum = skin;
- flag->render.alpha = 1;
- VectorSet(flag->render.colormod, 1, 1, 1);
+ flagrender->model = cl.model_precache[cl.qw_modelindex_flag];
+ flagrender->skinnum = skin;
+ flagrender->alpha = 1;
+ VectorSet(flagrender->colormod, 1, 1, 1);
// attach the flag to the player matrix
Matrix4x4_CreateFromQuakeEntity(&flagmatrix, -f, -22, 0, 0, 0, -45, 1);
- Matrix4x4_Concat(&flag->render.matrix, &player->render.matrix, &flagmatrix);
- CL_UpdateRenderEntity(&flag->render);
+ Matrix4x4_Concat(&flagrender->matrix, &player->render.matrix, &flagmatrix);
+ CL_UpdateRenderEntity(flagrender);
}
matrix4x4_t viewmodelmatrix;
{
int i, intframe;
cl_effect_t *e;
- entity_t *ent;
+ entity_render_t *entrender;
float frame;
for (i = 0, e = cl.effects;i < cl.num_effects;i++, e++)
// if we're drawing effects, get a new temp entity
// (NewTempEntity adds it to the render entities list for us)
- if (r_draweffects.integer && (ent = CL_NewTempEntity()))
+ if (r_draweffects.integer && (entrender = CL_NewTempEntity()))
{
// interpolation stuff
- ent->render.frame1 = intframe;
- ent->render.frame2 = intframe + 1;
- if (ent->render.frame2 >= e->endframe)
- ent->render.frame2 = -1; // disappear
- ent->render.framelerp = frame - intframe;
- ent->render.frame1time = e->frame1time;
- ent->render.frame2time = e->frame2time;
+ entrender->frame1 = intframe;
+ entrender->frame2 = intframe + 1;
+ if (entrender->frame2 >= e->endframe)
+ entrender->frame2 = -1; // disappear
+ entrender->framelerp = frame - intframe;
+ entrender->frame1time = e->frame1time;
+ entrender->frame2time = e->frame2time;
// normal stuff
if(e->modelindex < MAX_MODELS)
- ent->render.model = cl.model_precache[e->modelindex];
+ entrender->model = cl.model_precache[e->modelindex];
else
- ent->render.model = cl.csqc_model_precache[-(e->modelindex+1)];
- ent->render.alpha = 1;
- VectorSet(ent->render.colormod, 1, 1, 1);
+ entrender->model = cl.csqc_model_precache[-(e->modelindex+1)];
+ entrender->alpha = 1;
+ VectorSet(entrender->colormod, 1, 1, 1);
- Matrix4x4_CreateFromQuakeEntity(&ent->render.matrix, e->origin[0], e->origin[1], e->origin[2], 0, 0, 0, 1);
- CL_UpdateRenderEntity(&ent->render);
+ Matrix4x4_CreateFromQuakeEntity(&entrender->matrix, e->origin[0], e->origin[1], e->origin[2], 0, 0, 0, 1);
+ CL_UpdateRenderEntity(entrender);
}
}
}
beam_t *b;
vec3_t dist, org, start, end;
float d;
- entity_t *ent;
+ entity_render_t *entrender;
double yaw, pitch;
float forward;
matrix4x4_t tempmatrix;
d = VectorNormalizeLength(dist);
while (d > 0)
{
- ent = CL_NewTempEntity ();
- if (!ent)
+ entrender = CL_NewTempEntity ();
+ if (!entrender)
return;
//VectorCopy (org, ent->render.origin);
- ent->render.model = b->model;
+ entrender->model = b->model;
//ent->render.effects = EF_FULLBRIGHT;
//ent->render.angles[0] = pitch;
//ent->render.angles[1] = yaw;
//ent->render.angles[2] = rand()%360;
- Matrix4x4_CreateFromQuakeEntity(&ent->render.matrix, org[0], org[1], org[2], -pitch, yaw, lhrandom(0, 360), 1);
- CL_UpdateRenderEntity(&ent->render);
+ Matrix4x4_CreateFromQuakeEntity(&entrender->matrix, org[0], org[1], org[2], -pitch, yaw, lhrandom(0, 360), 1);
+ CL_UpdateRenderEntity(entrender);
VectorMA(org, 30, dist, org);
d -= 30;
}
{
int i;
vec_t *v;
- entity_t *ent;
+ entity_render_t *entrender;
for (i = 0;i < cl.qw_num_nails;i++)
{
// if we're drawing effects, get a new temp entity
// (NewTempEntity adds it to the render entities list for us)
- if (!(ent = CL_NewTempEntity()))
+ if (!(entrender = CL_NewTempEntity()))
continue;
// normal stuff
- ent->render.model = cl.model_precache[cl.qw_modelindex_spike];
- ent->render.alpha = 1;
- VectorSet(ent->render.colormod, 1, 1, 1);
+ entrender->model = cl.model_precache[cl.qw_modelindex_spike];
+ entrender->alpha = 1;
+ VectorSet(entrender->colormod, 1, 1, 1);
- Matrix4x4_CreateFromQuakeEntity(&ent->render.matrix, v[0], v[1], v[2], v[3], v[4], v[5], 1);
- CL_UpdateRenderEntity(&ent->render);
+ Matrix4x4_CreateFromQuakeEntity(&entrender->matrix, v[0], v[1], v[2], v[3], v[4], v[5], 1);
+ CL_UpdateRenderEntity(entrender);
}
}
r_refdef.maxentities = MAX_EDICTS + 256 + 512;
r_refdef.entities = (entity_render_t **)Mem_Alloc(cls.permanentmempool, sizeof(entity_render_t *) * r_refdef.maxentities);
+ r_refdef.maxtempentities = 512;
+ r_refdef.tempentities = (entity_render_t *)Mem_Alloc(cls.permanentmempool, sizeof(entity_render_t) * r_refdef.maxtempentities);
+
CL_InitInput ();
//
int c;
float scale;
prvm_eval_t *val;
- entity_t *e;
+ entity_render_t *entrender;
model_t *model;
matrix4x4_t tagmatrix, matrix2;
if (!model)
return false;
- e = CL_NewTempEntity();
- if (!e)
+ entrender = CL_NewTempEntity();
+ if (!entrender)
return false;
- e->render.model = model;
- e->render.skinnum = (int)ed->fields.client->skin;
- e->render.effects |= e->render.model->effects;
+ entrender->model = model;
+ entrender->skinnum = (int)ed->fields.client->skin;
+ entrender->effects |= entrender->model->effects;
scale = 1;
renderflags = 0;
if((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.renderflags)) && val->_float) renderflags = (int)val->_float;
- if((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.alpha)) && val->_float) e->render.alpha = val->_float;
- if((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.scale)) && val->_float) e->render.scale = scale = val->_float;
- if((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.colormod)) && VectorLength2(val->vector)) VectorCopy(val->vector, e->render.colormod);
- if((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.effects)) && val->_float) e->render.effects |= (int)val->_float;
+ if((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.alpha)) && val->_float) entrender->alpha = val->_float;
+ if((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.scale)) && val->_float) entrender->scale = scale = val->_float;
+ if((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.colormod)) && VectorLength2(val->vector)) VectorCopy(val->vector, entrender->colormod);
+ if((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.effects)) && val->_float) entrender->effects |= (int)val->_float;
if((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.tag_entity)) && val->edict)
{
int tagentity;
vec3_t angles;
VectorCopy(ed->fields.client->angles, angles);
// if model is alias, reverse pitch direction
- if (e->render.model->type == mod_alias)
+ if (entrender->model->type == mod_alias)
angles[0] = -angles[0];
// set up the render matrix
// self.frame1time is the animation base time for the interpolation target
// self.frame2 is the interpolation start (previous frame)
// self.frame2time is the animation base time for the interpolation start
- e->render.frame1 = e->render.frame2 = ed->fields.client->frame;
- if ((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.frame2))) e->render.frame2 = val->_float;
- if ((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.frame1time))) e->render.frame2time = val->_float;
- if ((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.frame2time))) e->render.frame1time = val->_float;
- if ((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.lerpfrac))) e->render.framelerp = val->_float;
+ entrender->frame1 = entrender->frame2 = ed->fields.client->frame;
+ if ((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.frame2))) entrender->frame2 = val->_float;
+ if ((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.frame1time))) entrender->frame2time = val->_float;
+ if ((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.frame2time))) entrender->frame1time = val->_float;
+ if ((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.lerpfrac))) entrender->framelerp = val->_float;
// concat the matrices to make the entity relative to its tag
- Matrix4x4_Concat(&e->render.matrix, &tagmatrix, &matrix2);
+ Matrix4x4_Concat(&entrender->matrix, &tagmatrix, &matrix2);
if(renderflags)
{
- if(renderflags & RF_VIEWMODEL) e->render.flags |= RENDER_VIEWMODEL;
- if(renderflags & RF_EXTERNALMODEL)e->render.flags |= RENDER_EXTERIORMODEL;
- if(renderflags & RF_DEPTHHACK) e->render.effects |= EF_NODEPTHTEST;
- if(renderflags & RF_ADDITIVE) e->render.effects |= EF_ADDITIVE;
+ if(renderflags & RF_VIEWMODEL) entrender->flags |= RENDER_VIEWMODEL;
+ if(renderflags & RF_EXTERNALMODEL)entrender->flags |= RENDER_EXTERIORMODEL;
+ if(renderflags & RF_DEPTHHACK) entrender->effects |= EF_NODEPTHTEST;
+ if(renderflags & RF_ADDITIVE) entrender->effects |= EF_ADDITIVE;
}
c = (int)ed->fields.client->colormap;
if (c <= 0)
- CL_SetEntityColormapColors(&e->render, -1);
+ CL_SetEntityColormapColors(entrender, -1);
else if (c <= cl.maxclients && cl.scores != NULL)
- CL_SetEntityColormapColors(&e->render, cl.scores[c-1].colors);
+ CL_SetEntityColormapColors(entrender, cl.scores[c-1].colors);
else
- CL_SetEntityColormapColors(&e->render, c);
+ CL_SetEntityColormapColors(entrender, c);
// either fullbright or lit
- if (!(e->render.effects & EF_FULLBRIGHT) && !r_fullbright.integer)
- e->render.flags |= RENDER_LIGHT;
+ if (!(entrender->effects & EF_FULLBRIGHT) && !r_fullbright.integer)
+ entrender->flags |= RENDER_LIGHT;
// hide player shadow during intermission or nehahra movie
- if (!(e->render.effects & (EF_NOSHADOW | EF_ADDITIVE | EF_NODEPTHTEST))
- && (e->render.alpha >= 1)
- && !(e->render.flags & RENDER_VIEWMODEL)
- && (!(e->render.flags & RENDER_EXTERIORMODEL) || (!cl.intermission && cls.protocol != PROTOCOL_NEHAHRAMOVIE && !cl_noplayershadow.integer)))
- e->render.flags |= RENDER_SHADOW;
- if (e->render.flags & RENDER_VIEWMODEL)
- e->render.flags |= RENDER_NOSELFSHADOW;
+ if (!(entrender->effects & (EF_NOSHADOW | EF_ADDITIVE | EF_NODEPTHTEST))
+ && (entrender->alpha >= 1)
+ && !(entrender->flags & RENDER_VIEWMODEL)
+ && (!(entrender->flags & RENDER_EXTERIORMODEL) || (!cl.intermission && cls.protocol != PROTOCOL_NEHAHRAMOVIE && !cl_noplayershadow.integer)))
+ entrender->flags |= RENDER_SHADOW;
+ if (entrender->flags & RENDER_VIEWMODEL)
+ entrender->flags |= RENDER_NOSELFSHADOW;
// make the other useful stuff
- CL_UpdateRenderEntity(&e->render);
+ CL_UpdateRenderEntity(entrender);
return true;
}