private static void OnGenerateVerices(ref SGenerateVerticesWorkItem item) { ChunkStateManagerClient stateManager = item.StateManager; stateManager.chunk.GeometryHandler.Build(0, Env.ChunkMask, 0, Env.ChunkMask, 0, Env.ChunkMask); OnGenerateVerticesDone(stateManager); }
/// <summary> /// Build this minichunk's render buffers /// </summary> private void GenerateVertices() { /*Assert.IsTrue( * m_completedTasks.Check(ChunkState.FinalizeData), * string.Format("[{0},{1},{2}] - GenerateVertices set sooner than FinalizeData completed. Pending:{3}, Completed:{4}", Pos.X, Pos.Y, Pos.Z, m_pendingTasks, m_completedTasks) * );*/ if (!m_completedTasks.Check(ChunkState.FinalizeData)) { return; } m_pendingTasks = m_pendingTasks.Reset(CurrStateGenerateVertices); // Nothing here for us to do if the chunk was not changed since the last time geometry was built if (m_completedTasks.Check(CurrStateGenerateVertices) && !m_refreshTasks.Check(CurrStateGenerateVertices)) { OnGenerateVerticesDone(this); return; } m_refreshTasks = m_refreshTasks.Reset(CurrStateGenerateVertices); m_completedTasks = m_completedTasks.Reset(CurrStateGenerateVertices); if (NonEmptyBlocks > 0) { IsBuilt = false; var workItem = new SGenerateVerticesWorkItem( this, MinRenderX, MaxRenderX, MinRenderY, MaxRenderY, MinRenderZ, MaxRenderZ, LOD ); m_taskRunning = true; WorkPoolManager.Add(new ThreadItem( m_threadID, arg => { SGenerateVerticesWorkItem item = (SGenerateVerticesWorkItem)arg; OnGenerateVerices(item.Chunk, item.MinX, item.MaxX, item.MinY, item.MaxY, item.MinZ, item.MaxZ, item.LOD); }, workItem) ); } else { OnGenerateVerticesDone(this); } }
/// <summary> /// Build this chunk's geometry /// </summary> private bool GenerateVertices() { if (!SynchronizeChunk()) { return(true); } bool priority = m_pendingStates.Check(ChunkState.BuildVerticesNow); m_pendingStates = m_pendingStates.Reset(CurrStateGenerateVertices); m_completedStates = m_completedStates.Reset(CurrStateGenerateVertices); m_completedStatesSafe = m_completedStates; if (chunk.NonEmptyBlocks > 0) { var workItem = new SGenerateVerticesWorkItem( this, chunk.MinRenderX, chunk.MaxRenderX, chunk.MinRenderY, chunk.MaxRenderY, chunk.MinRenderZ, chunk.MaxRenderZ, chunk.LOD ); m_taskRunning = true; WorkPoolManager.Add( new ThreadPoolItem( chunk.ThreadID, arg => { SGenerateVerticesWorkItem item = (SGenerateVerticesWorkItem)arg; OnGenerateVerices(item.StateManager, item.MinX, item.MaxX, item.MinY, item.MaxY, item.MinZ, item.MaxZ, item.LOD); }, workItem, priority ? Globals.Watch.ElapsedTicks : long.MaxValue) ); } else { OnGenerateVerticesDone(this); } return(true); }
/// <summary> /// Build this chunk's geometry /// </summary> private bool GenerateVertices() { if (!m_completedStates.Check(ChunkState.LoadData)) { return(true); } if (!SynchronizeChunk()) { return(true); } bool priority = m_pendingStates.Check(ChunkState.BuildVerticesNow); m_pendingStates = m_pendingStates.Reset(CurrStateGenerateVertices); m_completedStates = m_completedStates.Reset(CurrStateGenerateVertices); m_completedStatesSafe = m_completedStates; if (chunk.blocks.NonEmptyBlocks > 0) { var workItem = new SGenerateVerticesWorkItem(this); m_taskRunning = true; WorkPoolManager.Add( new ThreadPoolItem( chunk.ThreadID, arg => { SGenerateVerticesWorkItem item = (SGenerateVerticesWorkItem)arg; OnGenerateVerices(ref item); }, workItem, priority ? Globals.Watch.ElapsedTicks : long.MaxValue) ); return(true); } OnGenerateVerticesDone(this); return(false); }