- // handle effects now that we know where this entity is in the world...
- if (e->render.model && e->render.model->soundfromcenter)
- {
- // bmodels are treated specially since their origin is usually '0 0 0'
- vec3_t o;
- VectorMAM(0.5f, e->render.model->normalmins, 0.5f, e->render.model->normalmaxs, o);
- Matrix4x4_Transform(&e->render.matrix, o, origin);
- }
- else
- Matrix4x4_OriginFromMatrix(&e->render.matrix, origin);
- trailtype = EFFECT_NONE;
- dlightradius = 0;
- 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)
- trailtype = EFFECT_TR_NEXUIZPLASMA;
- else
- CL_EntityParticles(e);
- }
- if (e->render.effects & EF_MUZZLEFLASH)
- e->persistent.muzzleflash = 1.0f;
- if (e->render.effects & EF_DIMLIGHT)
- {
- dlightradius = max(dlightradius, 200);
- dlightcolor[0] += 1.50f;
- dlightcolor[1] += 1.50f;
- dlightcolor[2] += 1.50f;
- }
- if (e->render.effects & EF_BRIGHTLIGHT)
- {
- dlightradius = max(dlightradius, 400);
- dlightcolor[0] += 3.00f;
- dlightcolor[1] += 3.00f;
- dlightcolor[2] += 3.00f;
- }
- // LordHavoc: more effects
- if (e->render.effects & EF_RED) // red
- {
- dlightradius = max(dlightradius, 200);
- dlightcolor[0] += 1.50f;
- dlightcolor[1] += 0.15f;
- dlightcolor[2] += 0.15f;
- }
- if (e->render.effects & EF_BLUE) // blue
- {
- dlightradius = max(dlightradius, 200);
- dlightcolor[0] += 0.15f;
- dlightcolor[1] += 0.15f;
- dlightcolor[2] += 1.50f;
- }
- if (e->render.effects & EF_FLAME)
- CL_ParticleEffect(EFFECT_EF_FLAME, cl.time - cl.oldtime, origin, origin, vec3_origin, vec3_origin, NULL, 0);
- if (e->render.effects & EF_STARDUST)
- CL_ParticleEffect(EFFECT_EF_STARDUST, cl.time - cl.oldtime, origin, origin, vec3_origin, vec3_origin, NULL, 0);
- if (e->render.effects & (EF_FLAG1QW | EF_FLAG2QW))
- {
- // these are only set on player entities
- CL_AddQWCTFFlagModel(e, (e->render.effects & EF_FLAG2QW) != 0);
- }
- }
- // muzzleflash fades over time, and is offset a bit
- if (e->persistent.muzzleflash > 0)
- {
- Matrix4x4_Transform(&e->render.matrix, muzzleflashorigin, v2);
- trace = CL_TraceBox(origin, vec3_origin, vec3_origin, v2, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_SKY, false);
- tempmatrix = e->render.matrix;
- Matrix4x4_SetOrigin(&tempmatrix, trace.endpos[0], trace.endpos[1], trace.endpos[2]);
- CL_AllocDlight(NULL, &tempmatrix, 100, e->persistent.muzzleflash, e->persistent.muzzleflash, e->persistent.muzzleflash, 0, 0, 0, -1, true, 0, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
- e->persistent.muzzleflash -= (cl.time - cl.oldtime) * 10;
- }
- // LordHavoc: if the model has no flags, don't check each
- if (e->render.model && e->render.model->flags && (!e->state_current.tagentity && !(e->render.flags & RENDER_VIEWMODEL)))
- {
- if (e->render.model->flags & EF_GIB)
- trailtype = EFFECT_TR_BLOOD;
- else if (e->render.model->flags & EF_ZOMGIB)
- trailtype = EFFECT_TR_SLIGHTBLOOD;
- else if (e->render.model->flags & EF_TRACER)
- trailtype = EFFECT_TR_WIZSPIKE;
- else if (e->render.model->flags & EF_TRACER2)
- trailtype = EFFECT_TR_KNIGHTSPIKE;
- else if (e->render.model->flags & EF_ROCKET)
- trailtype = EFFECT_TR_ROCKET;
- 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 ? EFFECT_TR_NEHAHRASMOKE : EFFECT_TR_GRENADE;
- }
- else if (e->render.model->flags & EF_TRACER3)
- trailtype = EFFECT_TR_VORESPIKE;
- }
- // 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
- dlightradius = max(dlightradius, e->state_current.glowsize * 4);
- VectorMA(dlightcolor, (1.0f / 255.0f), (unsigned char *)&palette_complete[e->state_current.glowcolor], dlightcolor);
- }
- // make the glow dlight
- if (dlightradius > 0 && (dlightcolor[0] || dlightcolor[1] || dlightcolor[2]) && !(e->render.flags & RENDER_VIEWMODEL))
+ // make the other useful stuff
+ CL_UpdateRenderEntity(&e->render);
+
+ // tenebrae's sprites are all additive mode (weird)
+ if (gamemode == GAME_TENEBRAE && e->render.model && e->render.model->type == mod_sprite)
+ e->render.effects |= EF_ADDITIVE;
+ // player model is only shown with chase_active on
+ if (e->state_current.number == cl.viewentity)
+ e->render.flags |= RENDER_EXTERIORMODEL;
+ // transparent stuff can't be lit during the opaque stage
+ if (e->render.effects & (EF_ADDITIVE | EF_NODEPTHTEST) || e->render.alpha < 1)
+ e->render.flags |= RENDER_TRANSPARENT;
+ // double sided rendering mode causes backfaces to be visible
+ // (mostly useful on transparent stuff)
+ if (e->render.effects & EF_DOUBLESIDED)
+ e->render.flags |= RENDER_NOCULLFACE;
+ // either fullbright or lit
+ if (!(e->render.effects & EF_FULLBRIGHT) && !r_fullbright.integer)
+ e->render.flags |= RENDER_LIGHT;
+ // hide player shadow during intermission or nehahra movie
+ if (!(e->render.effects & EF_NOSHADOW)
+ && !(e->render.flags & (RENDER_VIEWMODEL | RENDER_TRANSPARENT))
+ && (!(e->render.flags & RENDER_EXTERIORMODEL) || (!cl.intermission && cls.protocol != PROTOCOL_NEHAHRAMOVIE && !cl_noplayershadow.integer)))
+ e->render.flags |= RENDER_SHADOW;
+}
+
+// creates light and trails from an entity
+void CL_UpdateNetworkEntityTrail(entity_t *e)
+{
+ effectnameindex_t trailtype;
+ vec3_t origin;
+
+ // bmodels are treated specially since their origin is usually '0 0 0' and
+ // their actual geometry is far from '0 0 0'
+ if (e->render.model && e->render.model->soundfromcenter)
+ {
+ vec3_t o;
+ VectorMAM(0.5f, e->render.model->normalmins, 0.5f, e->render.model->normalmaxs, o);
+ Matrix4x4_Transform(&e->render.matrix, o, origin);
+ }
+ else
+ Matrix4x4_OriginFromMatrix(&e->render.matrix, origin);
+
+ // handle particle trails and such effects now that we know where this
+ // entity is in the world...
+ trailtype = EFFECT_NONE;
+ // LordHavoc: if the entity has no effects, don't check each
+ if (e->render.effects & (EF_BRIGHTFIELD | EF_FLAME | EF_STARDUST | EF_FLAG1QW | EF_FLAG2QW))
+ {
+ if (e->render.effects & EF_BRIGHTFIELD)