SnapshotInterpolation.Timescale: rename threshold parameters to absolute and update comment. because that's what they are.

This commit is contained in:
vis2k 2023-03-10 16:13:15 +08:00
parent f62d68dbf3
commit b1e62cfac3
2 changed files with 6 additions and 6 deletions

View File

@ -35,13 +35,13 @@ public static double Timescale(
double drift, // how far we are off from bufferTime
double catchupSpeed, // in % [0,1]
double slowdownSpeed, // in % [0,1]
double catchupNegativeThreshold, // in % of sendInteral (careful, we may run out of snapshots)
double catchupPositiveThreshold) // in % of sendInterval
double absoluteCatchupNegativeThreshold, // in seconds (careful, we may run out of snapshots)
double absoluteCatchupPositiveThreshold) // in seconds
{
// if the drift time is too large, it means we are behind more time.
// so we need to speed up the timescale.
// note the threshold should be sendInterval * catchupThreshold.
if (drift > catchupPositiveThreshold)
if (drift > absoluteCatchupPositiveThreshold)
{
// localTimeline += 0.001; // too simple, this would ping pong
return 1 + catchupSpeed; // n% faster
@ -50,7 +50,7 @@ public static double Timescale(
// if the drift time is too small, it means we are ahead of time.
// so we need to slow down the timescale.
// note the threshold should be sendInterval * catchupThreshold.
if (drift < catchupNegativeThreshold)
if (drift < absoluteCatchupNegativeThreshold)
{
// localTimeline -= 0.001; // too simple, this would ping pong
return 1 - slowdownSpeed; // n% slower

View File

@ -34,8 +34,8 @@ public class SnapshotInterpolationTests
// some defaults
const double catchupSpeed = 0.02;
const double slowdownSpeed = 0.04;
const double negativeThresh = -0.10;
const double positiveThresh = 0.10;
const double negativeThresh = -0.10; // in seconds
const double positiveThresh = 0.10; // in seconds
[SetUp]
public void SetUp()