コード例 #1
0
            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));
            }
コード例 #2
0
        private static NonContiguousList <GameObjectStruct> CreateNonContiguousGameObjectStructs(int count)
        {
            var l = new NonContiguousList <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);
        }
コード例 #3
0
        public unsafe static void RandomShuffle(NonContiguousList <GameObjectStruct> l, Unity.Mathematics.Random r)
        {
            for (int i = 0; i < l.Length; i++)
            {
                var idx  = r.NextInt(0, l.Length);
                var tmp0 = l.mData[idx];
                var tmp1 = l.mData[i];
                tmp0->Random = new MockRandom((uint)i + 1);
                l.mData[i]   = tmp0;

                tmp1->Random = new MockRandom((uint)idx + 1);
                l.mData[idx] = tmp1;
            }
        }