-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTimeSystem.cpp
More file actions
52 lines (45 loc) · 1.1 KB
/
Copy pathTimeSystem.cpp
File metadata and controls
52 lines (45 loc) · 1.1 KB
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 "TimeSystem.h"
Core::TimeSystem::TimeSystem() :
m_elapsedTicks(0),
m_totalTicks(0),
m_leftOverTicks(0),
m_frameCount(0),
m_framesPerSecond(0),
m_framesThisSecond(0),
m_qpcSecondCounter(0),
m_isFixedTimeStep(false),
m_targetElapsedTicks(TicksPerSecond / 60),
m_fixedLeftOverTicks(0)
{
if (!QueryPerformanceFrequency(&m_qpcFrequency))
{
throw std::exception("Failed_QueryPerformanceFrequency");
}
if (!QueryPerformanceCounter(&m_qpcLastTime))
{
throw std::exception("Failed_QueryPerformanceCounter");
}
// NewCreateSceneInitialize max delta to 1/10 of a second.
m_qpcMaxDelta = m_qpcFrequency.QuadPart / 10;
}
void Core::TimeSystem::UpdateTimeScale(float _timeDelta)
{
if (changeTimeScaleTime > 0.f)
{
changeTimeScaleTime -= _timeDelta;
if (changeTimeScaleTime <= 0.f)
{
changeTimeScaleTime = 0.f;
timeScale = orginTimeScale;
}
}
}
void Core::TimeSystem::SetTimeScale(float _timeScale, float _changeTimeScaleTime)
{
timeScale = _timeScale;
changeTimeScaleTime = _changeTimeScaleTime;
}
void Core::TimeSystem::SetTimeScale(float _timeScale)
{
timeScale = _timeScale;
}