示例#1
0
 protected override void OnCreate()
 {
     m_MapSwitch          = false;
     m_PossibleCollisions = new NativeParallelMultiHashMap <int, PossibleCollision>(100, Allocator.Persistent);
     m_FrameCollisions0   = new NativeParallelHashMap <long, byte>(1000, Allocator.Persistent);
     m_FrameCollisions1   = new NativeParallelHashMap <long, byte>(1000, Allocator.Persistent);
     m_PartitionSystem    = World.GetOrCreateSystem <SpatialPartitionSystem>();
 }
        public static unsafe JobHandle Schedule <TJob>(this TJob jobData, NativeParallelMultiHashMap <int, int> hashMap, int minIndicesPerJobCount, JobHandle dependsOn = new JobHandle())
            where TJob : struct, IJobNativeMultiHashMapMergedSharedKeyIndices
        {
            var jobProducer = new JobNativeMultiHashMapMergedSharedKeyIndicesProducer <TJob>
            {
                HashMap = hashMap,
                JobData = jobData
            };

            var scheduleParams = new JobsUtility.JobScheduleParameters(
                UnsafeUtility.AddressOf(ref jobProducer)
                , JobNativeMultiHashMapMergedSharedKeyIndicesProducer <TJob> .Initialize()
                , dependsOn
#if UNITY_2020_2_OR_NEWER
                , ScheduleMode.Parallel
#else
                , ScheduleMode.Batched
#endif
                );

            return(JobsUtility.ScheduleParallelFor(ref scheduleParams, hashMap.GetUnsafeBucketData().bucketCapacityMask + 1, minIndicesPerJobCount));
        }
 void AllocateMaps(int capacity)
 {
     ColliderMap    = new NativeParallelMultiHashMap <int, ColliderData>(capacity, Allocator.Persistent);
     TargetMap      = new NativeParallelMultiHashMap <int, ColliderData>(capacity * 10, Allocator.Persistent);
     LargeColliders = new NativeQueue <LargeColliderData>(Allocator.Persistent);
 }