enable the quick update fps method by default, make it update even faster :P
authorFruitieX <rasse@rasse-lappy.localdomain>
Mon, 14 Jun 2010 20:28:31 +0000 (23:28 +0300)
committerFruitieX <rasse@rasse-lappy.localdomain>
Mon, 14 Jun 2010 20:28:31 +0000 (23:28 +0300)
defaultXonotic.cfg
qcsrc/client/hud.qc

index 60b6fe4..57838fb 100644 (file)
@@ -1509,8 +1509,9 @@ seta hud_engineinfo_bg_alpha 0 "if set to something else than \"\" = override de
 seta hud_engineinfo_bg_border "" "if set to something else than \"\" = override default size of border around the background"
 seta hud_engineinfo_bg_padding "" "if set to something else than \"\" = override default padding of contents from border"
 seta hud_engineinfo_framecounter_time 1 "time between framerate display updates, smaller values yield less accuracy"
-seta hud_engineinfo_framecounter_exponentialmovingaverage 0 "use an averaging method for calculating fps instead of counting frametime like engine does"
-seta hud_engineinfo_framecounter_exponentialmovingaverage_new_weight 0.025 "weight of latest data point"
+seta hud_engineinfo_framecounter_decimals 0 "amount of decimals to show"
+seta hud_engineinfo_framecounter_exponentialmovingaverage 1 "use an averaging method for calculating fps instead of counting frametime like engine does"
+seta hud_engineinfo_framecounter_exponentialmovingaverage_new_weight 0.1 "weight of latest data point"
 seta hud_engineinfo_framecounter_exponentialmovingaverage_instantupdate_change_threshold 0.5 "treshold for fps change when to update instantly, to make big fps changes update faster"
 
 // scoreboard
index 45cc515..28e4e0b 100644 (file)
@@ -3947,6 +3947,10 @@ void HUD_Chat(void)
 float prevfps;
 float prevfps_time;
 float framecounter;
+
+float frametimeavg;
+float frametimeavg1; // 1 frame ago
+float frametimeavg2; // 2 frames ago
 void HUD_EngineInfo(void)
 {
        float id = HUD_PANEL_ENGINEINFO;
@@ -3965,13 +3969,17 @@ void HUD_EngineInfo(void)
 
        if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
        {
+               frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
+               frametimeavg2 = frametimeavg1;
+               frametimeavg1 = frametimeavg;
+               
                float weight;
                weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
                if(frametime > 0.0001) // filter out insane values which sometimes seem to occur and throw off the average? If you are getting 10,000 fps or more, then you don't need a framerate counter.
                {
-                       if(fabs(prevfps - (1/frametime)) > prevfps * cvar("hud_engineinfo_framecounter_exponentialmovingaverage_instantupdate_change_threshold")) // if there was a big jump in fps, just force prevfps at current (1/frametime) to make big updates instant
+                       if(fabs(prevfps - (1/frametimeavg)) > prevfps * cvar("hud_engineinfo_framecounter_exponentialmovingaverage_instantupdate_change_threshold")) // if there was a big jump in fps, just force prevfps at current (1/frametime) to make big updates instant
                                prevfps = (1/frametime);
-                       prevfps = (1 - weight) * prevfps + weight * (1/frametime);
+                       prevfps = (1 - weight) * prevfps + weight * (1/frametimeavg); // framecounter just used so there's no need for a new variable, think of it as "frametime average"
                }
        }
        else
@@ -3987,7 +3995,7 @@ void HUD_EngineInfo(void)
 
        vector color;
        color = HUD_Get_Num_Color (prevfps, 100);
-       drawstring(pos, strcat("FPS: ", ftos_decimals(prevfps, 2)), '1 1 0' * 0.5 * mySize_y, color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
+       drawstring(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_engineinfo_framecounter_decimals"))), '1 1 0' * 0.5 * mySize_y, color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
 }
 /*
 ==================