private void CheckUpdateMap() { while (true) { if (KillThread) { return; } if (updateMap.Count > 0 && generationRequests.Size() == 0 && generationRequests.Empty() && finishedGeneration.Empty()) { try { List <long> keys = new List <long>(); keys.AddRange(updateMap.Keys); foreach (long key in keys) { if (!lockMap.ContainsKey(key)) { lockMap.Add(key, new object()); } lock (lockMap[key]) { generationRequests.Push(new ChunkRequest(ChunkRequest.RequestType.Update, updateMap[key])); updateMap.Remove(key); } } } catch (Exception e) { Debug.Log(e.Message + "\n" + e.StackTrace); } } } }
private IEnumerator CheckGenerationQueue() { while (true) { for (int n = 0; n < CheckNum; n++) { if (!finishedGeneration.Empty()) { Chunk chunk = finishedGeneration.Pop(); chunk.Initialize(); long key = Hash(chunk); chunkList.Add(key); if (!chunkMap.ContainsKey(key)) { chunkMap[key] = chunk; } else { Debug.Log("ERROR: Chunk Hash collision at: " + key + " :: " + chunk.data.ChunkX + " " + chunk.data.ChunkZ); } DynamicGI.UpdateEnvironment(); } } yield return(new WaitForEndOfFrame()); } }
private IEnumerator CheckUpdateQueue() { while (true) { for (int n = 0; n < CheckNum; n++) { if (!finishedUpdate.Empty()) { Chunk chunk = finishedUpdate.Pop(); chunk.Initialize(); DynamicGI.UpdateEnvironment(); } } yield return(new WaitForEndOfFrame()); } }