From e04293f980466882ee19b11bf467409d8eb007c4 Mon Sep 17 00:00:00 2001 From: vis2k Date: Fri, 3 Jun 2022 16:36:23 +0700 Subject: [PATCH] breaking: SnapshotInterpolation.Compute(): add 'out catchup' for debugging --- .../NetworkTransformBase.cs | 8 ++++--- .../SnapshotInterpolation.cs | 8 ++++--- .../Editor/SnapshotInterpolationTests.cs | 22 +++++++++---------- Packages/manifest.json | 12 +++++----- Packages/packages-lock.json | 16 +++++++------- ProjectSettings/ProjectVersion.txt | 4 ++-- UserSettings/EditorUserSettings.asset | 7 ++++++ 7 files changed, 44 insertions(+), 33 deletions(-) diff --git a/Assets/Mirror/Components/NetworkTransform2k/NetworkTransformBase.cs b/Assets/Mirror/Components/NetworkTransform2k/NetworkTransformBase.cs index 839064c88..15622805b 100644 --- a/Assets/Mirror/Components/NetworkTransform2k/NetworkTransformBase.cs +++ b/Assets/Mirror/Components/NetworkTransform2k/NetworkTransformBase.cs @@ -398,7 +398,8 @@ void UpdateServer() bufferTime, serverBuffer, catchupThreshold, catchupMultiplier, Interpolate, - out NTSnapshot computed)) + out NTSnapshot computed, + out _)) { NTSnapshot start = serverBuffer.Values[0]; NTSnapshot goal = serverBuffer.Values[1]; @@ -487,7 +488,8 @@ void UpdateClient() bufferTime, clientBuffer, catchupThreshold, catchupMultiplier, Interpolate, - out NTSnapshot computed)) + out NTSnapshot computed, + out _)) { NTSnapshot start = clientBuffer.Values[0]; NTSnapshot goal = clientBuffer.Values[1]; @@ -645,7 +647,7 @@ protected virtual void OnValidate() // buffer limit should be at least multiplier to have enough in there bufferSizeLimit = Mathf.Max(bufferTimeMultiplier, bufferSizeLimit); } - + public override bool OnSerialize(NetworkWriter writer, bool initialState) { // sync target component's position on spawn. diff --git a/Assets/Mirror/Runtime/SnapshotInterpolation/SnapshotInterpolation.cs b/Assets/Mirror/Runtime/SnapshotInterpolation/SnapshotInterpolation.cs index bc685d775..ab836a8c6 100644 --- a/Assets/Mirror/Runtime/SnapshotInterpolation/SnapshotInterpolation.cs +++ b/Assets/Mirror/Runtime/SnapshotInterpolation/SnapshotInterpolation.cs @@ -151,6 +151,7 @@ public static void GetFirstSecondAndDelta(SortedList buffer, out T // => needs to be Func instead of a function in the Snapshot // interface because that would require boxing. // => make sure to only allocate that function once. + // out catchup: useful for debugging only. // // returns // 'true' if it spit out a snapshot to apply. @@ -164,7 +165,8 @@ public static bool Compute( int catchupThreshold, float catchupMultiplier, Func Interpolate, - out T computed) + out T computed, + out double catchup) where T : Snapshot { // we buffer snapshots for 'bufferTime' @@ -183,7 +185,7 @@ public static bool Compute( // with high latency // -> at any given time, we are interpolating from snapshot A to B // => seems like A.timestamp += deltaTime is a good way to do it - + catchup = 0; computed = default; //Debug.Log($"{name} snapshotbuffer={buffer.Count}"); @@ -201,7 +203,7 @@ public static bool Compute( // // if '0' catchup then we multiply by '1', which changes nothing. // (faster branch prediction) - double catchup = CalculateCatchup(buffer, catchupThreshold, catchupMultiplier); + catchup = CalculateCatchup(buffer, catchupThreshold, catchupMultiplier); deltaTime *= (1 + catchup); // interpolationTime starts at 0 and we add deltaTime to move diff --git a/Assets/Mirror/Tests/Editor/SnapshotInterpolationTests.cs b/Assets/Mirror/Tests/Editor/SnapshotInterpolationTests.cs index 1ba07b1f9..b08776e37 100644 --- a/Assets/Mirror/Tests/Editor/SnapshotInterpolationTests.cs +++ b/Assets/Mirror/Tests/Editor/SnapshotInterpolationTests.cs @@ -240,7 +240,7 @@ public void Compute_Step1_DefaultDoesNothing() float bufferTime = 0; int catchupThreshold = Int32.MaxValue; float catchupMultiplier = 0; - bool result = SnapshotInterpolation.Compute(localTime, deltaTime, ref interpolationTime, bufferTime, buffer, catchupThreshold, catchupMultiplier, SimpleSnapshot.Interpolate, out SimpleSnapshot computed); + bool result = SnapshotInterpolation.Compute(localTime, deltaTime, ref interpolationTime, bufferTime, buffer, catchupThreshold, catchupMultiplier, SimpleSnapshot.Interpolate, out SimpleSnapshot computed, out _); // should not spit out any snapshot to apply Assert.That(result, Is.False); @@ -273,7 +273,7 @@ public void Compute_Step3_WaitsUntilBufferTime() float bufferTime = 2; int catchupThreshold = Int32.MaxValue; float catchupMultiplier = 0; - bool result = SnapshotInterpolation.Compute(localTime, deltaTime, ref interpolationTime, bufferTime, buffer, catchupThreshold, catchupMultiplier, SimpleSnapshot.Interpolate, out SimpleSnapshot computed); + bool result = SnapshotInterpolation.Compute(localTime, deltaTime, ref interpolationTime, bufferTime, buffer, catchupThreshold, catchupMultiplier, SimpleSnapshot.Interpolate, out SimpleSnapshot computed, out _); // should not spit out any snapshot to apply Assert.That(result, Is.False); @@ -301,7 +301,7 @@ public void Compute_Step3_WaitsForSecondSnapshot() float bufferTime = 1; int catchupThreshold = Int32.MaxValue; float catchupMultiplier = 0; - bool result = SnapshotInterpolation.Compute(localTime, deltaTime, ref interpolationTime, bufferTime, buffer, catchupThreshold, catchupMultiplier, SimpleSnapshot.Interpolate, out SimpleSnapshot computed); + bool result = SnapshotInterpolation.Compute(localTime, deltaTime, ref interpolationTime, bufferTime, buffer, catchupThreshold, catchupMultiplier, SimpleSnapshot.Interpolate, out SimpleSnapshot computed, out _); // should not spit out any snapshot to apply Assert.That(result, Is.False); @@ -334,7 +334,7 @@ public void Compute_Step4_InterpolateWithTwoOldEnoughSnapshots() float bufferTime = 2; int catchupThreshold = Int32.MaxValue; float catchupMultiplier = 0; - bool result = SnapshotInterpolation.Compute(localTime, deltaTime, ref interpolationTime, bufferTime, buffer, catchupThreshold, catchupMultiplier, SimpleSnapshot.Interpolate, out SimpleSnapshot computed); + bool result = SnapshotInterpolation.Compute(localTime, deltaTime, ref interpolationTime, bufferTime, buffer, catchupThreshold, catchupMultiplier, SimpleSnapshot.Interpolate, out SimpleSnapshot computed, out _); // should spit out the interpolated snapshot Assert.That(result, Is.True); @@ -371,7 +371,7 @@ public void Compute_Step4_InterpolateWithThreeOldEnoughSnapshots() float bufferTime = 2; int catchupThreshold = Int32.MaxValue; float catchupMultiplier = 0; - bool result = SnapshotInterpolation.Compute(localTime, deltaTime, ref interpolationTime, bufferTime, buffer, catchupThreshold, catchupMultiplier, SimpleSnapshot.Interpolate, out SimpleSnapshot computed); + bool result = SnapshotInterpolation.Compute(localTime, deltaTime, ref interpolationTime, bufferTime, buffer, catchupThreshold, catchupMultiplier, SimpleSnapshot.Interpolate, out SimpleSnapshot computed, out _); // should spit out the interpolated snapshot Assert.That(result, Is.True); @@ -408,7 +408,7 @@ public void Compute_Step4_InterpolateAfterLongPause() float bufferTime = 2; int catchupThreshold = Int32.MaxValue; float catchupMultiplier = 0; - bool result = SnapshotInterpolation.Compute(localTime, deltaTime, ref interpolationTime, bufferTime, buffer, catchupThreshold, catchupMultiplier, SimpleSnapshot.Interpolate, out SimpleSnapshot computed); + bool result = SnapshotInterpolation.Compute(localTime, deltaTime, ref interpolationTime, bufferTime, buffer, catchupThreshold, catchupMultiplier, SimpleSnapshot.Interpolate, out SimpleSnapshot computed, out _); // should spit out the interpolated snapshot Assert.That(result, Is.True); @@ -458,7 +458,7 @@ public void Compute_Step4_InterpolateWithCatchup() double deltaTime = 0.5; double interpolationTime = 0; float bufferTime = 2; - bool result = SnapshotInterpolation.Compute(localTime, deltaTime, ref interpolationTime, bufferTime, buffer, catchupThreshold, catchupMultiplier, SimpleSnapshot.Interpolate, out SimpleSnapshot computed); + bool result = SnapshotInterpolation.Compute(localTime, deltaTime, ref interpolationTime, bufferTime, buffer, catchupThreshold, catchupMultiplier, SimpleSnapshot.Interpolate, out SimpleSnapshot computed, out _); // should spit out the interpolated snapshot Assert.That(result, Is.True); @@ -519,7 +519,7 @@ public void Compute_Step5_OvershootWithoutEnoughSnapshots() float bufferTime = 2; int catchupThreshold = Int32.MaxValue; float catchupMultiplier = 0; - bool result = SnapshotInterpolation.Compute(localTime, deltaTime, ref interpolationTime, bufferTime, buffer, catchupThreshold, catchupMultiplier, SimpleSnapshot.Interpolate, out SimpleSnapshot computed); + bool result = SnapshotInterpolation.Compute(localTime, deltaTime, ref interpolationTime, bufferTime, buffer, catchupThreshold, catchupMultiplier, SimpleSnapshot.Interpolate, out SimpleSnapshot computed, out _); // should spit out the interpolated snapshot Assert.That(result, Is.True); @@ -587,7 +587,7 @@ public void Compute_Step5_OvershootWithEnoughSnapshots_NextIsntOldEnough() float bufferTime = 2; int catchupThreshold = Int32.MaxValue; float catchupMultiplier = 0; - bool result = SnapshotInterpolation.Compute(localTime, deltaTime, ref interpolationTime, bufferTime, buffer, catchupThreshold, catchupMultiplier, SimpleSnapshot.Interpolate, out SimpleSnapshot computed); + bool result = SnapshotInterpolation.Compute(localTime, deltaTime, ref interpolationTime, bufferTime, buffer, catchupThreshold, catchupMultiplier, SimpleSnapshot.Interpolate, out SimpleSnapshot computed, out _); // should still spit out a result between first & second. Assert.That(result, Is.True); @@ -647,7 +647,7 @@ public void Compute_Step5_OvershootWithEnoughSnapshots_MovesToNextSnapshotIfOldE float bufferTime = 2; int catchupThreshold = Int32.MaxValue; float catchupMultiplier = 0; - bool result = SnapshotInterpolation.Compute(localTime, deltaTime, ref interpolationTime, bufferTime, buffer, catchupThreshold, catchupMultiplier, SimpleSnapshot.Interpolate, out SimpleSnapshot computed); + bool result = SnapshotInterpolation.Compute(localTime, deltaTime, ref interpolationTime, bufferTime, buffer, catchupThreshold, catchupMultiplier, SimpleSnapshot.Interpolate, out SimpleSnapshot computed, out _); // should spit out the interpolated snapshot Assert.That(result, Is.True); @@ -703,7 +703,7 @@ public void Compute_Step5_OvershootWithEnoughSnapshots_2x_MovesToSecondNextSnaps float bufferTime = 2; int catchupThreshold = Int32.MaxValue; float catchupMultiplier = 0; - bool result = SnapshotInterpolation.Compute(localTime, deltaTime, ref interpolationTime, bufferTime, buffer, catchupThreshold, catchupMultiplier, SimpleSnapshot.Interpolate, out SimpleSnapshot computed); + bool result = SnapshotInterpolation.Compute(localTime, deltaTime, ref interpolationTime, bufferTime, buffer, catchupThreshold, catchupMultiplier, SimpleSnapshot.Interpolate, out SimpleSnapshot computed, out _); // should spit out the interpolated snapshot Assert.That(result, Is.True); diff --git a/Packages/manifest.json b/Packages/manifest.json index 61f083011..7fc4ba286 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -2,14 +2,14 @@ "dependencies": { "com.unity.2d.sprite": "1.0.0", "com.unity.2d.tilemap": "1.0.0", - "com.unity.ide.rider": "2.0.7", - "com.unity.ide.visualstudio": "2.0.12", - "com.unity.ide.vscode": "1.2.4", - "com.unity.test-framework": "1.1.30", - "com.unity.testtools.codecoverage": "1.0.0", + "com.unity.ide.rider": "3.0.13", + "com.unity.ide.visualstudio": "2.0.14", + "com.unity.ide.vscode": "1.2.5", + "com.unity.test-framework": "1.1.31", + "com.unity.testtools.codecoverage": "1.0.1", "com.unity.textmeshpro": "3.0.6", "com.unity.ugui": "1.0.0", - "com.unity.xr.legacyinputhelpers": "2.1.8", + "com.unity.xr.legacyinputhelpers": "2.1.9", "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", "com.unity.modules.animation": "1.0.0", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 90dfa2766..c022e4420 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -20,16 +20,16 @@ "url": "https://packages.unity.com" }, "com.unity.ide.rider": { - "version": "2.0.7", + "version": "3.0.13", "depth": 0, "source": "registry", "dependencies": { - "com.unity.test-framework": "1.1.1" + "com.unity.ext.nunit": "1.0.6" }, "url": "https://packages.unity.com" }, "com.unity.ide.visualstudio": { - "version": "2.0.12", + "version": "2.0.14", "depth": 0, "source": "registry", "dependencies": { @@ -38,21 +38,21 @@ "url": "https://packages.unity.com" }, "com.unity.ide.vscode": { - "version": "1.2.4", + "version": "1.2.5", "depth": 0, "source": "registry", "dependencies": {}, "url": "https://packages.unity.com" }, "com.unity.settings-manager": { - "version": "1.0.1", + "version": "1.0.3", "depth": 1, "source": "registry", "dependencies": {}, "url": "https://packages.unity.com" }, "com.unity.test-framework": { - "version": "1.1.30", + "version": "1.1.31", "depth": 0, "source": "registry", "dependencies": { @@ -63,7 +63,7 @@ "url": "https://packages.unity.com" }, "com.unity.testtools.codecoverage": { - "version": "1.0.0", + "version": "1.0.1", "depth": 0, "source": "registry", "dependencies": { @@ -91,7 +91,7 @@ } }, "com.unity.xr.legacyinputhelpers": { - "version": "2.1.8", + "version": "2.1.9", "depth": 0, "source": "registry", "dependencies": { diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index def29338c..90d6509f8 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2020.3.26f1 -m_EditorVersionWithRevision: 2020.3.26f1 (7298b473bc1a) +m_EditorVersion: 2021.3.1f1 +m_EditorVersionWithRevision: 2021.3.1f1 (3b70a0754835) diff --git a/UserSettings/EditorUserSettings.asset b/UserSettings/EditorUserSettings.asset index 22d1c44e9..85aac73ad 100644 --- a/UserSettings/EditorUserSettings.asset +++ b/UserSettings/EditorUserSettings.asset @@ -5,6 +5,9 @@ EditorUserSettings: m_ObjectHideFlags: 0 serializedVersion: 4 m_ConfigSettings: + RecentlyUsedSceneGuid-0: + value: 5500060752055c0b5a590f734677084912154f287d7e71312f78486abbe13160 + flags: 0 RecentlyUsedScenePath-0: value: 2242470311464676041c1e2d026c7a08171a0826293b691228271e3befe12633add435ece93f2c730a01ea3201701431fb1e10 flags: 0 @@ -16,9 +19,13 @@ EditorUserSettings: m_VCDebugCmd: 0 m_VCDebugOut: 0 m_SemanticMergeMode: 2 + m_DesiredImportWorkerCount: 2 + m_StandbyImportWorkerCount: 2 + m_IdleImportWorkerShutdownDelay: 60000 m_VCShowFailedCheckout: 1 m_VCOverwriteFailedCheckoutAssets: 1 m_VCProjectOverlayIcons: 1 m_VCHierarchyOverlayIcons: 1 m_VCOtherOverlayIcons: 1 m_VCAllowAsyncUpdate: 0 + m_ArtifactGarbageCollection: 1