File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -292,6 +292,10 @@ KSP_COMMUNITY_FIXES
292292 // speed up reading) at the cost of human readability.
293293 SkipIndentsOnSavesAndCraftFiles = false
294294
295+ // After using physics warp, Unity' s max physics dt will never be returned to the value specified in
296+ // game settings which can degrade performance in some cases
297+ RestoreMaxPhysicsDT = true
298+
295299 // ##########################
296300 // Modding
297301 // ##########################
Original file line number Diff line number Diff line change 1+ using HarmonyLib ;
2+ using System ;
3+ using System . Collections . Generic ;
4+ using System . Linq ;
5+ using System . Text ;
6+ using System . Threading . Tasks ;
7+ using UnityEngine ;
8+
9+ namespace KSPCommunityFixes . BugFixes
10+ {
11+ public class RestoreMaxPhysicsDT : BasePatch
12+ {
13+ protected override void ApplyPatches ( List < PatchInfo > patches )
14+ {
15+ patches . Add ( new PatchInfo (
16+ PatchMethodType . Prefix ,
17+ AccessTools . Method ( typeof ( TimeWarp ) , "updateRate" ) ,
18+ this ) ) ;
19+ }
20+
21+ static void TimeWarp_updateRate_Prefix ( )
22+ {
23+ // when you use physics warp, it increases Time.fixedDeltaTime
24+ // Unity will internally increase maximumDeltaTime to be at least as high as fixedDeltaTime
25+ // But nothing in the KSP code will ever return maximumDeltaTime to the value from the settings when time warp is over
26+ // Setting it just before TimeWarp sets fixedDeltaTime guarantees that all points of code will have the correct value
27+ Time . maximumDeltaTime = GameSettings . PHYSICS_FRAME_DT_LIMIT ;
28+ }
29+ }
30+ }
Original file line number Diff line number Diff line change 104104 <Compile Include =" Modding\ModUpgradePipeline.cs" />
105105 <Compile Include =" Performance\AsteroidAndCometDrillCache.cs" />
106106 <Compile Include =" BugFixes\DoubleCurvePreserveTangents.cs" />
107+ <Compile Include =" BugFixes\RestoreMaxPhysicsDT.cs" />
107108 <Compile Include =" Performance\CommNetThrottling.cs" />
108109 <Compile Include =" Performance\DisableMapUpdateInFlight.cs" />
109110 <Compile Include =" Performance\MemoryLeaks.cs" />
You can’t perform that action at this time.
0 commit comments