Files
WickedEngine/WickedEngine/wiFadeManager.cpp
T
Turánszki János 74cb74d3c9 version 0.60 (#367)
- namespace refactor (example: wiGraphics:: -> wi::graphics)
  - provided namespace compatibility macro for old user code: WICKEDENGINE_BACKWARDS_COMPATIBILITY_0_59
- resource manager will return `Resource` instead of `shared_ptr<Resource>` objects
- MAD shader optimizations
- implemented alpha to coverage with alpha tested materials when MSAA is enabled
- alpha testing fix with transparent shadow maps
- TLAS and scene buffers will be recreated less frequently when things get added/removed from the scene
2021-12-03 21:22:27 +01:00

61 lines
894 B
C++

#include "wiFadeManager.h"
namespace wi
{
void FadeManager::Clear()
{
opacity = 0;
state = FADE_FINISHED;
}
void FadeManager::Update(float dt)
{
if (!IsActive())
return;
if (targetFadeTimeInSeconds <= 0)
{
// skip fade, just launch the job
onFade();
state = FADE_FINISHED;
}
float t = timer / targetFadeTimeInSeconds;
timer += wi::math::Clamp(dt, 0, 0.033f);
if (state == FADE_IN)
{
opacity = wi::math::Lerp(0.0f, 1.0f, t);
if (t >= 1.0f)
{
state = FADE_MID;
opacity = 1.0f;
}
}
else if (state == FADE_MID)
{
state = FADE_OUT;
opacity = 1.0f;
onFade();
timer = 0;
}
else if (state == FADE_OUT)
{
opacity = wi::math::Lerp(1.0f, 0.0f, t);
if (t >= 1.0f)
{
state = FADE_FINISHED;
opacity = 0.0f;
}
}
else if (state == FADE_FINISHED)
{
opacity = 0.0f;
onFade = [] {};
}
}
}