@@ -41,7 +41,6 @@ public class BasisNetworkReceiver : BasisNetworkPlayer
4141 private float interpolationTime = 0f ; // 0..1 over current->next window
4242
4343 public bool HasBufferHolds ;
44- public bool PassedSimulate = false ;
4544
4645 // ---------------- staging (ring buffer) ----------------
4746 private const int MaxStage = 64 ;
@@ -180,16 +179,12 @@ public void Compute(float unscaledDeltaTime)
180179 {
181180 windowDuration = 1e-3 ;
182181 }
183-
184- double step = Math . Max ( unscaledDeltaTime , 0.0 ) ;
185-
186- int depth = _stagedRing . Count ;
187- float rate = 1f + CatchupGain * ( depth - TargetJitterDepth ) ;
182+ float rate = 1f + CatchupGain * ( StagedCount - TargetJitterDepth ) ;
188183 rate = Mathf . Clamp ( rate , MinPlaybackRate , MaxPlaybackRate ) ;
189- interpolationTime += ( float ) ( ( step / windowDuration ) * rate ) ;
190- PassedSimulate = BasisRemoteNetworkDriver . SetFrameTiming ( playerId , interpolationTime , unscaledDeltaTime ) ;
184+ interpolationTime += ( float ) ( ( ( double ) unscaledDeltaTime / windowDuration ) * rate ) ;
185+ BasisRemoteNetworkDriver . SetFrameTiming ( playerId , interpolationTime , unscaledDeltaTime ) ;
191186
192- if ( PassedSimulate && SentLatest )
187+ if ( SentLatest )
193188 {
194189
195190 BasisRemoteNetworkDriver . SetFrameInputs (
@@ -201,24 +196,26 @@ public void Compute(float unscaledDeltaTime)
201196 ) ;
202197
203198 BasisRemoteNetworkDriver . SetMuscleWindow ( playerId , first . Muscles , last . Muscles ) ;
199+ IsDataReady = true ;
204200 SentLatest = false ;
205201 }
206202 }
207203 }
208-
204+ public bool IsDataReady = false ;
209205 /// <summary>
210206 /// Main-thread application step. Pulls posed outputs from the driver and applies
211207 /// body position/rotation/muscles to the avatar via PoseHandler.
212208 /// </summary>
213209 public void Apply ( )
214210 {
215- if ( PassedSimulate )
211+ if ( IsDataReady )
216212 {
217213 // These outputs should be stable when simulate passed.
218214 BasisRemoteNetworkDriver . GetOutputs_NoAlloc ( playerId , out bool outscale , out var ApplyingRotation , out float3 scaledBody ) ;
219- BasisRemoteNetworkDriver . GetMuscleArray ( playerId , ref HumanPose , EyesAndMouth , EyesAndMouthOffset , EyeAndMouthCountInBytes ) ;
215+ BasisRemoteNetworkDriver . GetMuscleArray ( playerId , ref HumanPose , EyesAndMouth , EyesAndMouthOffset , EyeAndMouthCountInBytes ) ;
220216 HumanPose . bodyPosition = scaledBody ;
221217 HumanPose . bodyRotation = ApplyingRotation ;
218+
222219 if ( outscale )
223220 {
224221 ApplyScale ( ) ;
@@ -231,9 +228,8 @@ public void Apply()
231228 DidLastAvatarTransformChanged = false ;
232229 }
233230 }
234- PassedSimulate = false ;
235231 }
236- if ( hasRequiredData )
232+ if ( IsDataReady && hasRequiredData )
237233 {
238234 PoseHandler . SetHumanPose ( ref HumanPose ) ;
239235 if ( HasOverridenDestination )
@@ -264,8 +260,6 @@ public override void Initialize()
264260 StagedCount = 0 ;
265261 ClearAndRelease ( ) ;
266262 interpolationTime = 0f ;
267- PassedSimulate = false ;
268-
269263 // Clear any packets that arrived before init (rare, but safe)
270264 while ( PayloadQueue . TryDequeue ( out var buf ) )
271265 {
@@ -349,7 +343,6 @@ public override void DeInitialize()
349343 }
350344
351345 AudioReceiverModule ? . OnDestroy ( ) ;
352- PassedSimulate = false ;
353346 }
354347
355348 public void ReceiveNetworkAudio ( ServerAudioSegmentMessage msg )
0 commit comments