mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Combine CGraph::ScaleMin
and ScaleMax
into Scale
As the methods are always called at the same time, they can be combined. This also improves the performance, as the array only needs to be iterated once.
This commit is contained in:
parent
f10edfa589
commit
8e0a935d5c
|
@ -89,25 +89,16 @@ void CGraph::Init(float Min, float Max)
|
|||
m_Index = 0;
|
||||
}
|
||||
|
||||
void CGraph::ScaleMax()
|
||||
void CGraph::Scale()
|
||||
{
|
||||
int i = 0;
|
||||
m_Max = m_MaxRange;
|
||||
for(i = 0; i < MAX_VALUES; i++)
|
||||
{
|
||||
if(m_aValues[i] > m_Max)
|
||||
m_Max = m_aValues[i];
|
||||
}
|
||||
}
|
||||
|
||||
void CGraph::ScaleMin()
|
||||
{
|
||||
int i = 0;
|
||||
m_Min = m_MinRange;
|
||||
for(i = 0; i < MAX_VALUES; i++)
|
||||
m_Max = m_MaxRange;
|
||||
for(auto Value : m_aValues)
|
||||
{
|
||||
if(m_aValues[i] < m_Min)
|
||||
m_Min = m_aValues[i];
|
||||
if(Value > m_Max)
|
||||
m_Max = Value;
|
||||
else if(Value < m_Min)
|
||||
m_Min = Value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1143,14 +1134,11 @@ void CClient::DebugRender()
|
|||
float sp = Graphics()->ScreenWidth() / 100.0f;
|
||||
float x = Graphics()->ScreenWidth() - w - sp;
|
||||
|
||||
m_FpsGraph.ScaleMax();
|
||||
m_FpsGraph.ScaleMin();
|
||||
m_FpsGraph.Scale();
|
||||
m_FpsGraph.Render(Graphics(), m_DebugFont, x, sp * 5, w, h, "FPS");
|
||||
m_InputtimeMarginGraph.ScaleMin();
|
||||
m_InputtimeMarginGraph.ScaleMax();
|
||||
m_InputtimeMarginGraph.Scale();
|
||||
m_InputtimeMarginGraph.Render(Graphics(), m_DebugFont, x, sp * 5 + h + sp, w, h, "Prediction Margin");
|
||||
m_GametimeMarginGraph.ScaleMin();
|
||||
m_GametimeMarginGraph.ScaleMax();
|
||||
m_GametimeMarginGraph.Scale();
|
||||
m_GametimeMarginGraph.Render(Graphics(), m_DebugFont, x, sp * 5 + h + sp + h + sp, w, h, "Gametime Margin");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,9 +56,7 @@ public:
|
|||
|
||||
void Init(float Min, float Max);
|
||||
|
||||
void ScaleMax();
|
||||
void ScaleMin();
|
||||
|
||||
void Scale();
|
||||
void Add(float v, float r, float g, float b);
|
||||
bool InsertAt(int i, float v, float r, float g, float b);
|
||||
void Render(IGraphics *pGraphics, IGraphics::CTextureHandle FontTexture, float x, float y, float w, float h, const char *pDescription);
|
||||
|
|
|
@ -162,8 +162,7 @@ void CDebugHud::RenderTuning()
|
|||
}
|
||||
pv = RampedSpeed;
|
||||
}
|
||||
m_RampGraph.ScaleMin();
|
||||
m_RampGraph.ScaleMax();
|
||||
m_RampGraph.Scale();
|
||||
|
||||
m_ZoomedInGraph.Init(0.0f, 0.0f);
|
||||
pv = 1;
|
||||
|
@ -189,8 +188,7 @@ void CDebugHud::RenderTuning()
|
|||
}
|
||||
pv = RampedSpeed;
|
||||
}
|
||||
m_ZoomedInGraph.ScaleMin();
|
||||
m_ZoomedInGraph.ScaleMax();
|
||||
m_ZoomedInGraph.Scale();
|
||||
}
|
||||
char aBuf[128];
|
||||
str_format(aBuf, sizeof(aBuf), "Velspeed.X*Ramp in Bps (Velspeed %d to %d)", StepSizeRampGraph / 32, 128 * StepSizeRampGraph / 32);
|
||||
|
|
Loading…
Reference in a new issue