From: otta8634 Date: Wed, 25 Sep 2024 06:00:20 +0000 (+0800) Subject: Fix issues with physics hud jumpspeed X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7412ac6121253c91b5cc6bea3f33360c1b0115f4;p=xonotic%2Fxonotic-data.pk3dir.git Fix issues with physics hud jumpspeed Previous commit broke the previous-speed caching Made it use xy-speed rather than xyz-speed (ignores vertical speed) Made the cvar description reflect that it ignores vertical speed Used previous-frame speed rather than current frame -- acceleration after the jump would've already happened in the current frame --- diff --git a/_hud_common.cfg b/_hud_common.cfg index 2b1ab0178..302c107d1 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -111,7 +111,7 @@ seta hud_panel_physics_acceleration_movingaverage "1" "use an averaging method f seta hud_panel_physics_acceleration_movingaverage_strength "10" "weighting given to the current value in the movingaverage averaging method" seta hud_panel_physics_acceleration_max_slick "-1" "acceleration progressbar gets completely filled up by this value (in g) while on slick, -1 = same as the normal max" seta hud_panel_physics_update_interval "0.016" "how often (in seconds) numeric values get updated on screen" -seta hud_panel_physics_jumpspeed "0" "also show jump speed, replacing the speed unit text" +seta hud_panel_physics_jumpspeed "0" "also show jump speed, replacing the speed unit text (NOTE: ignores vertical speed)" seta hud_panel_physics_jumpspeed_time "1" "how many seconds the jump speed takes to fade out" seta hud_panel_itemstime_progressbar_maxtime "30" "when left time is at least this amount, the status bar is full" diff --git a/qcsrc/client/hud/panel/physics.qc b/qcsrc/client/hud/panel/physics.qc index 8b22fe661..0235787c7 100644 --- a/qcsrc/client/hud/panel/physics.qc +++ b/qcsrc/client/hud/panel/physics.qc @@ -29,7 +29,8 @@ void HUD_Physics_Export(int fh) } vector acc_prev_vel; -float acc_prevtime, acc_avg, top_speed, top_speed_time, jump_speed, jump_speed_time, prev_vel_z = 0; +float acc_prevtime, acc_avg, top_speed, top_speed_time, jump_speed, jump_speed_time; +float prev_vel_z = 0, prev_speed2d = 0; float physics_update_time, discrete_speed, discrete_acceleration; void HUD_Physics() { @@ -69,17 +70,23 @@ void HUD_Physics() text_scale = min(autocvar_hud_panel_physics_text_scale, 5); // compute speed - float speed, conversion_factor = GetSpeedUnitFactor(autocvar_hud_speed_unit); + float conversion_factor = GetSpeedUnitFactor(autocvar_hud_speed_unit); + float speed, speed2d; float max_speed = floor(autocvar_hud_panel_physics_speed_max * conversion_factor + 0.5); if (autocvar__hud_configure) { - speed = floor(max_speed * 0.65 + 0.5); + speed2d = floor(max_speed * 0.65 + 0.5); + speed = speed2d; // just ignore vertical speed in hud configure immobile = speed <= 0; } - else if (autocvar_hud_panel_physics_speed_vertical) - speed = floor(speed3d_phys * conversion_factor + 0.5); else - speed = floor(speed_phys * conversion_factor + 0.5); + { + speed2d = floor(speed_phys * conversion_factor + 0.5); + if (autocvar_hud_panel_physics_speed_vertical) + speed = floor(speed3d_phys * conversion_factor + 0.5); + else + speed = speed2d; + } // compute acceleration float acceleration, f; @@ -165,7 +172,7 @@ void HUD_Physics() { if (autocvar__hud_configure) { - top_speed = floor(max_speed * speed_size * 0.9 + 0.5); // slightly less than top speed text + jump_speed = floor(max_speed * speed_size * 0.9 + 0.5); // slightly less than top speed text f = 1; } else @@ -174,9 +181,11 @@ void HUD_Physics() { // NOTE: this includes some situations where the player doesn't explicitly jump (e.g. jumppad, weapon kb) // excluding them would be difficult. maybe they can be left in? - jump_speed = speed; + jump_speed = prev_speed2d; jump_speed_time = time; } + prev_vel_z = vel_phys.z; + prev_speed2d = speed2d; float time_frac = (time - jump_speed_time) / max(1, autocvar_hud_panel_physics_jumpspeed_time); f = time_frac > 1 ? 0 : cos(time_frac * PI / 2); }