Skip to content

Commit 233188c

Browse files
test
Removing some of the debug information. Fixing whitespace issue. Adding a smooth lerp and non-smooth lerp pass.
1 parent 4c36581 commit 233188c

File tree

2 files changed

+20
-27
lines changed

2 files changed

+20
-27
lines changed

com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransform/NetworkTransformBase.cs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -632,27 +632,13 @@ protected bool PositionsMatchesValue(Vector3 positionToMatch)
632632
var nonAuthorityPosition = m_NonAuthoritativeTransform.transform.position;
633633
var auhtorityIsEqual = Approximately(authorityPosition, positionToMatch);
634634
var nonauthorityIsEqual = Approximately(nonAuthorityPosition, positionToMatch);
635-
var authorityTimeAndTick = string.Empty;
636-
var nonAuthorityTimeAndTick = string.Empty;
637-
638-
if (m_AuthoritativeTransform.NetworkManager)
639-
{
640-
var authTime = m_AuthoritativeTransform.NetworkManager.LocalTime;
641-
authorityTimeAndTick = $"[{authTime.Time}[{authTime.Tick}]]";
642-
}
643-
if (m_NonAuthoritativeTransform.NetworkManager)
644-
{
645-
var nonAuthTime = m_NonAuthoritativeTransform.NetworkManager.LocalTime;
646-
nonAuthorityTimeAndTick = $"[{nonAuthTime.Time}[{nonAuthTime.Tick}]]";
647-
}
648-
649635
if (!auhtorityIsEqual)
650636
{
651-
VerboseDebug($"[{authorityTimeAndTick}] Authority position {authorityPosition} != position to match: {positionToMatch} [{nonAuthorityTimeAndTick}]!");
637+
VerboseDebug($"Authority ({m_AuthoritativeTransform.name}) position {authorityPosition} != position to match: {positionToMatch}!");
652638
}
653639
if (!nonauthorityIsEqual)
654640
{
655-
VerboseDebug($"[{authorityTimeAndTick}] NonAuthority position {nonAuthorityPosition} != position to match: {positionToMatch} [{nonAuthorityTimeAndTick}]!");
641+
VerboseDebug($"NonAuthority ({m_NonAuthoritativeTransform.name}) position {nonAuthorityPosition} != position to match: {positionToMatch}!");
656642
}
657643
return auhtorityIsEqual && nonauthorityIsEqual;
658644
}

