[qw] Partially clean up muzzle flash handling

It needs some more work (see FIXME in the code).
This commit is contained in:
Bill Currie 2021-03-11 15:23:35 +09:00
parent ca38f9b616
commit 36761192a6
3 changed files with 38 additions and 35 deletions

View file

@ -30,6 +30,8 @@
#ifndef __client_effects_h #ifndef __client_effects_h
#define __client_effects_h #define __client_effects_h
#include "QF/simd/types.h"
struct entity_s; struct entity_s;
struct entity_state_s; struct entity_state_s;
@ -39,5 +41,7 @@ void CL_ModelEffects (struct entity_s *ent, int num, int glow_color,
double time); double time);
void CL_EntityEffects (int num, struct entity_s *ent, void CL_EntityEffects (int num, struct entity_s *ent,
struct entity_state_s *state, double time); struct entity_state_s *state, double time);
void CL_MuzzleFlash (vec4f_t position, vec4f_t fv, float zoffset, int num,
double time);
#endif//__client_effects_h #endif//__client_effects_h

View file

@ -148,28 +148,33 @@ CL_ModelEffects (entity_t *ent, int num, int glow_color, double time)
r_funcs->particles->R_GlowTrail (ent, glow_color); r_funcs->particles->R_GlowTrail (ent, glow_color);
} }
void
CL_MuzzleFlash (vec4f_t position, vec4f_t fv, float zoffset, int num,
double time)
{
dlight_t *dl = r_funcs->R_AllocDlight (num);
if (dl) {
position += 18 * fv;
VectorCopy (position, dl->origin);
dl->origin[2] += zoffset;
dl->radius = 200 + (rand () & 31);
dl->die = time + 0.1;
dl->minlight = 32;
dl->color[0] = 0.2;
dl->color[1] = 0.1;
dl->color[2] = 0.05;
dl->color[3] = 0.7;
}
}
void void
CL_EntityEffects (int num, entity_t *ent, entity_state_t *state, double time) CL_EntityEffects (int num, entity_t *ent, entity_state_t *state, double time)
{ {
dlight_t *dl;
if (state->effects & EF_BRIGHTFIELD) if (state->effects & EF_BRIGHTFIELD)
r_funcs->particles->R_EntityParticles (ent); r_funcs->particles->R_EntityParticles (ent);
if (state->effects & EF_MUZZLEFLASH) { if (state->effects & EF_MUZZLEFLASH) {
dl = r_funcs->R_AllocDlight (num); vec4f_t position = Transform_GetWorldPosition (ent->transform);
if (dl) { vec4f_t fv = Transform_Forward (ent->transform);
vec4f_t position = Transform_GetWorldPosition (ent->transform); CL_MuzzleFlash (position, fv, 16, num, time);
vec4f_t fv = Transform_Forward (ent->transform);
position += 18 * fv;
VectorCopy (position, dl->origin);
dl->origin[2] += 16;
dl->radius = 200 + (rand () & 31);
dl->die = time + 0.1;
dl->minlight = 32;
dl->color[0] = 0.2;
dl->color[1] = 0.1;
dl->color[2] = 0.05;
dl->color[3] = 0.7;
}
} }
} }

View file

@ -65,6 +65,7 @@
#include "clview.h" #include "clview.h"
#include "sbar.h" #include "sbar.h"
#include "client/effects.h"
#include "client/temp_entities.h" #include "client/temp_entities.h"
#include "qw/bothdefs.h" #include "qw/bothdefs.h"
@ -1255,12 +1256,14 @@ CL_SetStat (int stat, int value)
} }
static void static void
CL_MuzzleFlash (void) CL_ParseMuzzleFlash (void)
{ {
dlight_t *dl; //FIXME this should just enable the effect on the relevant entity and
//then automatic entity updates take care of the rest
int i; int i;
player_state_t *pl; player_state_t *pl;
vec3_t fv, rv, uv; vec3_t f, r, u;
vec4f_t position = { 0, 0, 0, 1}, fv = {};
i = MSG_ReadShort (net_message); i = MSG_ReadShort (net_message);
@ -1269,23 +1272,14 @@ CL_MuzzleFlash (void)
pl = &cl.frames[parsecountmod].playerstate[i - 1]; pl = &cl.frames[parsecountmod].playerstate[i - 1];
dl = r_funcs->R_AllocDlight (i);
if (!dl)
return;
if (i - 1 == cl.playernum) if (i - 1 == cl.playernum)
AngleVectors (cl.viewangles, fv, rv, uv); AngleVectors (cl.viewangles, f, r, u);
else else
AngleVectors (pl->viewangles, fv, rv, uv); AngleVectors (pl->viewangles, f, r, u);
VectorMultAdd (pl->pls.origin, 18, fv, dl->origin); VectorCopy (f, fv);
dl->radius = 200 + (rand () & 31); VectorCopy (pl->pls.es.origin, position);
dl->die = cl.time + 0.1; CL_MuzzleFlash (position, fv, 0, i, cl.time);
dl->minlight = 32;
dl->color[0] = 0.2;
dl->color[1] = 0.1;
dl->color[2] = 0.05;
dl->color[3] = 0.7;
} }
#define SHOWNET(x) \ #define SHOWNET(x) \
@ -1621,7 +1615,7 @@ CL_ParseServerMessage (void)
break; break;
case svc_muzzleflash: case svc_muzzleflash:
CL_MuzzleFlash (); CL_ParseMuzzleFlash ();
break; break;
case svc_updateuserinfo: case svc_updateuserinfo: