JobHandle ProduceMeshColliders( NativeHashMap <Hash128, MeshInput> inputs, NativeList <float3> vertices, NativeList <int3> indices, out NativeHashMap <Hash128, BlobAssetReference <Collider> > meshColliders, JobHandle inputDeps = default ) { // create collider blob assets var meshCollidersArray = new NativeArray <KeyValuePair <Hash128, BlobAssetReference <Collider> > >(inputs.Count(), Allocator.TempJob); const int arrayLength = 5; var jobHandle = new ProduceMeshCollidersJob { InputKeys = inputs.GetKeyArray(Allocator.TempJob), InputValues = inputs.GetValueArray(Allocator.TempJob), AllVertices = vertices, AllIndices = indices, Output = meshCollidersArray }.Schedule(inputs.Count(), arrayLength, inputDeps); // put blob assets into hash map meshColliders = new NativeHashMap <Hash128, BlobAssetReference <Collider> >(inputs.Count(), Allocator.TempJob); jobHandle = new ConvertToHashMapJob <Hash128, BlobAssetReference <Collider> > { Input = meshCollidersArray, Output = meshColliders }.Schedule(jobHandle); return(jobHandle); }
static JobHandle ProduceConvexColliders( NativeHashMap <Hash128, ConvexInput> inputs, NativeArray <float3> points, out NativeHashMap <Hash128, BlobAssetReference <Collider> > convexColliders, JobHandle inputDeps = default ) { // create collider blob assets var convexCollidersArray = new NativeArray <KeyValuePair <Hash128, BlobAssetReference <Collider> > >(inputs.Length, Allocator.TempJob); const int arrayLength = 5; var jobHandle = new ProduceConvexCollidersJob { InputKeys = inputs.GetKeyArray(Allocator.TempJob), InputValues = inputs.GetValueArray(Allocator.TempJob), AllPoints = points, Output = convexCollidersArray }.Schedule(inputs.Length, arrayLength, inputDeps); // put blob assets into hash map convexColliders = new NativeHashMap <Hash128, BlobAssetReference <Collider> >(inputs.Length, Allocator.TempJob); jobHandle = new ConvertToHashMapJob <Hash128, BlobAssetReference <Collider> > { Input = convexCollidersArray, Output = convexColliders }.Schedule(jobHandle); return(jobHandle); }