This commit is contained in:
vis2k 2023-03-16 16:05:52 +08:00
parent ab200a57ab
commit 774ae4f5b7

View File

@ -283,7 +283,7 @@ public static SnapshotMode StepTime<T>(
localTimeline += deltaTime * catchupMultiplier; localTimeline += deltaTime * catchupMultiplier;
// but clamp so it never gets too far behind. // but clamp so it never gets too far behind.
localTimeline = Math.Max(localTimeline, targetTime - bufferTime); localTimeline = Math.Max(localTimeline, targetTime - bufferTime);
Debug.LogWarning($"clamp behind: time={localTimeline:F3} target={targetTime:F3} bufferTime={bufferTime:F3} drift={drift:F3}"); Debug.LogWarning($"clamp behind: time={localTimeline:F3} target={targetTime:F3} bufferTime={bufferTime:F3} snaps={buffer.Count} drift={drift:F3}");
return SnapshotMode.ClampBehind; return SnapshotMode.ClampBehind;
} }
@ -294,15 +294,15 @@ public static SnapshotMode StepTime<T>(
localTimeline += deltaTime * slowdownMultiplier; localTimeline += deltaTime * slowdownMultiplier;
// but clamp so it never gets too far ahead. // but clamp so it never gets too far ahead.
localTimeline = Math.Min(localTimeline, targetTime + bufferTime); localTimeline = Math.Min(localTimeline, targetTime + bufferTime);
Debug.LogWarning($"clamp ahead: time={localTimeline:F3} target={targetTime:F3} bufferTime={bufferTime:F3} drift={drift:F3}"); Debug.LogWarning($"clamp ahead: time={localTimeline:F3} target={targetTime:F3} bufferTime={bufferTime:F3} snaps={buffer.Count} drift={drift:F3}");
return SnapshotMode.ClampAhead; return SnapshotMode.ClampAhead;
} }
/*
// just a little behind: move by delta time and accelerate n%. // just a little behind: move by delta time and accelerate n%.
if (drift > bufferTime / 2) if (drift > bufferTime / 2)
{ {
localTimeline += deltaTime * catchupMultiplier; localTimeline += deltaTime * catchupMultiplier;
Debug.LogWarning($"catchup: time={localTimeline:F3} target={targetTime:F3} bufferTime={bufferTime:F3} drift={drift:F3}"); Debug.LogWarning($"catchup: time={localTimeline:F3} target={targetTime:F3} bufferTime={bufferTime:F3} snaps={buffer.Count} drift={drift:F3}");
return SnapshotMode.Catchup; return SnapshotMode.Catchup;
} }
@ -310,10 +310,10 @@ public static SnapshotMode StepTime<T>(
if (drift < -bufferTime / 2) if (drift < -bufferTime / 2)
{ {
localTimeline += deltaTime * slowdownMultiplier; localTimeline += deltaTime * slowdownMultiplier;
Debug.LogWarning($"slowdown: time={localTimeline:F3} target={targetTime:F3} bufferTime={bufferTime:F3} drift={drift:F3}"); Debug.LogWarning($"slowdown: time={localTimeline:F3} target={targetTime:F3} bufferTime={bufferTime:F3} snaps={buffer.Count} drift={drift:F3}");
return SnapshotMode.Slowdown; return SnapshotMode.Slowdown;
} }
*/
// otherwise we are within normal range. // otherwise we are within normal range.
// move linearly. // move linearly.
localTimeline += deltaTime; localTimeline += deltaTime;