+
+ e->render.model = cl.model_precache[e->state_current.modelindex];
+ if (e->render.model)
+ {
+ Mod_CheckLoaded(e->render.model);
+ if (e->render.model->type == mod_alias || e->render.model->type == mod_sprite)
+ angles[0] = -angles[0];
+ if (e->render.model->flags & EF_ROTATE)
+ {
+ angles[1] = ANGLEMOD(100*cl.time);
+ if (cl_itembobheight.value)
+ origin[2] += (cos(cl.time * cl_itembobspeed.value * (2.0 * M_PI)) + 1.0) * 0.5 * cl_itembobheight.value;
+ }
+ }
+
+ R_LerpAnimation(&e->render);
+
+ // FIXME: e->render.scale should go away
+ Matrix4x4_CreateFromQuakeEntity(&matrix2, origin[0], origin[1], origin[2], angles[0], angles[1], angles[2], e->render.scale);
+ // concat the matrices to make the entity relative to its tag
+ Matrix4x4_Concat(&e->render.matrix, matrix, &matrix2);
+ // make the other useful stuff
+ Matrix4x4_Invert_Simple(&e->render.inversematrix, &e->render.matrix);
+ CL_BoundingBoxForEntity(&e->render);
+
+ // handle effects now that we know where this entity is in the world...
+ origin[0] = e->render.matrix.m[0][3];
+ origin[1] = e->render.matrix.m[1][3];
+ origin[2] = e->render.matrix.m[2][3];
+ trailtype = -1;
+ dlightcolor[0] = 0;
+ dlightcolor[1] = 0;
+ dlightcolor[2] = 0;
+ // LordHavoc: if the entity has no effects, don't check each
+ if (e->render.effects)
+ {
+ if (e->render.effects & EF_BRIGHTFIELD)
+ {
+ if (gamemode == GAME_NEXUIZ)
+ {
+ dlightcolor[0] += 100.0f;
+ dlightcolor[1] += 200.0f;
+ dlightcolor[2] += 400.0f;
+ trailtype = 8;
+ }
+ else
+ CL_EntityParticles(e);
+ }
+ if (e->render.effects & EF_MUZZLEFLASH)
+ e->persistent.muzzleflash = 100.0f;
+ if (e->render.effects & EF_DIMLIGHT)
+ {
+ dlightcolor[0] += 200.0f;
+ dlightcolor[1] += 200.0f;
+ dlightcolor[2] += 200.0f;
+ }
+ if (e->render.effects & EF_BRIGHTLIGHT)
+ {
+ dlightcolor[0] += 400.0f;
+ dlightcolor[1] += 400.0f;
+ dlightcolor[2] += 400.0f;
+ }
+ // LordHavoc: more effects
+ if (e->render.effects & EF_RED) // red
+ {
+ dlightcolor[0] += 200.0f;
+ dlightcolor[1] += 20.0f;
+ dlightcolor[2] += 20.0f;
+ }
+ if (e->render.effects & EF_BLUE) // blue
+ {
+ dlightcolor[0] += 20.0f;
+ dlightcolor[1] += 20.0f;
+ dlightcolor[2] += 200.0f;
+ }
+ if (e->render.effects & EF_FLAME)
+ {
+ mins[0] = origin[0] - 16.0f;
+ mins[1] = origin[1] - 16.0f;
+ mins[2] = origin[2] - 16.0f;
+ maxs[0] = origin[0] + 16.0f;
+ maxs[1] = origin[1] + 16.0f;
+ maxs[2] = origin[2] + 16.0f;
+ // how many flames to make
+ temp = (int) (cl.time * 300) - (int) (cl.oldtime * 300);
+ CL_FlameCube(mins, maxs, temp);
+ d = lhrandom(200, 250);
+ dlightcolor[0] += d * 1.0f;
+ dlightcolor[1] += d * 0.7f;
+ dlightcolor[2] += d * 0.3f;
+ }
+ if (e->render.effects & EF_STARDUST)
+ {
+ mins[0] = origin[0] - 16.0f;
+ mins[1] = origin[1] - 16.0f;
+ mins[2] = origin[2] - 16.0f;
+ maxs[0] = origin[0] + 16.0f;
+ maxs[1] = origin[1] + 16.0f;
+ maxs[2] = origin[2] + 16.0f;
+ // how many particles to make
+ temp = (int) (cl.time * 200) - (int) (cl.oldtime * 200);
+ CL_Stardust(mins, maxs, temp);
+ d = 100;
+ dlightcolor[0] += d * 1.0f;
+ dlightcolor[1] += d * 0.7f;
+ dlightcolor[2] += d * 0.3f;
+ }
+ }
+ // muzzleflash fades over time, and is offset a bit
+ if (e->persistent.muzzleflash > 0)
+ {
+ Matrix4x4_Transform(&e->render.matrix, muzzleflashorigin, v2);
+ CL_TraceLine(origin, v2, v, NULL, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_SKY);
+ CL_AllocDlight(NULL, v, e->persistent.muzzleflash, 1, 1, 1, 0, 0);
+ e->persistent.muzzleflash -= cl.frametime * 1000;
+ }
+ // LordHavoc: if the model has no flags, don't check each
+ if (e->render.model && e->render.model->flags)
+ {
+ if (e->render.model->flags & EF_GIB)
+ trailtype = 2;
+ else if (e->render.model->flags & EF_ZOMGIB)
+ trailtype = 4;
+ else if (e->render.model->flags & EF_TRACER)
+ {
+ trailtype = 3;
+ dlightcolor[0] += 0x10;
+ dlightcolor[1] += 0x40;
+ dlightcolor[2] += 0x10;
+ }
+ else if (e->render.model->flags & EF_TRACER2)
+ {
+ trailtype = 5;
+ dlightcolor[0] += 0x50;
+ dlightcolor[1] += 0x30;
+ dlightcolor[2] += 0x10;
+ }
+ else if (e->render.model->flags & EF_ROCKET)
+ {
+ trailtype = 0;
+ dlightcolor[0] += 200.0f;
+ dlightcolor[1] += 160.0f;
+ dlightcolor[2] += 80.0f;
+ }
+ else if (e->render.model->flags & EF_GRENADE)
+ {
+ // LordHavoc: e->render.alpha == -1 is for Nehahra dem compatibility (cigar smoke)
+ trailtype = e->render.alpha == -1 ? 7 : 1;
+ }
+ else if (e->render.model->flags & EF_TRACER3)
+ {
+ trailtype = 6;
+ dlightcolor[0] += 0x50;
+ dlightcolor[1] += 0x20;
+ dlightcolor[2] += 0x40;
+ }
+ }
+ // LordHavoc: customizable glow
+ if (e->state_current.glowsize)
+ {
+ // * 4 for the expansion from 0-255 to 0-1023 range,
+ // / 255 to scale down byte colors
+ VectorMA(dlightcolor, e->state_current.glowsize * (4.0f / 255.0f), (qbyte *)&palette_complete[e->state_current.glowcolor], dlightcolor);
+ }
+ // make the dlight
+ if ((dlightcolor[0] || dlightcolor[1] || dlightcolor[2]) && !(e->render.flags & RENDER_VIEWMODEL) && !e->state_current.tagentity)
+ {
+ VectorCopy(origin, v);
+ // hack to make glowing player light shine on their gun
+ if ((e - cl_entities) == cl.viewentity/* && !chase_active.integer*/)
+ v[2] += 30;
+ CL_AllocDlight(&e->render, v, 1, dlightcolor[0], dlightcolor[1], dlightcolor[2], 0, 0);
+ }
+ // trails need the previous frame
+ if (e->state_previous.active && e->state_previous.modelindex == e->state_current.modelindex)
+ {
+ if (e->render.flags & RENDER_GLOWTRAIL)
+ CL_RocketTrail2(e->persistent.trail_origin, origin, e->state_current.glowcolor, e);
+ else if (trailtype >= 0)
+ CL_RocketTrail(e->persistent.trail_origin, origin, trailtype, e);
+ }
+ VectorCopy(origin, e->persistent.trail_origin);
+ // note: the cl.viewentity and intermission check is to hide player
+ // shadow during intermission and during the Nehahra movie and
+ // Nehahra cinematics
+ if (!(e->render.effects & (EF_NOSHADOW | EF_ADDITIVE))
+ && (e->render.alpha == 1)
+ && !(e->render.flags & RENDER_VIEWMODEL)
+ && ((e - cl_entities) != cl.viewentity || (!cl.intermission && cl.protocol != PROTOCOL_NEHAHRAMOVIE && !cl_noplayershadow.integer)))
+ e->render.flags |= RENDER_SHADOW;
+ // as soon as player is known we can call V_CalcRefDef
+ if ((e - cl_entities) == cl.viewentity)
+ V_CalcRefdef();
+ if (e->render.model && e->render.model->name[0] == '*' && e->render.model->brush.TraceBox)
+ cl_brushmodel_entities[cl_num_brushmodel_entities++] = &e->render;
+ // don't show entities with no modelindex (note: this still shows
+ // entities which have a modelindex that resolved to a NULL model)
+ if (e->render.model && !(e->render.effects & EF_NODRAW) && r_refdef.numentities < r_refdef.maxentities)
+ r_refdef.entities[r_refdef.numentities++] = &e->render;
+ if (cl_num_entities < e->state_current.number + 1)
+ cl_num_entities = e->state_current.number + 1;