Exemplo n.º 1
0
    //private bool ABatchIsBeingProcessed { get; set; }

    /// <summary>
    /// This is the main method which processes the batches of chunks.
    /// It is responsible for calling the terrain generation, decorating, lighting,
    /// and mesh generation.
    /// It's running in a seperate thread, and never stops checking for more work to do.
    /// </summary>
    private void ProcessChunks()
    {
        while (ContinueProcessingChunks)
        {
            // Complete each batch before moving onto the next
            if (m_CurrentBatchBeingProcessed != null || m_ChunkProcessor.ChunksAreBeingAdded)
            {
                continue;
            }


            ChunkBatch batch = m_ChunkProcessor.GetBatchOfChunksToProcess();
            if (batch == null)
            {
                continue;
            }

            m_CurrentBatchBeingProcessed = batch;

            DateTime start = DateTime.Now;

            if (batch.BatchType == BatchType.TerrainGeneration)
            {
                m_TerrainGenerator.GenerateTerrain(batch.Chunks);
                m_CurrentBatchBeingProcessed = null;
                continue;
            }

            m_WorldDecorator.Decorate(batch.Chunks);
            m_LightProcessor.LightChunks(batch.Chunks);
            m_MeshDataGenerator.GenerateMeshData(batch.Chunks);
            m_CurrentBatchBeingProcessed = null;

            if (batch.Chunks.Count > 0)
            {
                Debug.Log("Total Time: " + (DateTime.Now - start));
            }

            Thread.Sleep(1);
        }
    }
Exemplo n.º 2
0
    //private bool ABatchIsBeingProcessed { get; set; }
    /// <summary>
    /// This is the main method which processes the batches of chunks.
    /// It is responsible for calling the terrain generation, decorating, lighting,
    /// and mesh generation.
    /// It's running in a seperate thread, and never stops checking for more work to do.
    /// </summary>
    private void ProcessChunks()
    {
        while (ContinueProcessingChunks)
        {
            // Complete each batch before moving onto the next
            if (m_CurrentBatchBeingProcessed!= null || m_ChunkProcessor.ChunksAreBeingAdded)
            {
                continue;
            }

            ChunkBatch batch = m_ChunkProcessor.GetBatchOfChunksToProcess();
            if (batch == null)
            {
                continue;
            }

            m_CurrentBatchBeingProcessed = batch;

            DateTime start = DateTime.Now;

            if (batch.BatchType == BatchType.TerrainGeneration)
            {
                m_TerrainGenerator.GenerateTerrain(batch.Chunks);
                m_CurrentBatchBeingProcessed = null;
                continue;
            }

            m_WorldDecorator.Decorate(batch.Chunks);
            m_LightProcessor.LightChunks(batch.Chunks);
            m_MeshDataGenerator.GenerateMeshData(batch.Chunks);
            m_CurrentBatchBeingProcessed = null;

            if (batch.Chunks.Count > 0)
            {
                Debug.Log("Total Time: " + (DateTime.Now - start));
            }

            Thread.Sleep(1);
        }
    }