[qw] Add a cvar to control player shadows

cl_player_shadows defaults to 1 thus giving a nice (for the resolution)
shadow of the player (and disables the weapon shadow). Mirrors the
change to nq (I really need to get these last bits merged).
This commit is contained in:
Bill Currie 2024-01-13 02:43:15 +09:00
parent e978234018
commit ad852a15b6
4 changed files with 21 additions and 1 deletions

View file

@ -261,6 +261,7 @@ extern int cl_netgraph_box;
extern int cl_draw_locs;
extern int cl_shownet;
extern int cl_player_shadows;
extern char *cl_name;

View file

@ -168,7 +168,7 @@ Cam_DrawPlayer (int playernum)
{
if (playernum == cl.playernum) { // client player
if (cl.viewstate.chase == 0 || chase_active == 0)
return false;
return cl_player_shadows;
if (!cl.spectator)
return true;
} else {

View file

@ -151,6 +151,7 @@ set_entity_model (entity_t ent, int modelindex)
} else {
animation->syncbase = 0.0;
}
renderer->noshadows = renderer->model->shadow_alpha < 0.5;
}
animation->nolerp = 1; // don't try to lerp when the model has changed
}
@ -487,6 +488,9 @@ CL_LinkPlayers (void)
&& is_dead_body (&state->pls.es))
continue;
renderer->onlyshadows = (cl_player_shadows && j == cl.playernum
&& !chase_active);
colormap_t colormap = {
.top = player->topcolor,
.bottom = player->bottomcolor,

View file

@ -236,6 +236,15 @@ static cvar_t cl_shownet_cvar = {
.flags = CVAR_NONE,
.value = { .type = &cexpr_int, .value = &cl_shownet },
};
int cl_player_shadows;
static cvar_t cl_player_shadows_cvar = {
.name = "cl_player_shadows",
.description =
"Show player shadows instead of weapon shadows",
.default_value = "1",
.flags = CVAR_ARCHIVE,
.value = { .type = &cexpr_int, .value = &cl_player_shadows },
};
int cl_autoexec;
static cvar_t cl_autoexec_cvar = {
.name = "cl_autoexec",
@ -655,6 +664,11 @@ CL_ClearState (void)
cl.viewstate.weapon_entity = Scene_CreateEntity (cl_world.scene);
CL_Init_Entity (cl.viewstate.weapon_entity);
renderer_t *renderer = Ent_GetComponent (cl.viewstate.weapon_entity.id,
cl_world.scene->base + scene_renderer,
cl_world.scene->reg);
renderer->depthhack = 1;
renderer->noshadows = cl_player_shadows;
r_data->view_model = cl.viewstate.weapon_entity;
CL_TEnts_Precache ();
@ -1640,6 +1654,7 @@ CL_Init_Cvars (void)
Cvar_Register (&cl_writecfg_cvar, 0, 0);
Cvar_Register (&cl_draw_locs_cvar, 0, 0);
Cvar_Register (&cl_shownet_cvar, 0, 0);
Cvar_Register (&cl_player_shadows_cvar, 0, 0);
Cvar_Register (&cl_maxfps_cvar, 0, 0);
Cvar_Register (&cl_timeout_cvar, 0, 0);
Cvar_Register (&host_speeds_cvar, 0, 0);