private void createJob() { if (_waitingQueue.Count == 0 || _processingList.Count >= 16) { return; } Chunk chunk = _waitingQueue.Dequeue(); ChunkData data = new ChunkData { chunk = chunk, chunkPos = new int2(chunk.chunkPos.x, chunk.chunkPos.y), blocks = new NativeArray <byte>(65536, Allocator.Persistent), vertices = new NativeList <float3>(Allocator.Persistent), uvs = new NativeList <float2>(Allocator.Persistent), triangles = new NativeList <int>(Allocator.Persistent) }; ChunkJob job = new ChunkJob { chunkPos = data.chunkPos, blocks = data.blocks, vertices = data.vertices, uvs = data.uvs, triangles = data.triangles }; data.handle = job.Schedule(); _processingList.Add(data); }
/// <summary> /// Sets the next job to run. /// </summary> private void runNextJob() { mRunningChunkJob = mWaitingJobs[0]; mChunkJobHandle = mRunningChunkJob.Schedule(); mWaitingJobs.RemoveAt(0); }