2017-03-30 22:36:18 +00:00
|
|
|
#include "CRippleManager.hpp"
|
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
2018-06-04 01:56:21 +00:00
|
|
|
CRippleManager::CRippleManager(int maxRipples, float alpha)
|
|
|
|
: x14_alpha(alpha)
|
2017-03-30 22:36:18 +00:00
|
|
|
{
|
|
|
|
Init(maxRipples);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CRippleManager::Init(int maxRipples)
|
|
|
|
{
|
|
|
|
x4_ripples.resize(maxRipples, CRipple(kInvalidUniqueId, zeus::CVector3f::skZero, 0.f));
|
|
|
|
for (CRipple& r : x4_ripples)
|
|
|
|
r.SetTime(9999.f);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CRippleManager::Update(float dt)
|
|
|
|
{
|
2018-02-01 23:19:34 +00:00
|
|
|
for (CRipple& ripple : x4_ripples)
|
|
|
|
{
|
|
|
|
ripple.SetTime(ripple.GetTime() + dt);
|
|
|
|
if (ripple.GetTime() > 9999.f)
|
|
|
|
ripple.SetTime(9999.f);
|
|
|
|
}
|
2017-03-30 22:36:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
float CRippleManager::GetLastRippleDeltaTime(TUniqueId rippler) const
|
|
|
|
{
|
|
|
|
float res = 9999.f;
|
|
|
|
for (const CRipple& r : x4_ripples)
|
|
|
|
if (r.GetUniqueId() == rippler)
|
|
|
|
if (r.GetTime() < res)
|
|
|
|
res = r.GetTime();
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CRippleManager::AddRipple(const CRipple& ripple)
|
|
|
|
{
|
2018-06-04 01:56:21 +00:00
|
|
|
float maxTime = 0.f;
|
|
|
|
auto oldestRipple = x4_ripples.end();
|
|
|
|
for (auto it = x4_ripples.begin() ; it != x4_ripples.end() ; ++it)
|
|
|
|
if (it->GetTime() > maxTime)
|
|
|
|
{
|
|
|
|
oldestRipple = it;
|
|
|
|
maxTime = it->GetTime();
|
|
|
|
}
|
2017-03-30 22:36:18 +00:00
|
|
|
|
2018-06-04 01:56:21 +00:00
|
|
|
if (oldestRipple != x4_ripples.end())
|
|
|
|
{
|
|
|
|
*oldestRipple = ripple;
|
|
|
|
x0_maxTimeFalloff = std::max(x0_maxTimeFalloff, ripple.GetTimeFalloff());
|
|
|
|
}
|
2017-03-30 22:36:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|