Exemplo n.º 1
0
        public void ProcessChunks()
        {
            Profiler.BeginSample("ProcessChunks");

            HandleVisibility();

            // Process removal requests
            for (int i = 0; i < m_updateRequests.Count;)
            {
                Chunk chunk = m_updateRequests[i];

                OnProcessChunk(chunk);

                // Update the chunk if possible
                if (chunk.Update())
                {
                    // Build geometry if there is enough time
                    if (Globals.GeometryBudget.HasTimeBudget)
                    {
                        Globals.GeometryBudget.StartMeasurement();

                        bool wasBuilt = chunk.UpdateCollisionGeometry();
                        wasBuilt |= chunk.UpdateRenderGeometry();
                        if (wasBuilt)
                        {
                            Globals.GeometryBudget.StopMeasurement();
                        }
                    }
                }

                // Automatically collect chunks which are ready to be removed from the world
                if (chunk.IsStateCompleted(ChunkState.Remove))
                {
                    // Remove the chunk from our provider and unregister it from chunk storage
                    world.RemoveChunk(chunk);

                    // Unregister from updates
                    m_updateRequests.RemoveAt(i);
                    continue;
                }

                ++i;
            }

            world.PerformBlockActions();

            FullLoadOnStartUp = false;

            Profiler.EndSample();
        }