2014-12-07 19:09:38 -05:00
|
|
|
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
#include "CrashReportClientApp.h"
|
|
|
|
|
|
|
|
|
|
#include "MainLoopTiming.h"
|
|
|
|
|
#include "LaunchEngineLoop.h"
|
2015-01-22 08:04:21 -05:00
|
|
|
#include "TaskGraphInterfaces.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2015-04-22 17:58:53 -04:00
|
|
|
FMainLoopTiming::FMainLoopTiming(float InIdealTickRate, EMainLoopOptions::Type Options)
|
|
|
|
|
: IdealFrameTime(1.f / InIdealTickRate)
|
2014-03-14 14:13:41 -04:00
|
|
|
, ActualDeltaTime(0)
|
|
|
|
|
, LastTime(FPlatformTime::Seconds())
|
|
|
|
|
, bTickSlate(Options & EMainLoopOptions::UsingSlate)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FMainLoopTiming::Tick()
|
|
|
|
|
{
|
|
|
|
|
// Tick app logic
|
2015-01-22 08:04:21 -05:00
|
|
|
FTaskGraphInterface::Get().ProcessThreadUntilIdle(ENamedThreads::GameThread);
|
2014-03-14 14:13:41 -04:00
|
|
|
FTicker::GetCoreTicker().Tick(ActualDeltaTime);
|
|
|
|
|
|
|
|
|
|
#if !CRASH_REPORT_UNATTENDED_ONLY
|
|
|
|
|
// Tick SlateApplication
|
|
|
|
|
if (bTickSlate)
|
|
|
|
|
{
|
|
|
|
|
FSlateApplication::Get().PumpMessages();
|
|
|
|
|
FSlateApplication::Get().Tick();
|
|
|
|
|
}
|
|
|
|
|
#endif // !CRASH_REPORT_UNATTENDED_ONLY
|
|
|
|
|
|
|
|
|
|
static const float TickRate = 30.f;
|
|
|
|
|
static const float TickInterval = 1.f / TickRate;
|
|
|
|
|
|
|
|
|
|
// Sleep Throttling
|
|
|
|
|
// Copied from Community Portal - should be shared
|
|
|
|
|
FPlatformProcess::Sleep(FMath::Max<float>(0, IdealFrameTime - (FPlatformTime::Seconds() - LastTime)));
|
|
|
|
|
|
|
|
|
|
// Calculate deltas
|
|
|
|
|
const double AppTime = FPlatformTime::Seconds();
|
|
|
|
|
ActualDeltaTime = AppTime - LastTime;
|
|
|
|
|
LastTime = AppTime;
|
|
|
|
|
}
|