From 1b9cc62e175cad18fd3fb7e1985ad41422a48d9d Mon Sep 17 00:00:00 2001 From: terencehill Date: Fri, 3 Jul 2015 15:24:28 +0200 Subject: [PATCH] Make numeric values of speed and acceleration more readable by limiting the refresh rate (cvar hud_panel_physics_update_interval) --- _hud_common.cfg | 1 + qcsrc/client/autocvars.qh | 1 + qcsrc/client/hud.qc | 20 ++++++++++++++------ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/_hud_common.cfg b/_hud_common.cfg index 8558e84be1..b74eff9607 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -39,6 +39,7 @@ seta hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight 0.1 " seta hud_panel_engineinfo_framecounter_exponentialmovingaverage_instantupdate_change_threshold 0.5 "threshold for fps change when to update instantly, to make big fps changes update faster" seta hud_panel_physics_acceleration_movingaverage 1 "use an averaging method for calculating acceleration instead of the real value" +seta hud_panel_phisics_update_interval 0.0666 "how often (in seconds) numeric values get updated on screen" // hud panel aliases alias hud_panel_radar_rotate "toggle hud_panel_radar_rotation 0 1 2 3 4" diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index f28bc552c4..90faef9411 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -287,6 +287,7 @@ float autocvar_hud_panel_physics_acceleration_progressbar_mode; float autocvar_hud_panel_physics_acceleration_progressbar_scale; float autocvar_hud_panel_physics_acceleration_progressbar_nonlinear; float autocvar_hud_panel_physics_acceleration_max; +float autocvar_hud_panel_physics_update_interval; int autocvar_hud_panel_physics_progressbar; bool autocvar_hud_panel_physics_acceleration_vertical; int autocvar_hud_panel_physics_baralign; diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 7a1634625c..98f97b0efe 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -3909,6 +3909,7 @@ void HUD_InfoMessages(void) // vector acc_prevspeed; float acc_prevtime, acc_avg, top_speed, top_speed_time; +float physics_update_time, discrete_speed, discrete_acceleration; void HUD_Physics(void) { if(!autocvar__hud_configure) @@ -4004,6 +4005,17 @@ void HUD_Physics(void) } } + int acc_decimals = 2; + if(time > physics_update_time) + { + // workaround for ftos_decimals returning a negative 0 + if(discrete_acceleration > -1 / pow(10, acc_decimals) && discrete_acceleration < 0) + discrete_acceleration = 0; + discrete_acceleration = acceleration; + discrete_speed = speed; + physics_update_time += autocvar_hud_panel_physics_update_interval; + } + //compute layout float panel_ar = panel_size.x/panel_size.y; vector speed_offset = '0 0 0', acceleration_offset = '0 0 0'; @@ -4055,7 +4067,7 @@ void HUD_Physics(void) //else //tmp_offset_x = 0; tmp_offset.y = (panel_size.y - tmp_size.y) / 2; - drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(speed), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(discrete_speed), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); //draw speed unit if (speed_baralign) @@ -4175,11 +4187,7 @@ void HUD_Physics(void) tmp_offset.x = 0; tmp_offset.y = (panel_size.y - tmp_size.y) / 2; - int decimals = 2; - // workaround for ftos_decimals returning a negative 0 - if(acceleration > -1 / pow(10, decimals) && acceleration < 0) - acceleration = 0; - drawstring_aspect(panel_pos + acceleration_offset + tmp_offset, strcat(ftos_decimals(acceleration, decimals), "g"), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(panel_pos + acceleration_offset + tmp_offset, strcat(ftos_decimals(discrete_acceleration, acc_decimals), "g"), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); } draw_endBoldFont(); -- 2.39.2