public void RePrioritizeProcessingChunkList() { lock (processingChunkList) { if (processingChunkListSortIndex >= processingChunkList.Count) { processingChunkListSortIndex = 0; } int startIndex = processingChunkListSortIndex; while (processingChunkListSortIndex < processingChunkList.Count && processingChunkListSortIndex < startIndex + Configuration.PERFORMANCE_MAX_PROCESSING_CHUNK_LIST_REPRIORITIZE_BATCH) { Chunk chunk = processingChunkList.Values[processingChunkListSortIndex]; Vector3 position; position.x = chunk.WorldPosition().x *Chunk.SIZE; position.y = chunk.WorldPosition().y *Chunk.SIZE; position.z = chunk.WorldPosition().z *Chunk.SIZE; int priority = RenderService.PriorityRelativeToCamera(position); while (processingChunkList.ContainsKey(priority)) { priority++; } processingChunkList.RemoveAt(processingChunkListSortIndex); processingChunkList.Add(priority, chunk); processingChunkListSortIndex++; } } }
public void FlushProcessingChunkListModifications() { lock (addToProcessingChunkList) { lock (processingChunkList) { for (int i = 0; i < addToProcessingChunkList.Count; i++) { Chunk addChunk = addToProcessingChunkList[i]; Vector3 position; position.x = addChunk.WorldPosition().x *Chunk.SIZE; position.y = addChunk.WorldPosition().y *Chunk.SIZE; position.z = addChunk.WorldPosition().z *Chunk.SIZE; int priority = RenderService.PriorityRelativeToCamera(position); while (processingChunkList.ContainsKey(priority)) { priority++; } processingChunkList.Add(priority, addChunk); } } addToProcessingChunkList.Clear(); } }