From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Tue, 24 Sep 2024 21:40:08 +0000 (+0200) Subject: strafehud: improved hud range code, added fov option for range_sidestrafe and better... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=227001f2db1fccf4dd08d79797082e78551c4396;p=xonotic%2Fxonotic-data.pk3dir.git strafehud: improved hud range code, added fov option for range_sidestrafe and better handling of edge cases --- diff --git a/_hud_common.cfg b/_hud_common.cfg index 9d080fbfa..6c5050c07 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -168,7 +168,7 @@ seta hud_panel_scoreboard_itemstats_showdelay_minpos 0.75 "delay displaying the seta _hud_panel_strafehud_demo "0" "strafehud changes angle during configure" seta hud_panel_strafehud_mode "0" "strafehud mode which controls whether the strafehud is centered at 0 = view angle, 1 = velocity angle" seta hud_panel_strafehud_range "90" "the angle range up to 360 degrees displayed on the strafehud, -1 = current fov, 0 = dynamic (chooses the minimum range required to still see the whole area needed for accelerating)" -seta hud_panel_strafehud_range_sidestrafe "-1" "the angle range up to 360 degrees displayed on the strafehud when side strafing, 0 = dynamic (chooses the minimum range required to still see the whole area needed for accelerating), -1 = same as the normal range" +seta hud_panel_strafehud_range_sidestrafe "-2" "the angle range up to 360 degrees displayed on the strafehud when side strafing, 0 = dynamic (chooses the minimum range required to still see the whole area needed for accelerating), -1 = current fov, -2 = same as the normal range" seta hud_panel_strafehud_style "2" "0 = no styling, 1 = progress bar style for the strafe bar, 2 = gradient for the strafe bar, 3 = fast gradient for the strafe bar (requires linear projection mode)" seta hud_panel_strafehud_unit_show "1" "show units" seta hud_panel_strafehud_onground_mode "2" "handling of landing at speeds where friction is higher than optimal acceleration, 0 = fill the whole hud with overturn, 1 = show zones regardless, 2 = show the zones as if airborne (useful for quake2 and quake3 physics)" diff --git a/qcsrc/client/hud/panel/strafehud.qh b/qcsrc/client/hud/panel/strafehud.qh index f7b6e5e40..ac503a81b 100644 --- a/qcsrc/client/hud/panel/strafehud.qh +++ b/qcsrc/client/hud/panel/strafehud.qh @@ -10,7 +10,7 @@ bool autocvar__hud_panel_strafehud_demo = false; bool autocvar_hud_panel_strafehud_dynamichud = true; int autocvar_hud_panel_strafehud_mode = 0; float autocvar_hud_panel_strafehud_range = 90; -float autocvar_hud_panel_strafehud_range_sidestrafe = -1; +float autocvar_hud_panel_strafehud_range_sidestrafe = -2; int autocvar_hud_panel_strafehud_style = 2; bool autocvar_hud_panel_strafehud_unit_show = true; int autocvar_hud_panel_strafehud_onground_mode = 2; diff --git a/qcsrc/client/hud/panel/strafehud/util.qc b/qcsrc/client/hud/panel/strafehud/util.qc index b430a5260..c02e18516 100644 --- a/qcsrc/client/hud/panel/strafehud/util.qc +++ b/qcsrc/client/hud/panel/strafehud/util.qc @@ -221,23 +221,25 @@ float StrafeHUD_DetermineHudAngle(float absolute_wishangle, float absolute_overt float range_side = autocvar_hud_panel_strafehud_range_sidestrafe; float range_used; - if(isnan(range_normal) || isnan(range_side)) return 0; - - if(range_normal == 0) - range_normal = autocvar__hud_configure ? 90 : range_minangle; // use minimum angle required if dynamically setting hud angle - else if(range_normal < 0) - { - float hfov = getproperty(VF_FOVX); - if(isnan(hfov)) hfov = 0; - + float hfov = getproperty(VF_FOVX); + if(isnan(range_normal) || isnan(range_side) || isnan(hfov)) return 360; + + // negative values enable different behaviour + // no exact matching so that all negative values are caught + if(range_normal == 0) // range = 0, use minimum angle required if dynamically setting hud angle + range_normal = autocvar__hud_configure ? 90 : range_minangle; + else if(range_normal < 0) // range = -1, use the current field of view range_normal = hfov; - } - if(range_side == -1) // use the normal range + + if(range_side < -1) // range = -2, use the normal range range_used = range_normal; else { - if(range_side == 0) + if(range_side == 0) // range = 0, use minimum angle required if dynamically setting hud angle range_side = autocvar__hud_configure ? 90 : range_minangle; + else if(range_side < 0) // range = -1, use the current field of view + range_side = hfov; + range_used = GeomLerp(range_normal, strafity, range_side); } float hudangle = bound(0, fabs(range_used), 360); // limit HUD range to 360 degrees, higher values don't make sense