cl_truelightning fixed (rid# 1214349)

cl_beam_trace added to avoid traces with particle effects/truelightning


git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1260 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2005-08-27 23:28:39 +00:00
parent b2494e4bc6
commit 9b2c9c63c8
2 changed files with 76 additions and 28 deletions

View file

@ -177,6 +177,7 @@ sfx_t *cl_sfx_r_exp3;
cvar_t cl_expsprite = {"cl_expsprite", "0"}; cvar_t cl_expsprite = {"cl_expsprite", "0"};
cvar_t r_explosionlight = {"r_explosionlight", "1"}; cvar_t r_explosionlight = {"r_explosionlight", "1"};
cvar_t cl_truelightning = {"cl_truelightning", "0", NULL, CVAR_SEMICHEAT}; cvar_t cl_truelightning = {"cl_truelightning", "0", NULL, CVAR_SEMICHEAT};
cvar_t cl_beam_trace = {"cl_beam_trace", "0"};
typedef struct { typedef struct {
sfx_t **sfx; sfx_t **sfx;
@ -192,6 +193,8 @@ tentsfx_t tentsfx[] =
{&cl_sfx_ric3, "weapons/ric3.wav"}, {&cl_sfx_ric3, "weapons/ric3.wav"},
{&cl_sfx_r_exp3, "weapons/r_exp3.wav"} {&cl_sfx_r_exp3, "weapons/r_exp3.wav"}
}; };
vec3_t playerbeam_end[MAX_SPLITS];
/* /*
================= =================
CL_ParseTEnts CL_ParseTEnts
@ -210,6 +213,7 @@ void CL_InitTEnts (void)
Cvar_Register (&cl_expsprite, "Temporary entity control"); Cvar_Register (&cl_expsprite, "Temporary entity control");
Cvar_Register (&cl_truelightning, "Temporary entity control"); Cvar_Register (&cl_truelightning, "Temporary entity control");
Cvar_Register (&cl_beam_trace, "Temporary entity control");
Cvar_Register (&r_explosionlight, "Temporary entity control"); Cvar_Register (&r_explosionlight, "Temporary entity control");
} }
@ -335,6 +339,7 @@ void CL_AddBeam (int tent, int ent, vec3_t start, vec3_t end) //fixme: use TE_ n
model_t *m; model_t *m;
int btype, etype; int btype, etype;
int i;
vec3_t impact, normal; vec3_t impact, normal;
vec3_t extra; vec3_t extra;
@ -385,7 +390,20 @@ void CL_AddBeam (int tent, int ent, vec3_t start, vec3_t end) //fixme: use TE_ n
#endif #endif
} }
if (cls.state == ca_active && etype >= 0) // save end position for truelightning
if (ent)
{
for (i = 0; i < MAX_SPLITS; i++)
{
if (ent == (autocam[i]?spec_track[i]:(cl.playernum[i]+1)))
{
VectorCopy(end, playerbeam_end[i]);
break;
}
}
}
if (cl_beam_trace.value && etype >= 0 && cls.state == ca_active)
{ {
VectorSubtract(end, start, normal); VectorSubtract(end, start, normal);
VectorNormalize(normal); VectorNormalize(normal);
@ -2237,7 +2255,7 @@ CL_UpdateBeams
*/ */
void CL_UpdateBeams (void) void CL_UpdateBeams (void)
{ {
int i; int i, j;
beam_t *b; beam_t *b;
vec3_t dist, org; vec3_t dist, org;
float d; float d;
@ -2263,36 +2281,66 @@ void CL_UpdateBeams (void)
} }
// if coming from the player, update the start position // if coming from the player, update the start position
if (b->flags & 1 && b->entity == (autocam[0]?spec_track[0]:(cl.playernum[0]+1)) && b->entity>0 && b->entity<= MAX_CLIENTS) // entity 0 is the world if ((b->flags & 1) && b->entity > 0 && b->entity <= MAX_CLIENTS)
{ {
player_state_t *pl; for (j = 0; j < MAX_SPLITS; j++)
// VectorSubtract(cl.simorg, b->start, org);
// VectorAdd(b->end, org, b->end); //move the end point by simorg-start
pl = &cl.frames[cl.parsecount&UPDATE_MASK].playerstate[b->entity-1];
if (pl->messagenum == cl.parsecount)
{ {
VectorCopy (cl.simorg[0], b->start); //move the start point to view origin if (b->entity == (autocam[j]?spec_track[j]:(cl.playernum[j]+1)))
b->start[2] += cl.crouch[0];
if (v_viewheight.value)
{ {
if (v_viewheight.value <= -7) player_state_t *pl;
b->start[2] += -7; // VectorSubtract(cl.simorg, b->start, org);
else if (v_viewheight.value >= 4) // VectorAdd(b->end, org, b->end); //move the end point by simorg-start
b->start[2] += 4;
else
b->start[2] += v_viewheight.value;
}
pl = &cl.frames[cl.parsecount&UPDATE_MASK].playerstate[j];
if (pl->messagenum == cl.parsecount)
{
vec3_t fwd, org, ang;
float delta, f, len;
//rotate the end point to face in the view direction. This gives a smoother shafting. turning looks great. VectorCopy (cl.simorg[j], b->start);
if (cl_truelightning.value) b->start[2] += cl.crouch[j] + bound(-7, v_viewheight.value, 4);
{
VectorSubtract (b->end, b->start, dist); f = bound(0, cl_truelightning.value, 1);
d = VectorNormalize(dist);
AngleVectors (cl.simangles[0], b->end, dist, org); if (!f)
VectorMA(b->start, d, b->end, b->end); break;
b->end[2] += cl.viewheight[0];
VectorSubtract (playerbeam_end[j], cl.simorg[j], org);
len = VectorLength(org);
org[2] -= 22; // adjust for view height
vectoangles (org, ang);
// lerp pitch
ang[0] = -ang[0];
if (ang[0] < -180)
ang[0] += 360;
ang[0] += (cl.simangles[j][0] - ang[0]) * f;
// lerp yaw
delta = cl.simangles[j][1] - ang[1];
if (delta > 180)
delta -= 360;
if (delta < -180)
delta += 360;
ang[1] += delta * f;
ang[2] = 0;
AngleVectors (ang, fwd, ang, ang);
VectorCopy(fwd, ang);
VectorScale (fwd, len, fwd);
VectorCopy (cl.simorg[j], org);
org[2] += 16;
VectorAdd (org, fwd, b->end);
if (cl_beam_trace.value)
{
vec3_t normal;
VectorMA(org, len+4, ang, fwd);
if (TraceLineN(org, fwd, ang, normal))
VectorCopy (ang, b->end);
}
break;
}
} }
} }
} }

View file

@ -654,7 +654,7 @@ void VQ3_RenderView(const q3refdef_t *ref)
} }
#endif #endif
#ifdef RGLQUAKE #ifdef RGLQUAKE
if (qrenderer == QR_OPENGL) if (qrenderer == QR_OPENGL)
{ {
qglDisable(GL_ALPHA_TEST); qglDisable(GL_ALPHA_TEST);