]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Make numeric values of speed and acceleration more readable by limiting the refresh...
authorterencehill <piuntn@gmail.com>
Fri, 3 Jul 2015 13:24:28 +0000 (15:24 +0200)
committerterencehill <piuntn@gmail.com>
Fri, 3 Jul 2015 13:24:28 +0000 (15:24 +0200)
_hud_common.cfg
qcsrc/client/autocvars.qh
qcsrc/client/hud.qc

index 8558e84be1e83068f4fd848dad781e0d46d17fb3..b74eff9607999b19978d0128dd466824e1167585 100644 (file)
@@ -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"
index f28bc552c49356f1e7320f836a406372937a4ac7..90faef9411e7a23bee108316cad225b3e4b5e723 100644 (file)
@@ -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;
index 7a1634625c76f1ef83598bfd4c87a36737ad2a18..98f97b0efe4ca75bdd1f500ba789ec7d6b245cee 100644 (file)
@@ -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();