com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransform/NetworkTransformGeneral.cs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ namespace Unity.Netcode.RuntimeTests
1212
[TestFixture(HostOrServer.Host, Authority.ServerAuthority, NetworkTransform.InterpolationTypes.LerpExtrapolateBlend)]
1313
internal class NetworkTransformGeneral : NetworkTransformBase
1414
{
15+
public enum SmoothLerpSettings
16+
{
17+
SmoothLerp,
18+
NormalLerp
19+
}
20+
1521
public NetworkTransformGeneral(HostOrServer testWithHost, Authority authority, NetworkTransform.InterpolationTypes interpolationType) :
1622
base(testWithHost, authority, RotationCompression.None, Rotation.Euler, Precision.Full)
1723
{
@@ -281,38 +287,39 @@ public void TestMultipleExplicitSetStates([Values] Interpolation interpolation)
281287
/// This also tests that the original server authoritative model with client-owner driven NetworkTransforms is preserved.
282288
/// </remarks>
283289
[Test]
284-
public void NonAuthorityOwnerSettingStateTest([Values] Interpolation interpolation)
290+
public void NonAuthorityOwnerSettingStateTest([Values] Interpolation interpolation, [Values] SmoothLerpSettings smoothLerp)
285291
{
286292
var interpolate = interpolation == Interpolation.EnableInterpolate;
293+
var usingSmoothLerp = (smoothLerp == SmoothLerpSettings.SmoothLerp) && interpolate;
294+
var waitForDelay = usingSmoothLerp ? 1000 : 500;
295+
m_NonAuthoritativeTransform.PositionLerpSmoothing = usingSmoothLerp;
296+
m_NonAuthoritativeTransform.RotationLerpSmoothing = usingSmoothLerp;
297+
m_NonAuthoritativeTransform.ScaleLerpSmoothing = usingSmoothLerp;
298+
287299
m_AuthoritativeTransform.Interpolate = interpolate;
288300
m_NonAuthoritativeTransform.Interpolate = interpolate;
289301
m_NonAuthoritativeTransform.RotAngleThreshold = m_AuthoritativeTransform.RotAngleThreshold = 0.1f;
290302

291303
m_EnableVerboseDebug = true;
292304
VerboseDebug($"Target Frame Rate: {Application.targetFrameRate}");
293-
//m_AuthoritativeTransform.Teleport(Vector3.zero, Quaternion.identity, Vector3.one);
294-
//TimeTravelAdvanceTick();
295-
//var success = WaitForConditionOrTimeOutWithTimeTravel(() => PositionRotationScaleMatches(Vector3.zero, Quaternion.identity.eulerAngles, Vector3.one), 800);
296-
//Assert.True(success, $"Timed out waiting for initialization to be applied!");
297-
298305
// Test one parameter at a time first
299-
var newPosition = new Vector3(15f,-12f, 10f);
306+
var newPosition = usingSmoothLerp ? new Vector3(15f, -12f, 10f) : new Vector3(55f, -24f, 20f);
300307
var newRotation = Quaternion.Euler(1, 2, 3);
301308
var newScale = new Vector3(2.0f, 2.0f, 2.0f);
302309
m_NonAuthoritativeTransform.SetState(newPosition, null, null, interpolate);
303-
var success = WaitForConditionOrTimeOutWithTimeTravel(() => PositionsMatchesValue(newPosition), 1000);
310+
var success = WaitForConditionOrTimeOutWithTimeTravel(() => PositionsMatchesValue(newPosition), waitForDelay);
304311
Assert.True(success, $"Timed out waiting for non-authoritative position state request to be applied!\n {VerboseDebugLog}");
305312
Assert.True(Approximately(newPosition, m_AuthoritativeTransform.transform.position), "Authoritative position does not match!");
306313
Assert.True(Approximately(newPosition, m_NonAuthoritativeTransform.transform.position), "Non-Authoritative position does not match!");
307314
m_NonAuthoritativeTransform.SetState(null, newRotation, null, interpolate);
308-
success = WaitForConditionOrTimeOutWithTimeTravel(() => RotationMatchesValue(newRotation.eulerAngles), 1000);
315+
success = WaitForConditionOrTimeOutWithTimeTravel(() => RotationMatchesValue(newRotation.eulerAngles), waitForDelay);
309316
Assert.True(success, $"Timed out waiting for non-authoritative rotation state request to be applied!\n {VerboseDebugLog}");
310317
Assert.True(Approximately(newRotation.eulerAngles, m_AuthoritativeTransform.transform.rotation.eulerAngles), $"Authoritative rotation does not match!\n {VerboseDebugLog}");
311318
Assert.True(Approximately(newRotation.eulerAngles, m_NonAuthoritativeTransform.transform.rotation.eulerAngles), $"Non-Authoritative rotation does not match!\n {VerboseDebugLog}");
312319
Assert.True(Approximately(newRotation.eulerAngles, m_NonAuthoritativeTransform.transform.rotation.eulerAngles), $"Non-Authoritative rotation does not match!\n {VerboseDebugLog}");
313320

314321
m_NonAuthoritativeTransform.SetState(null, null, newScale, interpolate);
315-
success = WaitForConditionOrTimeOutWithTimeTravel(() => ScaleMatchesValue(newScale), 1000);
322+
success = WaitForConditionOrTimeOutWithTimeTravel(() => ScaleMatchesValue(newScale), waitForDelay);
316323
Assert.True(success, $"Timed out waiting for non-authoritative scale state request to be applied!\n {VerboseDebugLog}");
317324
Assert.True(Approximately(newScale, m_AuthoritativeTransform.transform.localScale), $"Authoritative scale does not match!\n {VerboseDebugLog}");
318325
Assert.True(Approximately(newScale, m_NonAuthoritativeTransform.transform.localScale), $"Non-Authoritative scale does not match!\n {VerboseDebugLog}");
@@ -323,7 +330,7 @@ public void NonAuthorityOwnerSettingStateTest([Values] Interpolation interpolati
323330
newScale = new Vector3(0.5f, 0.5f, 0.5f);
324331

325332
m_NonAuthoritativeTransform.SetState(newPosition, newRotation, newScale, interpolate);
326-
success = WaitForConditionOrTimeOutWithTimeTravel(() => PositionRotationScaleMatches(newPosition, newRotation.eulerAngles, newScale), 1000);
333+
success = WaitForConditionOrTimeOutWithTimeTravel(() => PositionRotationScaleMatches(newPosition, newRotation.eulerAngles, newScale), waitForDelay);
327334
Assert.True(success, $"Timed out waiting for non-authoritative position, rotation, and scale state request to be applied!\n {VerboseDebugLog}");
328335
Assert.True(Approximately(newPosition, m_AuthoritativeTransform.transform.position), $"Authoritative position does not match!\n {VerboseDebugLog}");
329336
Assert.True(Approximately(newPosition, m_NonAuthoritativeTransform.transform.position), $"Non-Authoritative position does not match!\n {VerboseDebugLog}");

0 commit comments

Comments
 (0)