From: divverent Date: Sat, 22 May 2010 18:41:10 +0000 (+0000) Subject: sv_airstrafeaccel_qw cvar for tuning CPMA-style physics X-Git-Tag: xonotic-v0.1.0preview~230^2~268 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=728e717bdc878f4ef2fb4311619b232949fb16aa;p=xonotic%2Fdarkplaces.git sv_airstrafeaccel_qw cvar for tuning CPMA-style physics git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10210 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_input.c b/cl_input.c index aacdfcc5..4400e3a6 100644 --- a/cl_input.c +++ b/cl_input.c @@ -1099,6 +1099,25 @@ static vec_t CL_IsMoveInDirection(vec_t forward, vec_t side, vec_t angle) return 1 - fabs(angle); } +static vec_t CL_GeomLerp(vec_t a, vec_t lerp, vec_t b) +{ + if(a == 0) + { + if(lerp < 1) + return 0; + else + return b; + } + if(b == 0) + { + if(lerp > 0) + return 0; + else + return a; + } + return a * pow(fabs(b / a), lerp); +} + void CL_ClientMovement_Physics_CPM_PM_Aircontrol(cl_clientmovement_state_t *s, vec3_t wishdir, vec_t wishspeed) { vec_t zspeed, speed, dot, k; @@ -1353,7 +1372,7 @@ void CL_ClientMovement_Physics_Walk(cl_clientmovement_state_t *s) if (s->waterjumptime <= 0) { // apply air speed limit - vec_t accel, wishspeed0, wishspeed2, accelqw; + vec_t accel, wishspeed0, wishspeed2, accelqw, strafity; qboolean accelerating; accelqw = cl.movevars_airaccel_qw; @@ -1370,9 +1389,17 @@ void CL_ClientMovement_Physics_Walk(cl_clientmovement_state_t *s) if(cl.movevars_airstopaccelerate != 0) if(DotProduct(s->velocity, wishdir) < 0) accel = cl.movevars_airstopaccelerate; - // this doesn't play well with analog input, but can't really be - // fixed like the AirControl can. So, don't set the maxairstrafe* - // cvars when you want to support analog input. + strafity = CL_IsMoveInDirection(s->cmd.forwardmove, s->cmd.sidemove, -90) + CL_IsMoveInDirection(s->cmd.forwardmove, s->cmd.sidemove, +90); // if one is nonzero, other is always zero + if(cl.movevars_maxairstrafespeed) + wishspeed = min(wishspeed, CL_GeomLerp(cl.movevars_maxairspeed, strafity, cl.movevars_maxairstrafespeed)); + if(cl.movevars_airstrafeaccelerate) + accel = CL_GeomLerp(cl.movevars_airaccelerate, strafity, cl.movevars_airstrafeaccelerate); + if(cl.movevars_airstrafeaccel_qw) + accelqw = + (((strafity > 0.5 ? cl.movevars_airstrafeaccel_qw : cl.movevars_airaccel_qw) >= 0) ? +1 : -1) + * + (1 - CL_GeomLerp(1 - fabs(cl.movevars_airaccel_qw), strafity, 1 - fabs(cl.movevars_airstrafeaccel_qw))); + if(s->cmd.forwardmove == 0 && s->cmd.sidemove != 0) { if(cl.movevars_maxairstrafespeed) @@ -1461,6 +1488,7 @@ void CL_UpdateMoveVars(void) cl.movevars_airstopaccelerate = cl.statsf[STAT_MOVEVARS_AIRSTOPACCELERATE]; cl.movevars_airstrafeaccelerate = cl.statsf[STAT_MOVEVARS_AIRSTRAFEACCELERATE]; cl.movevars_maxairstrafespeed = cl.statsf[STAT_MOVEVARS_MAXAIRSTRAFESPEED]; + cl.movevars_airstrafeaccel_qw = cl.statsf[STAT_MOVEVARS_AIRSTRAFEACCEL_QW]; cl.movevars_aircontrol = cl.statsf[STAT_MOVEVARS_AIRCONTROL]; cl.movevars_aircontrol_power = cl.statsf[STAT_MOVEVARS_AIRCONTROL_POWER]; cl.movevars_warsowbunny_airforwardaccel = cl.statsf[STAT_MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL]; @@ -1494,6 +1522,7 @@ void CL_UpdateMoveVars(void) cl.movevars_airstopaccelerate = 0; cl.movevars_airstrafeaccelerate = 0; cl.movevars_maxairstrafespeed = 0; + cl.movevars_airstrafeaccel_qw = 0; cl.movevars_aircontrol = 0; cl.movevars_aircontrol_power = 2; cl.movevars_warsowbunny_airforwardaccel = 0; diff --git a/client.h b/client.h index 9ee76093..8a8e192c 100644 --- a/client.h +++ b/client.h @@ -1191,6 +1191,7 @@ typedef struct client_state_s float movevars_airstopaccelerate; float movevars_airstrafeaccelerate; float movevars_maxairstrafespeed; + float movevars_airstrafeaccel_qw; float movevars_aircontrol; float movevars_aircontrol_power; float movevars_warsowbunny_airforwardaccel; diff --git a/quakedef.h b/quakedef.h index 09192850..1c1148e0 100644 --- a/quakedef.h +++ b/quakedef.h @@ -229,6 +229,7 @@ extern char engineversion[128]; //#define STAT_TIME 17 ///< FTE //#define STAT_VIEW2 20 ///< FTE #define STAT_VIEWZOOM 21 ///< DP +#define STAT_MOVEVARS_AIRSTRAFEACCEL_QW 223 ///< DP #define STAT_MOVEVARS_AIRCONTROL_POWER 224 ///< DP #define STAT_MOVEFLAGS 225 ///< DP #define STAT_MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL 226 ///< DP diff --git a/server.h b/server.h index fdea1076..db72d41d 100644 --- a/server.h +++ b/server.h @@ -390,6 +390,7 @@ extern cvar_t sv_airaccelerate; extern cvar_t sv_airstopaccelerate; extern cvar_t sv_airstrafeaccelerate; extern cvar_t sv_maxairstrafespeed; +extern cvar_t sv_airstrafeaccel_qw; extern cvar_t sv_aircontrol; extern cvar_t sv_aircontrol_power; extern cvar_t sv_allowdownloads; diff --git a/sv_main.c b/sv_main.c index 32abfe34..ad9a3a13 100644 --- a/sv_main.c +++ b/sv_main.c @@ -58,6 +58,7 @@ cvar_t sv_airaccelerate = {0, "sv_airaccelerate", "-1", "rate at which a player cvar_t sv_airstopaccelerate = {0, "sv_airstopaccelerate", "0", "when set, replacement for sv_airaccelerate when moving backwards"}; cvar_t sv_airstrafeaccelerate = {0, "sv_airstrafeaccelerate", "0", "when set, replacement for sv_airaccelerate when just strafing"}; cvar_t sv_maxairstrafespeed = {0, "sv_maxairstrafespeed", "0", "when set, replacement for sv_maxairspeed when just strafing"}; +cvar_t sv_airstrafeaccel_qw = {0, "sv_airstrafeaccel_qw", "0", "when set, replacement for sv_airaccel_qw when just strafing"}; cvar_t sv_aircontrol = {0, "sv_aircontrol", "0", "CPMA-style air control"}; cvar_t sv_aircontrol_power = {0, "sv_aircontrol_power", "2", "CPMA-style air control exponent"}; cvar_t sv_allowdownloads = {0, "sv_allowdownloads", "1", "whether to allow clients to download files from the server (does not affect http downloads)"}; @@ -379,6 +380,7 @@ void SV_Init (void) Cvar_RegisterVariable (&sv_airstopaccelerate); Cvar_RegisterVariable (&sv_airstrafeaccelerate); Cvar_RegisterVariable (&sv_maxairstrafespeed); + Cvar_RegisterVariable (&sv_airstrafeaccel_qw); Cvar_RegisterVariable (&sv_aircontrol); Cvar_RegisterVariable (&sv_aircontrol_power); Cvar_RegisterVariable (&sv_allowdownloads); @@ -1966,6 +1968,7 @@ void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t statsf[STAT_MOVEVARS_AIRSTOPACCELERATE] = sv_airstopaccelerate.value; statsf[STAT_MOVEVARS_AIRSTRAFEACCELERATE] = sv_airstrafeaccelerate.value; statsf[STAT_MOVEVARS_MAXAIRSTRAFESPEED] = sv_maxairstrafespeed.value; + statsf[STAT_MOVEVARS_AIRSTRAFEACCEL_QW] = sv_airstrafeaccel_qw.value; statsf[STAT_MOVEVARS_AIRCONTROL] = sv_aircontrol.value; statsf[STAT_MOVEVARS_AIRCONTROL_POWER] = sv_aircontrol_power.value; statsf[STAT_MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL] = sv_warsowbunny_airforwardaccel.value;