Пример #1
0
        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);
        }
Пример #2
0
        public void updateChunk(Chunk chunk, BufferChunkFunc bufferfunc)
        {
            removeChunk(chunk);

            DrawChunk dc = bufferfunc(chunk);

            lock (myLock)
            {
                myLoadedChunks[chunk.key] = dc;
            }
        }
Пример #3
0
        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);
            }
        }
Пример #4
0
 public Task <DrawChunk> bufferChunkAsync(Chunk chunk, BufferChunkFunc bufferFunc)
 {
     return(Task.Run(() => bufferFunc(chunk)));
 }