mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-22 23:26:15 +00:00
Allow stepping through the time delta in multiple passes in snowballs
--HG-- branch : multipass-stereo
This commit is contained in:
parent
c7a9edd495
commit
4a7f58938d
3 changed files with 28 additions and 7 deletions
|
@ -42,6 +42,14 @@ static bool _SkipAnimationOnce;
|
|||
static NLMISC::TTime _TimeMs;
|
||||
static CValueSmootherTemplate<float> _FpsSmoother;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
NLMISC::TLocalTime a_LocalTimeDelta;
|
||||
NL3D::TGlobalAnimationTime a_AnimationTimeDelta;
|
||||
|
||||
} /* anonymous namespace */
|
||||
|
||||
static void cbFpsSmoothing(CConfigFile::CVar &var)
|
||||
{
|
||||
_FpsSmoother.init((uint)var.asInt());
|
||||
|
@ -53,8 +61,10 @@ void CGameTime::init()
|
|||
_TimeMs = NLMISC::CTime::getLocalTime();
|
||||
LocalTime = ((TLocalTime)_TimeMs) / 1000.0;
|
||||
LocalTimeDelta = 0.0;
|
||||
a_LocalTimeDelta = 0.0;
|
||||
AnimationTime = 0.0;
|
||||
AnimationTimeDelta = 0.f;
|
||||
a_AnimationTimeDelta = 0.0;
|
||||
FramesPerSecond = 0.f;
|
||||
FramesPerSecondSmooth = 0.f;
|
||||
CConfiguration::setAndCallback("FpsSmoothing", cbFpsSmoothing);
|
||||
|
@ -78,26 +88,24 @@ void CGameTime::updateTime()
|
|||
// average of previous fps and this fps should be ok
|
||||
FramesPerSecond *= 3;
|
||||
|
||||
LocalTimeDelta = 0.f;
|
||||
AnimationTimeDelta = 0.f;
|
||||
a_LocalTimeDelta = 0.f;
|
||||
a_AnimationTimeDelta = 0.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
FramesPerSecond = 1000.0f / (float)deltams;
|
||||
|
||||
TLocalTime localTime = ((TLocalTime)timems) / 1000.0;
|
||||
LocalTimeDelta = localTime - LocalTime;
|
||||
LocalTime = localTime;
|
||||
a_LocalTimeDelta = localTime - LocalTime;
|
||||
|
||||
if (_SkipAnimationOnce)
|
||||
{
|
||||
AnimationTimeDelta = 0.f;
|
||||
a_AnimationTimeDelta = 0.f;
|
||||
_SkipAnimationOnce = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
AnimationTimeDelta = (TAnimationTime)LocalTimeDelta;
|
||||
AnimationTime += (TGlobalAnimationTime)LocalTimeDelta;
|
||||
a_AnimationTimeDelta = (TGlobalAnimationTime)a_LocalTimeDelta;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,6 +113,15 @@ void CGameTime::updateTime()
|
|||
FramesPerSecondSmooth = _FpsSmoother.getSmoothValue();
|
||||
}
|
||||
|
||||
void CGameTime::advanceTime(double f)
|
||||
{
|
||||
LocalTimeDelta = a_LocalTimeDelta * f;
|
||||
LocalTime += LocalTimeDelta;
|
||||
TGlobalAnimationTime atd = a_AnimationTimeDelta * f;
|
||||
AnimationTimeDelta = (NL3D::TAnimationTime)atd;
|
||||
AnimationTime += atd;
|
||||
}
|
||||
|
||||
void CGameTime::skipAnimationOnce()
|
||||
{
|
||||
_SkipAnimationOnce = true;
|
||||
|
|
|
@ -40,6 +40,9 @@ public:
|
|||
|
||||
static void updateTime();
|
||||
|
||||
/// Advance time to target time by factor f.
|
||||
static void advanceTime(double f);
|
||||
|
||||
/// Used when loading, this will skip changing animation time on the next update
|
||||
/// (updates aren't called during loading)
|
||||
static void skipAnimationOnce();
|
||||
|
|
|
@ -679,6 +679,7 @@ void loopIngame()
|
|||
|
||||
// 02. Update Time (deltas)
|
||||
CGameTime::updateTime();
|
||||
CGameTime::advanceTime(1.0);
|
||||
|
||||
// 03. Update Input (keyboard controls, etc)
|
||||
Driver->EventServer.pump(); // Pump user input messages
|
||||
|
|
Loading…
Reference in a new issue