Skip to content

Commit

Permalink
Add cl_gun_x/y/z cvars
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-drexler committed Aug 10, 2024
1 parent 7a2c3da commit 8477706
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
6 changes: 6 additions & 0 deletions Quake/gl_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ cvar_t scr_printspeed = {"scr_printspeed","8",CVAR_NONE};
cvar_t gl_triplebuffer = {"gl_triplebuffer", "1", CVAR_ARCHIVE};

cvar_t cl_gun_fovscale = {"cl_gun_fovscale","1",CVAR_ARCHIVE}; // Qrack
cvar_t cl_gun_x = {"cl_gun_x","0",CVAR_ARCHIVE};
cvar_t cl_gun_y = {"cl_gun_y","0",CVAR_ARCHIVE};
cvar_t cl_gun_z = {"cl_gun_z","0",CVAR_ARCHIVE};

extern char crosshair_char;
extern cvar_t crosshair;
Expand Down Expand Up @@ -571,6 +574,9 @@ void SCR_Init (void)
Cvar_RegisterVariable (&scr_printspeed);
Cvar_RegisterVariable (&gl_triplebuffer);
Cvar_RegisterVariable (&cl_gun_fovscale);
Cvar_RegisterVariable (&cl_gun_x);
Cvar_RegisterVariable (&cl_gun_y);
Cvar_RegisterVariable (&cl_gun_z);

Cmd_AddCommand ("scr_autoscale",SCR_AutoScale_f);

Expand Down
24 changes: 17 additions & 7 deletions Quake/r_alias.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "quakedef.h"

extern cvar_t gl_overbright_models, gl_fullbrights, r_lerpmodels, r_lerpmove; //johnfitz
extern cvar_t scr_fov, cl_gun_fovscale;
extern cvar_t scr_fov, cl_gun_fovscale, cl_gun_x, cl_gun_y, cl_gun_z;
extern cvar_t r_oit;

//up to 16 color translated skins
Expand Down Expand Up @@ -423,6 +423,22 @@ static void R_DrawAliasModel_Real (entity_t *e, qboolean showtris)
if (lerpdata.pose1 == lerpdata.pose2)
lerpdata.blend = 0.f;

//
// viewmodel adjustments (position, fov distortion correction)
//
if (e == &cl.viewent)
{
if (r_refdef.basefov > 90.f && cl_gun_fovscale.value)
{
fovscale = tan (r_refdef.basefov * (0.5f * M_PI / 180.f));
fovscale = 1.f + (fovscale - 1.f) * cl_gun_fovscale.value;
}

VectorMA (lerpdata.origin, cl_gun_x.value * paliashdr->scale[0] * fovscale, vright, lerpdata.origin);
VectorMA (lerpdata.origin, cl_gun_y.value * paliashdr->scale[1] * fovscale, vup, lerpdata.origin);
VectorMA (lerpdata.origin, cl_gun_z.value * paliashdr->scale[2], vpn, lerpdata.origin);
}

//
// cull it
//
Expand All @@ -432,12 +448,6 @@ static void R_DrawAliasModel_Real (entity_t *e, qboolean showtris)
//
// transform it
//
if (e == &cl.viewent && r_refdef.basefov > 90.f && cl_gun_fovscale.value)
{
fovscale = tan(r_refdef.basefov * (0.5f * M_PI / 180.f));
fovscale = 1.f + (fovscale - 1.f) * cl_gun_fovscale.value;
}

R_EntityMatrix (model_matrix, lerpdata.origin, lerpdata.angles, e->scale);
ApplyTranslation (model_matrix, paliashdr->scale_origin[0], paliashdr->scale_origin[1] * fovscale, paliashdr->scale_origin[2] * fovscale);
ApplyScale (model_matrix, paliashdr->scale[0], paliashdr->scale[1] * fovscale, paliashdr->scale[2] * fovscale);
Expand Down

0 comments on commit 8477706

Please sign in to comment.