Skip to content

Commit 35b7fbe

Browse files
update
Exposing internal access to position and rotation interpolators for future tests and tools. Noticed the slerp for full precision rotation was only being applied when using Lerp, now it is for all interpolation types. Making the time to approximately reach adjustment be the default when there is no pending item to be consumed and slightly sooner when there is. Removing the adjustment to the slerp smoothing as this should be a consistantly applied value for all interpolation types.
1 parent 643329a commit 35b7fbe

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

com.unity.netcode.gameobjects/Runtime/Components/Interpolator/BufferedLinearInterpolator.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ private void TryConsumeFromBuffer(double renderTime, double minDeltaTime, double
335335
if (!noStateSet)
336336
{
337337
potentialItemNeedsProcessing = (potentialItem.TimeSent <= renderTime) && potentialItem.TimeSent >= InterpolateState.Target.Value.TimeSent;
338-
currentTargetTimeReached = InterpolateState.TargetTimeAproximatelyReached(potentialItemNeedsProcessing ? 1.0f : 0.85f) || InterpolateState.TargetReached;
338+
currentTargetTimeReached = InterpolateState.TargetTimeAproximatelyReached(potentialItemNeedsProcessing ? 1.15f : 1.0f) || InterpolateState.TargetReached;
339339
if (!InterpolateState.TargetReached)
340340
{
341341
InterpolateState.TargetReached = IsAproximately(InterpolateState.CurrentValue, InterpolateState.Target.Value.Item);
@@ -463,7 +463,7 @@ internal T Update(float deltaTime, double tickLatencyAsTime, double minDeltaTime
463463
if (LerpSmoothEnabled)
464464
{
465465
// Apply the smooth lerp to the target to help smooth the final value.
466-
InterpolateState.CurrentValue = Interpolate(InterpolateState.CurrentValue, targetValue, deltaTime / (MaximumInterpolationTime * 0.3333f));
466+
InterpolateState.CurrentValue = Interpolate(InterpolateState.CurrentValue, targetValue, deltaTime / MaximumInterpolationTime);
467467
}
468468
else
469469
{
@@ -574,10 +574,10 @@ public T Update(float deltaTime, double renderTime, double serverTime)
574574
// The original BufferedLinearInterpolator lerping script to assure the Smooth Dampening updates do not impact
575575
// this specific behavior.
576576
float t = 1.0f;
577-
double range = InterpolateState.EndTime - InterpolateState.StartTime;
578-
if (range > k_SmallValue)
577+
InterpolateState.TimeToTargetValue = InterpolateState.EndTime - InterpolateState.StartTime;
578+
if (InterpolateState.TimeToTargetValue > k_SmallValue)
579579
{
580-
t = (float)((renderTime - InterpolateState.StartTime) / range);
580+
t = (float)((renderTime - InterpolateState.StartTime) / InterpolateState.TimeToTargetValue);
581581

582582
if (t < 0.0f)
583583
{

com.unity.netcode.gameobjects/Runtime/Components/NetworkTransform.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4045,6 +4045,15 @@ public void ClearStats()
40454045
PositionStats.Clear();
40464046
}
40474047
#endif
4048+
internal BufferedLinearInterpolatorVector3 GetPositionInterpolator()
4049+
{
4050+
return m_PositionInterpolator;
4051+
}
4052+
4053+
internal BufferedLinearInterpolatorQuaternion GetRotationInterpolator()
4054+
{
4055+
return m_RotationInterpolator;
4056+
}
40484057

40494058
// Non-Authority
40504059
private void UpdateInterpolation()
@@ -4145,13 +4154,12 @@ private void UpdateInterpolation()
41454154
m_PreviousRotationLerpSmoothing = RotationLerpSmoothing;
41464155
m_RotationInterpolator.ResetCurrentState();
41474156
}
4148-
4157+
// When using half precision Lerp towards the target rotation.
4158+
// When using full precision Slerp towards the target rotation.
4159+
/// <see cref="BufferedLinearInterpolatorQuaternion.IsSlerp"/>
4160+
m_RotationInterpolator.IsSlerp = !UseHalfFloatPrecision;
41494161
if (RotationInterpolationType == InterpolationTypes.Lerp)
41504162
{
4151-
// When using half precision Lerp towards the target rotation.
4152-
// When using full precision Slerp towards the target rotation.
4153-
/// <see cref="BufferedLinearInterpolatorQuaternion.IsSlerp"/>
4154-
m_RotationInterpolator.IsSlerp = !UseHalfFloatPrecision;
41554163
m_RotationInterpolator.Update(cachedDeltaTime, tickLatencyAsTime, currentTime);
41564164
}
41574165
else

0 commit comments

Comments
 (0)