public bool isLoaded(Chunk chunk, BufferChunkFunc bufferFunc) { DrawChunk dc = findDrawChunk(chunk); if (dc != null) { if (chunk.changeNumber == dc.changeNumber) { dc.lastFrameUsed = Renderer.frameNumber; return(true); } //it's out of date, remove it to trigger a reload updateChunk(chunk, bufferFunc); return(true); } //it's been requested, we're working on it if (myRequestedIds.Contains(chunk.key)) { return(true); } return(false); }
public void updateChunk(Chunk chunk, BufferChunkFunc bufferfunc) { removeChunk(chunk); DrawChunk dc = bufferfunc(chunk); lock (myLock) { myLoadedChunks[chunk.key] = dc; } }
public async void loadChunk(Chunk chunk, BufferChunkFunc bufferFunc) { if (myRequestedIds.Contains(chunk.key) == true) //already requested { return; } lock (myLock) { myRequestedIds.Add(chunk.key); } DrawChunk dc = await bufferChunkAsync(chunk, bufferFunc); //DrawChunk dc = bufferFunc(chunk); //finished the async call lock (myLock) { myLoadedChunks[chunk.key] = dc; myRequestedIds.Remove(chunk.key); } }
public Task <DrawChunk> bufferChunkAsync(Chunk chunk, BufferChunkFunc bufferFunc) { return(Task.Run(() => bufferFunc(chunk))); }