Ejemplo n.º 1
0
        public static void TryDrawingChunk(Vector3 chunkPos)
        {
            AssignedWorkContainer awc = GetWorkContainer(chunkPos);

            //Check if the chunk is already drawn or if it requires redrawing.
            if (!awc.ContainsWork(JobType.Draw))
            {
                ThreadedPendingDrawingWork tpdw = new ThreadedPendingDrawingWork(chunkPos);
                awc.AddAssignedJob(JobType.Draw, new AssignedJob(chunkPos, JobType.Draw, tpdw));
                ThreadHandler.EnqueuWork(tpdw);
            }
        }
Ejemplo n.º 2
0
        public static void GenerateChunk(Vector3 chunkPos)
        {
            Chunk c;

            if (!ChunkCollection.TryGetValue(chunkPos, out c))
            {
                AssignedWorkContainer awc = GetWorkContainer(chunkPos);

                if (!awc.ContainsWork(JobType.Generate))
                {
                    ThreadedChunkGeneration tcg = new ThreadedChunkGeneration(chunkPos);
                    awc.AddAssignedJob(JobType.Generate, new AssignedJob(chunkPos, JobType.Generate, tcg));
                    ThreadHandler.EnqueuWork(tcg);
                }
            }
        }
Ejemplo n.º 3
0
        public static void DrawChunk(Vector3 chunkPos)
        {
            AssignedWorkContainer awc = GetWorkContainer(chunkPos);

            if (!awc.ContainsWork(JobType.Draw))
            {
                Chunk c;
                TryGetChunk(chunkPos, out c);
                ThreadedSubChunkDrawingWork[] workArr = c.GetSubChunksToDraw();
                if (workArr.Length > 0)
                {
                    awc.AddAssignedJob(JobType.Draw, new AssignedJob(chunkPos, JobType.Draw, workArr));
                    ThreadHandler.EnqueuWork(workArr);
                }
                else
                {
                    ChunkGameObjectHandler.UpdateMesh(c.ChunkPos, c.GetMesh()).transform.position = c.ChunkPos * Chunk.CHUNKSIZE;
                }
            }
        }