public void Setup() { OrderedContiguous = CreateContiguousGameObjectStructs(ObjectCount); RandomizedContiguous = CreateContiguousGameObjectStructs(ObjectCount); RandomShuffle(RandomizedContiguous, new Unity.Mathematics.Random(RandomizerSeed)); OrderedNonContiguous = CreateNonContiguousGameObjectStructs(ObjectCount); RandomizedNonContiguous = CreateNonContiguousGameObjectStructs(ObjectCount); RandomShuffle(RandomizedNonContiguous, new Unity.Mathematics.Random(RandomizerSeed)); }
private static ContiguousList <GameObjectStruct> CreateContiguousGameObjectStructs(int count) { var l = new ContiguousList <GameObjectStruct>(Unity.Collections.Allocator.Persistent); for (int i = 0; i < count; i++) { l.Add(new GameObjectStruct { Velocity = new float3(1.0f, 0.0f, 1.0f), Random = new MockRandom((uint)i + 1) }); } return(l); }
public static void RandomShuffle(ContiguousList <GameObjectStruct> l, Unity.Mathematics.Random r) { for (int i = 0; i < l.Length; i++) { var idx = r.NextInt(0, l.Length); var tmp0 = l[idx]; var tmp1 = l[i]; tmp0.Random = new MockRandom((uint)i + 1); l[i] = tmp0; tmp1.Random = new MockRandom((uint)idx + 1); l[idx] = tmp1; } }