|
1 | 1 | using Basis.Network.Core.Compression; |
2 | 2 | using Basis.Scripts.Networking; |
3 | 3 | using System; |
4 | | -using System.Collections.Generic; |
5 | 4 | using System.Runtime.CompilerServices; |
6 | 5 | using Unity.Burst; |
7 | 6 | using Unity.Collections; |
8 | 7 | using Unity.Collections.LowLevel.Unsafe; |
9 | 8 | using Unity.Jobs; |
10 | 9 | using Unity.Mathematics; |
11 | | -using UnityEngine; |
12 | 10 |
|
13 | 11 | /// <summary> |
14 | 12 | /// Remote network driver that: |
@@ -237,6 +235,25 @@ public static unsafe void BeginWrite() |
237 | 235 | _ptrPoseFilterSeeded = (IntPtr)_poseFilterSeeded.GetUnsafePtr(); |
238 | 236 | } |
239 | 237 |
|
| 238 | + /// <summary> |
| 239 | + /// Grows the lazily-initialized region to include <paramref name="playerId"/> on the |
| 240 | + /// main thread. BeginWrite only covers [0, LargestNetworkReceiverID+1), and that |
| 241 | + /// high-water is recomputed at the tail of LateUpdate — AFTER RemoteBoneJobSystem.Schedule() |
| 242 | + /// reads these slots earlier in the same LateUpdate. A remote whose avatar calibrates within |
| 243 | + /// a frame of joining (cached/fallback avatars) registers a key the driver hasn't covered |
| 244 | + /// yet, so the bone-copy jobs read uninitialized NativeArray memory and emit a NaN pose. |
| 245 | + /// Call this at calibration, before the player is registered with RemoteBoneJobSystem. |
| 246 | + /// Completes any in-flight oneEuroJob first (same reason as SeedScaleState): EnsureInitialized |
| 247 | + /// writes arrays the job touches. |
| 248 | + /// </summary> |
| 249 | + public static void EnsureSlotInitialized(int playerId) |
| 250 | + { |
| 251 | + if (!_initialized) return; |
| 252 | + if ((uint)playerId >= FixedCapacity) return; |
| 253 | + oneEuroJob.Complete(); |
| 254 | + EnsureInitialized(playerId + 1); |
| 255 | + } |
| 256 | + |
240 | 257 | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
241 | 258 | public static unsafe void ResetPoseFilter(int index) |
242 | 259 | { |
|
0 commit comments