X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=qcsrc%2Fclient%2Fhud%2Fpanel%2Fstrafehud.qc;h=8f050005305b4e2673afffe80cda2935cecd2780;hb=bda29da7c83e61ef45bce71d9a0c53115cd56752;hp=b281d3ed4a554c84f4704503c28d706274ef8521;hpb=fc56bbddeeb17753e0bdb9ec68b69ce90905df8f;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index b281d3ed4..8f0500053 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -36,12 +36,6 @@ float turnaccel; bool fwd = true; float starttime = 0; float startspeed = -1; -float jumptime = 0; -float jumpheight = -1; -float jumpheight_persistent = -1; -float jumpheight_prev = 0; -float jumpspeed_prev = 0; -bool jumprestart = true; // provide basic panel cvars to old clients // TODO remove them after a future release (0.8.2+) @@ -865,47 +859,29 @@ void HUD_StrafeHUD() startspeed = -1; } - // experimental: show height achieved by a single jump (doesn't work in low gravity and may not be 100% accurate) - if(autocvar_hud_panel_strafehud_jumpheight_fade > 0) + // show height achieved by a single jump + if(autocvar_hud_panel_strafehud_jumpheight_fade > 0 && autocvar_hud_panel_strafehud_jumpheight_size > 0) { - float text_alpha = 0; - float jumpheight_min = max(autocvar_hud_panel_strafehud_jumpheight_min, 0); - float jumpheight_current = strafeplayer.origin.z; - float jumpspeed_current = strafeplayer.velocity.z; - if(jumpspeed_prev <= jumpspeed_current || jumpheight_prev > jumpheight_current || onground || swimming || IS_DEAD(strafeplayer) || spectating) + static float height_min = 0, height_max = 0; // ground and peak of jump z coordinates + static float jumpheight = 0, jumptime = 0; // displayed value and timestamp for fade out + + // tries to catch kill and spectate but those are not reliable, should just hook to kill/spectate/teleport and reset jump height there + if((strafeplayer.velocity.z <= 0 && height_max >= strafeplayer.origin.z) || onground || swimming || IS_DEAD(strafeplayer) || spectating) { - // tries to catch kill and spectate but those are not reliable, should just hook to kill/spectate/teleport and reset jump height there - jumprestart = true; + height_min = height_max = strafeplayer.origin.z; } - else + else if(strafeplayer.origin.z > height_max) { - if(jumpheight < 0 || jumprestart) - { - jumprestart = false; - jumpheight = 0; - } - else - { - jumpheight += jumpheight_current - jumpheight_prev; - } - if((jumpheight * length_conversion_factor) > jumpheight_min && jumpheight > jumpheight_persistent) - { + height_max = strafeplayer.origin.z; + jumpheight = (height_max - height_min) * length_conversion_factor; + + if(jumpheight > max(autocvar_hud_panel_strafehud_jumpheight_min, 0)) jumptime = time; - jumpheight_persistent = jumpheight; - } - } - jumpheight_prev = jumpheight_current; - jumpspeed_prev = jumpspeed_current; - if(jumpheight_persistent > 0) - { - text_alpha = cos(((time - jumptime) / autocvar_hud_panel_strafehud_jumpheight_fade) * 90 * DEG2RAD); // fade non-linear like the physics panel does - if((time - jumptime) > autocvar_hud_panel_strafehud_jumpheight_fade) - { - jumpheight_persistent = -1; - } } - if(jumpheight_persistent > 0 && text_alpha > 0 && autocvar_hud_panel_strafehud_jumpheight_size > 0) + + if((time - jumptime) <= autocvar_hud_panel_strafehud_jumpheight_fade) { + float text_alpha = cos(((time - jumptime) / autocvar_hud_panel_strafehud_jumpheight_fade) * 90 * DEG2RAD); // fade non-linear like the physics panel does vector jumpheight_size = panel_size; jumpheight_size.y = autocvar_hud_panel_strafehud_jumpheight_size; if(!autocvar_hud_panel_strafehud_uncapped) @@ -925,14 +901,9 @@ void HUD_StrafeHUD() } string length_unit = GetLengthUnit(autocvar_hud_panel_strafehud_unit); - drawstring_aspect(panel_pos - eY * (jumpheight_size.y + text_offset), strcat(ftos_decimals(jumpheight_persistent * length_conversion_factor, length_decimals), autocvar_hud_panel_strafehud_unit_show ? length_unit : ""), jumpheight_size, autocvar_hud_panel_strafehud_jumpheight_color, text_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(panel_pos - eY * (jumpheight_size.y + text_offset), strcat(ftos_decimals(jumpheight, length_decimals), autocvar_hud_panel_strafehud_unit_show ? length_unit : ""), jumpheight_size, autocvar_hud_panel_strafehud_jumpheight_color, text_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } } - else - { - jumpheight_prev = jumpspeed_prev = 0; - jumpheight = jumpheight_persistent = -1; - } draw_endBoldFont(); } }