コード例 #1
0
    public void RequestMeshData(System.Action <ChunkMeshData[]> callback, ChunkColumn chunkCol, int yIndex)
    {
        ThreadMeshObject threadTask = new ThreadMeshObject(callback, chunkCol, yIndex);

        ThreadPool.QueueUserWorkItem(new WaitCallback(MeshDataThread), threadTask);
        amountOfWorkerThreads++;
    }
コード例 #2
0
    public void MeshDataThread(object threadTask)
    {
        ThreadMeshObject threadTaskInfo = (ThreadMeshObject)threadTask;

        try
        {
            ChunkMeshData[] chunkMeshData = World.meshGen.GenerateChunkMeshData(threadTaskInfo.chunkCol, threadTaskInfo.yIndex);
            ThreadMeshInfo  threadInfo    = new ThreadMeshInfo(threadTaskInfo.callback, chunkMeshData);

            lock (threadMeshQueue)
            {
                threadMeshQueue.Enqueue(threadInfo);
            }
        }
        catch
        {
            Debug.Log("Chunk Mesh Error Occured!");
        }
    }