From a32c0ce1669a89c892ac06a48b50eb8b67ecad82 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Wed, 16 Feb 2022 21:22:04 -0800 Subject: [PATCH] SyncBase: rename leeway variables --- QSB/OrbSync/TransformSync/NomaiOrbTransformSync.cs | 2 +- QSB/Syncs/SyncBase.cs | 12 ++++++------ QSB/Tools/ProbeTool/TransformSync/PlayerProbeSync.cs | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/QSB/OrbSync/TransformSync/NomaiOrbTransformSync.cs b/QSB/OrbSync/TransformSync/NomaiOrbTransformSync.cs index d80e3fdb..a5d11fca 100644 --- a/QSB/OrbSync/TransformSync/NomaiOrbTransformSync.cs +++ b/QSB/OrbSync/TransformSync/NomaiOrbTransformSync.cs @@ -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; diff --git a/QSB/Syncs/SyncBase.cs b/QSB/Syncs/SyncBase.cs index 1bd9b464..2cb73c2b 100644 --- a/QSB/Syncs/SyncBase.cs +++ b/QSB/Syncs/SyncBase.cs @@ -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; diff --git a/QSB/Tools/ProbeTool/TransformSync/PlayerProbeSync.cs b/QSB/Tools/ProbeTool/TransformSync/PlayerProbeSync.cs index a85acd3f..f77123be 100644 --- a/QSB/Tools/ProbeTool/TransformSync/PlayerProbeSync.cs +++ b/QSB/Tools/ProbeTool/TransformSync/PlayerProbeSync.cs @@ -14,7 +14,7 @@ namespace QSB.Tools.ProbeTool.TransformSync /// 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;