private static void OnGenerateData(ChunkStateManagerClient stateManager) { Chunk chunk = stateManager.chunk; chunk.Map.ChunkGenerator.Generate(chunk); OnGenerateDataDone(stateManager); }
private static void OnSaveData(ChunkStateManagerClient stateManager, string filePath) { Chunk chunk = stateManager.chunk; // !TODO: Handle failure ChunkProvider.StoreChunkToDisk(chunk, filePath); OnSaveDataDone(stateManager); }
public SGenerateVerticesWorkItem(ChunkStateManagerClient stateManager, int minX, int maxX, int minY, int maxY, int minZ, int maxZ, int lod) { StateManager = stateManager; MinX = minX; MaxX = maxX; MinY = minY; MaxY = maxY; MinZ = minZ; MaxZ = maxZ; LOD = lod; }
private void SubscribeTwoNeighbors(int cx, int cy, int cz, bool subscribe) { Chunk neighbor = chunk.Map.GetChunk(cx, cy, cz); if (neighbor != null) { ChunkStateManagerClient stateManager = neighbor.StateManager; // Subscribe with each other. Passing Idle as event - it is ignored in this case anyway stateManager.Subscribe(this, ChunkState.Idle, subscribe); Subscribe(stateManager, ChunkState.Idle, subscribe); } }
private static void OnGenerateVerices(ChunkStateManagerClient stateManager, int minX, int maxX, int minY, int maxY, int minZ, int maxZ, int lod) { Chunk chunk = stateManager.chunk; Map map = chunk.Map; int offsetX = (chunk.Pos.X << EngineSettings.ChunkConfig.LogSize) << map.VoxelLogScaleX; int offsetY = (chunk.Pos.Y << EngineSettings.ChunkConfig.LogSize) << map.VoxelLogScaleY; int offsetZ = (chunk.Pos.Z << EngineSettings.ChunkConfig.LogSize) << map.VoxelLogScaleZ; map.MeshBuilder.BuildMesh(map, chunk.RenderGeometryBatcher, offsetX, offsetY, offsetZ, minX, maxX, minY, maxY, minZ, maxZ, lod, chunk.Pools); OnGenerateVerticesDone(stateManager); }
private static void OnGenericWork(ref SGenericWorkItem item) { ChunkStateManagerClient chunk = item.Chunk; // Perform the action item.Action(); int cnt = Interlocked.Decrement(ref chunk.m_genericWorkItemsLeftToProcess); if (cnt <= 0) { // Something is very wrong if we go below zero Assert.IsTrue(cnt == 0); // All generic work is done OnGenericWorkDone(chunk); } }
private static void OnFinalizeData(ChunkStateManagerClient stateManager) { Chunk chunk = stateManager.chunk; // Generate height limits chunk.CalculateProperties(); // Compress chunk data //chunk.Blocks.IsCompressed = true; // Compress chunk data // Only do this when streaming is enabled for now if (EngineSettings.WorldConfig.Streaming) { chunk.Blocks.RLE.Reset(); BlockData[] compressedData = chunk.Blocks.ToArray(); chunk.Blocks.RLE.Compress(ref compressedData); } OnFinalizeDataDone(stateManager); }
private bool GenerateData() { m_pendingStates = m_pendingStates.Reset(CurrStateGenerateData); m_completedStates = m_completedStates.Reset(CurrStateGenerateData | CurrStateFinalizeData); m_completedStatesSafe = m_completedStates; m_taskRunning = true; // Let server generate chunk data WorkPoolManager.Add( new ThreadPoolItem( chunk.ThreadID, arg => { ChunkStateManagerClient stateManager = (ChunkStateManagerClient)arg; OnGenerateData(stateManager); }, this) ); return(true); }
private bool FinalizeData() { if (!m_completedStates.Check(ChunkState.Generate)) { return(true); } m_pendingStates = m_pendingStates.Reset(CurrStateFinalizeData); m_completedStatesSafe = m_completedStates = m_completedStates.Reset(CurrStateFinalizeData); m_taskRunning = true; WorkPoolManager.Add(new ThreadPoolItem( chunk.ThreadID, arg => { ChunkStateManagerClient stateManager = (ChunkStateManagerClient)arg; OnFinalizeData(stateManager); }, this) ); return(true); }
private static void OnGenerateVerticesDone(ChunkStateManagerClient stateManager) { stateManager.m_completedStates = stateManager.m_completedStates.Set(CurrStateGenerateVertices); stateManager.m_taskRunning = false; }
private static void OnSaveDataDone(ChunkStateManagerClient stateManager) { stateManager.m_stateExternal = ChunkStateExternal.Saved; stateManager.m_completedStates = stateManager.m_completedStates.Set(CurrStateSaveData); stateManager.m_taskRunning = false; }
public SSerializeWorkItem(ChunkStateManagerClient stateManager, string filePath) { StateManager = stateManager; FilePath = filePath; }
private static void OnFinalizeDataDone(ChunkStateManagerClient stateManager) { stateManager.m_completedStates = stateManager.m_completedStates.Set(CurrStateFinalizeData); stateManager.m_nextState = NextStateFinalizeData; stateManager.m_taskRunning = false; }
private static void OnGenericWorkDone(ChunkStateManagerClient chunk) { chunk.m_completedStates = chunk.m_completedStates.Set(CurrStateGenericWork); chunk.m_nextState = NextStateGenericWork; chunk.m_taskRunning = false; }
public SGenericWorkItem(ChunkStateManagerClient chunk, Action action) { Chunk = chunk; Action = action; }