Skip to content

Commit 126880b

Browse files
committed
more cleanup
1 parent 758c6c8 commit 126880b

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

Basis/Packages/com.basis.framework/Networking/BasisNetworkManagement.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Collections.Concurrent;
88
using System.Threading;
99
using Unity.Jobs;
10+
using Unity.Mathematics;
1011
using UnityEngine;
1112
using UnityEngine.ResourceManagement.ResourceProviders;
1213
using static SerializableBasis;
@@ -174,6 +175,10 @@ public static void SimulateNetworkCompute(float UnscaledDeltaTime)
174175
}
175176

176177
BoneJobSystem = RemoteBoneJobSystem.Schedule(); // will always be a frame behind
178+
if (float.IsNaN(UnscaledDeltaTime) || math.isfinite(UnscaledDeltaTime))
179+
{
180+
UnscaledDeltaTime = 1e-3f;
181+
}
177182
double step = Math.Max(UnscaledDeltaTime, 0.0);
178183
for (int Index = 0; Index < Length; Index++)
179184
{

Basis/Packages/com.basis.framework/Networking/Recievers/BasisNetworkReceiver.cs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,25 +162,36 @@ public void Compute(float unscaledDeltaTime, double step)
162162
var first = Current;
163163
var last = Next;
164164

165-
double windowDuration = last.SecondsInterval > 0 ? last.SecondsInterval :first.SecondsInterval > 0 ? first.SecondsInterval : (1.0 / 60.0);
166-
167-
if (!double.IsFinite(windowDuration) || windowDuration <= 1e-6)
165+
double windowDuration;
166+
if (last.SecondsInterval > 0)
167+
{
168+
windowDuration = last.SecondsInterval;
169+
if (!double.IsFinite(windowDuration) || windowDuration <= 0.05f)
170+
{
171+
windowDuration = 1.0 / 60.0;
172+
}
173+
}
174+
else if (first.SecondsInterval > 0)
175+
{
176+
windowDuration = first.SecondsInterval;
177+
if (!double.IsFinite(windowDuration) || windowDuration <= 0.05f)
178+
{
179+
windowDuration = 1.0 / 60.0;
180+
}
181+
}
182+
else
168183
{
169-
windowDuration = 1e-3;
184+
windowDuration = 1.0 / 60.0;
170185
}
171186
float rate = 1f + CatchupGain * (StagedCount - TargetJitterDepth);
172187
rate = Mathf.Clamp(rate, MinPlaybackRate, MaxPlaybackRate);
173188

174189
float Computed = (float)((step / windowDuration) * rate);
175190

176-
if (float.IsNaN(Computed) || math.isfinite(Computed))
177-
{
178-
Computed = 0;
179-
}
180191
interpolationTime += Computed;
181-
if(float.IsNaN(interpolationTime) || math.isfinite(Computed))
192+
if(float.IsNaN(interpolationTime) || math.isfinite(interpolationTime))
182193
{
183-
interpolationTime = 1;
194+
interpolationTime = 1;//this fires
184195
}
185196
BasisRemoteNetworkDriver.SetFrameTiming(playerId, interpolationTime, unscaledDeltaTime);
186197

0 commit comments

Comments
 (0)