From 5ae26a4c4fe26c1c9f1fcdb56dd615a341fea268 Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Wed, 18 Sep 2024 22:53:29 +0200 Subject: [PATCH] strafehud: refactor and document the minimum hud angle calculations triggered by a _range value of 0 --- qcsrc/client/hud/panel/strafehud/util.qc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/qcsrc/client/hud/panel/strafehud/util.qc b/qcsrc/client/hud/panel/strafehud/util.qc index 74704685e..189621c40 100644 --- a/qcsrc/client/hud/panel/strafehud/util.qc +++ b/qcsrc/client/hud/panel/strafehud/util.qc @@ -218,13 +218,17 @@ float StrafeHUD_DetermineHudAngle(float wishangle) } else { - // determine minimum required angle to display full strafe range - float range_minangle = fabs(wishangle) % 90; // maximum range is 90 degree - if(range_minangle > 45) range_minangle = 45 - fabs(wishangle) % 45; // minimum angle range is 45 - range_minangle = 90 - range_minangle; // calculate value which is never >90 or <45 - range_minangle *= 2; // multiply to accommodate for both sides of the hud - - hudangle = range_minangle; // use minimum angle required if dynamically setting hud angle + // determine the minimal required HUD angle to contain the full strafing angle range + // this is useful for the velocity centered mode where the zones do not follow the strafing angle + // how it works: + // the angle where the most acceleration occurs moves relative to the player velocity + // from 0 - wishangle to 90 - wishangle + // the angle farther away from the center is the maximum the optimal strafing angle can + // diverge from the direction of velocity + // this angle has to be multiplied by two since the HUD extends in both directions which + // halves the amount it extends in a single direction + float absolute_wishangle = fabs(wishangle); + hudangle = max(absolute_wishangle, 90 - absolute_wishangle) * 2; } } else if(autocvar_hud_panel_strafehud_range < 0) -- 2.39.2