From ac61585f5c54abb39fffae933775e118337ec947 Mon Sep 17 00:00:00 2001 From: Kevin Date: Mon, 17 Jan 2022 16:51:59 -0500 Subject: [PATCH] Custom engine which caps framerate to 60fps and fixes timestep to 1/60 Custom engine which caps framerate to 60fps and fixes timestep to 1/60 --- KOFForever/Config/DefaultEngine.ini | 3 +++ KOFForever/KOFForever.uproject | 3 ++- .../Source/KOFForever/KOFForever.Build.cs | 2 +- .../KOFForever/Private/Engine/KOFEdEngine.cpp | 14 +++++++++++++ .../Private/Engine/KOFGameEngine.cpp | 14 +++++++++++++ .../KOFForever/Public/Engine/KOFEdEngine.h | 20 +++++++++++++++++++ .../KOFForever/Public/Engine/KOFGameEngine.h | 20 +++++++++++++++++++ 7 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 KOFForever/Source/KOFForever/Private/Engine/KOFEdEngine.cpp create mode 100644 KOFForever/Source/KOFForever/Private/Engine/KOFGameEngine.cpp create mode 100644 KOFForever/Source/KOFForever/Public/Engine/KOFEdEngine.h create mode 100644 KOFForever/Source/KOFForever/Public/Engine/KOFGameEngine.h diff --git a/KOFForever/Config/DefaultEngine.ini b/KOFForever/Config/DefaultEngine.ini index 32eb7ba..3236a5c 100644 --- a/KOFForever/Config/DefaultEngine.ini +++ b/KOFForever/Config/DefaultEngine.ini @@ -28,6 +28,9 @@ AppliedDefaultGraphicsPerformance=Maximum +ActiveGameNameRedirects=(OldGameName="/Script/TP_SideScroller",NewGameName="/Script/KOFForever") +ActiveClassRedirects=(OldClassName="TP_SideScrollerGameMode",NewClassName="KOFForeverGameMode") +ActiveClassRedirects=(OldClassName="TP_SideScrollerCharacter",NewClassName="KOFForeverCharacter") +GameEngine=/Script/KOFForever.KOFGameEngine +EditorEngine=/Script/UnrealEd.EditorEngine +UnrealEdEngine=/Script/KOFForever.KOFEdEngine [SystemSettingsEditor] r.Editor.SkipSourceControlCheckForEditablePackages = 1 diff --git a/KOFForever/KOFForever.uproject b/KOFForever/KOFForever.uproject index 0451eda..d44e0a2 100644 --- a/KOFForever/KOFForever.uproject +++ b/KOFForever/KOFForever.uproject @@ -11,7 +11,8 @@ "AdditionalDependencies": [ "Paper2D", "Engine", - "CoreUObject" + "CoreUObject", + "UnrealEd" ] } ] diff --git a/KOFForever/Source/KOFForever/KOFForever.Build.cs b/KOFForever/Source/KOFForever/KOFForever.Build.cs index fff1c36..3834df4 100644 --- a/KOFForever/Source/KOFForever/KOFForever.Build.cs +++ b/KOFForever/Source/KOFForever/KOFForever.Build.cs @@ -8,6 +8,6 @@ public class KOFForever : ModuleRules { PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; - PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "Paper2D" }); + PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "Paper2D", "UnrealEd" }); } } diff --git a/KOFForever/Source/KOFForever/Private/Engine/KOFEdEngine.cpp b/KOFForever/Source/KOFForever/Private/Engine/KOFEdEngine.cpp new file mode 100644 index 0000000..1bc722a --- /dev/null +++ b/KOFForever/Source/KOFForever/Private/Engine/KOFEdEngine.cpp @@ -0,0 +1,14 @@ + + + +#include "Engine/KOFEdEngine.h" + +void UKOFEdEngine::Tick(float DeltaSeconds, bool bIdleMode) +{ + Super::Tick(1.0f / 60.0f, bIdleMode); +} + +float UKOFEdEngine::GetMaxTickRate(float DeltaTime, bool bAllowFrameRateSmoothing) const +{ + return 60.0f; +} diff --git a/KOFForever/Source/KOFForever/Private/Engine/KOFGameEngine.cpp b/KOFForever/Source/KOFForever/Private/Engine/KOFGameEngine.cpp new file mode 100644 index 0000000..628f147 --- /dev/null +++ b/KOFForever/Source/KOFForever/Private/Engine/KOFGameEngine.cpp @@ -0,0 +1,14 @@ + + + +#include "Engine/KOFGameEngine.h" + +void UKOFGameEngine::Tick(float DeltaSeconds, bool bIdleMode) +{ + Super::Tick(1.0f / 60.0f, bIdleMode); +} + +float UKOFGameEngine::GetMaxTickRate(float DeltaTime, bool bAllowFrameRateSmoothing) const +{ + return 60.0f; +} diff --git a/KOFForever/Source/KOFForever/Public/Engine/KOFEdEngine.h b/KOFForever/Source/KOFForever/Public/Engine/KOFEdEngine.h new file mode 100644 index 0000000..9a73e01 --- /dev/null +++ b/KOFForever/Source/KOFForever/Public/Engine/KOFEdEngine.h @@ -0,0 +1,20 @@ + + +#pragma once + +#include "CoreMinimal.h" +#include "Editor/UnrealEdEngine.h" +#include "KOFEdEngine.generated.h" + +/** + * + */ +UCLASS() +class KOFFOREVER_API UKOFEdEngine : public UUnrealEdEngine +{ + GENERATED_BODY() + + virtual void Tick(float DeltaSeconds, bool bIdleMode) override; + + virtual float GetMaxTickRate(float DeltaTime, bool bAllowFrameRateSmoothing) const override; +}; diff --git a/KOFForever/Source/KOFForever/Public/Engine/KOFGameEngine.h b/KOFForever/Source/KOFForever/Public/Engine/KOFGameEngine.h new file mode 100644 index 0000000..f525b66 --- /dev/null +++ b/KOFForever/Source/KOFForever/Public/Engine/KOFGameEngine.h @@ -0,0 +1,20 @@ + + +#pragma once + +#include "CoreMinimal.h" +#include "Engine/GameEngine.h" +#include "KOFGameEngine.generated.h" + +/** + * + */ +UCLASS() +class KOFFOREVER_API UKOFGameEngine : public UGameEngine +{ + GENERATED_BODY() + + virtual void Tick(float DeltaSeconds, bool bIdleMode) override; + + virtual float GetMaxTickRate(float DeltaTime, bool bAllowFrameRateSmoothing) const override; +};