SyncBase: rename leeway variables

This commit is contained in:
JohnCorby 2022-02-16 21:22:04 -08:00
parent b23c5ac1aa
commit a32c0ce166
3 changed files with 8 additions and 8 deletions

View File

@ -16,7 +16,7 @@ namespace QSB.OrbSync.TransformSync
protected override bool CheckValid() => AttachedTransform && base.CheckValid();
protected override bool UseInterpolation => true;
protected override float DistanceLeeway => 1f;
protected override float DistanceChangeThreshold => 1f;
protected override Transform InitLocalTransform() => _qsbOrb.AttachedObject.transform;
protected override Transform InitRemoteTransform() => _qsbOrb.AttachedObject.transform;

View File

@ -118,10 +118,10 @@ namespace QSB.Syncs
public override string ToString() => (IsPlayerObject ? $"{Player.PlayerId}." : string.Empty)
+ $"{netId}:{GetType().Name} ({Name})";
protected virtual float DistanceLeeway => 5f;
protected virtual float AngleLeeway => 5f;
private float _prevDistance;
private float _prevAngle;
protected virtual float DistanceChangeThreshold => 5f;
private const float AngleChangeThreshold = 90f;
private float _prevDistance = float.MinValue;
private float _prevAngle = float.MinValue;
protected const float SmoothTime = 0.1f;
private Vector3 _positionSmoothVelocity;
private Quaternion _rotationSmoothVelocity;
@ -265,13 +265,13 @@ namespace QSB.Syncs
private void Interpolate()
{
var distance = Vector3.Distance(SmoothPosition, transform.position);
SmoothPosition = Mathf.Abs(distance - _prevDistance) > DistanceLeeway ?
SmoothPosition = Mathf.Abs(distance - _prevDistance) > DistanceChangeThreshold ?
transform.position :
Vector3.SmoothDamp(SmoothPosition, transform.position, ref _positionSmoothVelocity, SmoothTime);
_prevDistance = distance;
var angle = Quaternion.Angle(SmoothRotation, transform.rotation);
SmoothRotation = Mathf.Abs(angle - _prevAngle) > AngleLeeway ?
SmoothRotation = Mathf.Abs(angle - _prevAngle) > AngleChangeThreshold ?
transform.rotation :
QuaternionHelper.SmoothDamp(SmoothRotation, transform.rotation, ref _rotationSmoothVelocity, SmoothTime);
_prevAngle = angle;

View File

@ -14,7 +14,7 @@ namespace QSB.Tools.ProbeTool.TransformSync
/// </summary>
protected override bool CheckValid() => AttachedTransform && base.CheckValid();
protected override float DistanceLeeway => 10f;
protected override float DistanceChangeThreshold => 10f;
protected override bool UseInterpolation => true;
protected override bool AllowInactiveAttachedObject => true;
protected override bool IsPlayerObject => true;