diff --git a/doc/040_cvarlist.md b/doc/040_cvarlist.md index 2c8fefde..65c7136c 100644 --- a/doc/040_cvarlist.md +++ b/doc/040_cvarlist.md @@ -120,6 +120,11 @@ Set `0` by default. * **cl_kickangles**: If set to `0` angle kicks (weapon recoil, damage hits and the like) are ignored. Cheat-protected. Defaults to `1`. +* **cl_laseralpha**: Controls how see-through laserbeams are. + The value ranges from 0.0 to 1.0, from completely invisible to + completely opaque. So higher value means better visibility. + Defaults to `0.3`. + * **cl_limitsparksounds**: If set to `1` the number of sound generated when shooting into power screen and power shields is limited to 16. This works around global volume drops in some OpenAL implementations diff --git a/src/client/cl_entities.c b/src/client/cl_entities.c index ad315306..e951cea4 100644 --- a/src/client/cl_entities.c +++ b/src/client/cl_entities.c @@ -139,8 +139,17 @@ CL_AddPacketEntities(frame_t *frame) /* tweak the color of beams */ if (renderfx & RF_BEAM) { + ent.alpha = cl_laseralpha->value; + if (ent.alpha < 0.0f) + { + ent.alpha = 0.0f; + } + else if (ent.alpha > 1.0f) + { + ent.alpha = 1.0f; + } + /* the four beam colors are encoded in 32 bits of skinnum (hack) */ - ent.alpha = 0.30f; ent.skinnum = (s1->skinnum >> ((randk() % 4) * 8)) & 0xff; ent.model = NULL; } diff --git a/src/client/cl_main.c b/src/client/cl_main.c index 9d4ff2d0..38a41728 100644 --- a/src/client/cl_main.c +++ b/src/client/cl_main.c @@ -50,6 +50,7 @@ cvar_t *cl_add_lights; cvar_t *cl_add_entities; cvar_t *cl_add_blend; cvar_t *cl_kickangles; +cvar_t *cl_laseralpha; cvar_t *cl_shownet; cvar_t *cl_showmiss; @@ -517,6 +518,7 @@ CL_InitLocal(void) cl_predict = Cvar_Get("cl_predict", "1", 0); cl_showfps = Cvar_Get("cl_showfps", "0", CVAR_ARCHIVE); cl_showspeed = Cvar_Get("cl_showspeed", "0", CVAR_ARCHIVE); + cl_laseralpha = Cvar_Get("cl_laseralpha", "0.3", 0); cl_upspeed = Cvar_Get("cl_upspeed", "200", 0); cl_forwardspeed = Cvar_Get("cl_forwardspeed", "200", 0); diff --git a/src/client/cl_tempentities.c b/src/client/cl_tempentities.c index b9ef4b35..e5ef4bbd 100644 --- a/src/client/cl_tempentities.c +++ b/src/client/cl_tempentities.c @@ -492,10 +492,20 @@ CL_ParseLaser(int colors) { if (l->endtime < cl.time) { + float alpha = cl_laseralpha->value; + if (alpha < 0.0f) + { + alpha = 0.0f; + } + else if (alpha > 1.0f) + { + alpha = 1.0f; + } + l->ent.flags = RF_TRANSLUCENT | RF_BEAM; VectorCopy(start, l->ent.origin); VectorCopy(end, l->ent.oldorigin); - l->ent.alpha = 0.30f; + l->ent.alpha = alpha; l->ent.skinnum = (colors >> ((randk() % 4) * 8)) & 0xff; l->ent.model = NULL; l->ent.frame = 4; diff --git a/src/client/header/client.h b/src/client/header/client.h index 9b664f65..ee7883e0 100644 --- a/src/client/header/client.h +++ b/src/client/header/client.h @@ -316,6 +316,7 @@ extern cvar_t *vid_renderer; extern cvar_t *cl_kickangles; extern cvar_t *cl_r1q2_lightstyle; extern cvar_t *cl_limitsparksounds; +extern cvar_t *cl_laseralpha; typedef struct { diff --git a/src/common/shared/shared.c b/src/common/shared/shared.c index e86da819..20e4ec7a 100644 --- a/src/common/shared/shared.c +++ b/src/common/shared/shared.c @@ -581,19 +581,9 @@ double sqrt(double x); vec_t VectorLength(const vec3_t v) { - int i; - float length; - - length = 0; - - for (i = 0; i < 3; i++) - { - length += v[i] * v[i]; - } - - length = (float)sqrt(length); - - return length; + return sqrtf((v[0] * v[0]) + + (v[1] * v[1]) + + (v[2] * v[2])); } void