mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
new defaults use logistic curve
This commit is contained in:
parent
ce57d928eb
commit
3578c74667
|
@ -28,11 +28,14 @@ CCamera::CCamera()
|
|||
|
||||
void CCamera::OnRender()
|
||||
{
|
||||
if(Client()->GameTick(g_Config.m_ClDummy) < m_ZoomAnimEndTick && m_ZoomAnimStartTick < m_ZoomAnimEndTick)
|
||||
if(IsZooming())
|
||||
{
|
||||
int SmoothTick;
|
||||
Client()->GetSmoothTick(&SmoothTick, NULL, 0);
|
||||
m_Zoom = mix(m_StartZoom, m_TargetZoom, (SmoothTick - m_ZoomAnimStartTick) / (m_ZoomAnimEndTick - m_ZoomAnimStartTick));
|
||||
|
||||
// The logistic function with default values give values near maximums and minimums on [-6, 6].
|
||||
float ScaledProgress = ZoomProgress() * 12 - 6;
|
||||
float Amount = 1.f / (1.f + exp(-ScaledProgress));
|
||||
m_Zoom = mix(m_StartZoom, m_TargetZoom, Amount);
|
||||
|
||||
if(m_TargetZoom < m_StartZoom)
|
||||
m_Zoom = clamp(m_Zoom, m_TargetZoom, m_StartZoom);
|
||||
else
|
||||
|
@ -155,10 +158,30 @@ void CCamera::ConZoomReset(IConsole::IResult *pResult, void *pUserData)
|
|||
((CCamera *)pUserData)->OnReset();
|
||||
}
|
||||
|
||||
float CCamera::ZoomProgress()
|
||||
{
|
||||
int SmoothTick;
|
||||
Client()->GetSmoothTick(&SmoothTick, NULL, 0);
|
||||
return (SmoothTick - m_ZoomAnimStartTick) / (m_ZoomAnimEndTick - m_ZoomAnimStartTick);
|
||||
}
|
||||
|
||||
bool CCamera::IsZooming()
|
||||
{
|
||||
return Client()->GameTick(g_Config.m_ClDummy) < m_ZoomAnimEndTick && m_ZoomAnimStartTick < m_ZoomAnimEndTick;
|
||||
}
|
||||
|
||||
void CCamera::StartSmoothZoom(float ZoomStep)
|
||||
{
|
||||
m_StartZoom = m_Zoom;
|
||||
m_TargetZoom = m_StartZoom * ZoomStep;
|
||||
m_ZoomAnimStartTick = Client()->GameTick(g_Config.m_ClDummy);
|
||||
m_ZoomAnimEndTick = m_ZoomAnimStartTick + g_Config.m_ClSmoothZoomLength / 1000.f * Client()->GameTickSpeed();
|
||||
// Check if we are in the middle of a smooth zoom already.
|
||||
if(IsZooming())
|
||||
{
|
||||
// TODO: Implement
|
||||
}
|
||||
else
|
||||
{
|
||||
m_StartZoom = m_Zoom;
|
||||
m_TargetZoom = m_StartZoom * ZoomStep;
|
||||
m_ZoomAnimStartTick = Client()->GameTick(g_Config.m_ClDummy);
|
||||
m_ZoomAnimEndTick = m_ZoomAnimStartTick + g_Config.m_ClSmoothZoomLength / 1000.f * Client()->GameTickSpeed();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,9 @@ public:
|
|||
virtual void OnReset();
|
||||
|
||||
void StartSmoothZoom(float ZoomStep);
|
||||
// Returns the zoom progress [0, 1]
|
||||
float ZoomProgress();
|
||||
bool IsZooming();
|
||||
|
||||
private:
|
||||
static void ConZoomPlus(IConsole::IResult *pResult, void *pUserData);
|
||||
|
|
|
@ -82,8 +82,8 @@ MACRO_CONFIG_INT(ClAutoStatboardScreenshot, cl_auto_statboard_screenshot, 0, 0,
|
|||
MACRO_CONFIG_INT(ClAutoStatboardScreenshotMax, cl_auto_statboard_screenshot_max, 10, 0, 1000, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Maximum number of automatically created statboard screenshots (0 = no limit)")
|
||||
|
||||
MACRO_CONFIG_INT(ClDefaultZoom, cl_default_zoom, 10, 0, 20, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Default zoom level (10 default, min 0, max 20)")
|
||||
MACRO_CONFIG_INT(ClSmoothZoom, cl_smooth_zoom, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Whether to enable smooth zoom.")
|
||||
MACRO_CONFIG_INT(ClSmoothZoomLength, cl_smooth_zoom_length, 400, 1, 5000, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Zoom smooth animation length in miliseconds.")
|
||||
MACRO_CONFIG_INT(ClSmoothZoom, cl_smooth_zoom, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Whether to enable smooth zoom.")
|
||||
MACRO_CONFIG_INT(ClSmoothZoomLength, cl_smooth_zoom_length, 800, 1, 5000, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Zoom smooth animation length in miliseconds.")
|
||||
|
||||
MACRO_CONFIG_INT(ClPlayerUseCustomColor, player_use_custom_color, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Toggles usage of custom colors")
|
||||
MACRO_CONFIG_COL(ClPlayerColorBody, player_color_body, 65408, CFGFLAG_CLIENT|CFGFLAG_SAVE|CFGFLAG_COLLIGHT, "Player body color")
|
||||
|
|
Loading…
Reference in a new issue