blob: f7f7ca35b426fe20ae8f5cff0758ab22d7142040 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#include "drape_frontend/animation/base_interpolator.hpp"
#include "drape_frontend/animation/interpolation_holder.hpp"
#include "base/assert.hpp"
#include "base/math.hpp"
namespace df
{
BaseInterpolator::BaseInterpolator(double duration, double delay)
: m_elapsedTime(0.0)
, m_duration(duration)
, m_delay(delay)
{
ASSERT(m_duration > 0.0, ());
InterpolationHolder::Instance().RegisterInterpolator(this);
}
BaseInterpolator::~BaseInterpolator()
{
InterpolationHolder::Instance().DeregisterInterpolator(this);
}
bool BaseInterpolator::IsFinished() const
{
return m_elapsedTime > (m_duration + m_delay);
}
void BaseInterpolator::Advance(double elapsedSeconds)
{
m_elapsedTime += elapsedSeconds;
}
double BaseInterpolator::GetT() const
{
if (IsFinished())
return 1.0;
return max(m_elapsedTime - m_delay, 0.0) / m_duration;
}
double BaseInterpolator::GetElapsedTime() const
{
return m_elapsedTime;
}
double BaseInterpolator::GetDuration() const
{
return m_duration;
}
}
|