public override bool Equals(object obj)
 {
     if (obj is PrevRenderChunk)
     {
         PrevRenderChunk c = obj as PrevRenderChunk;
         return(chunk.worldPos.EqualOther(c.chunk.worldPos) && x == c.x && y == c.y && z == c.z && block.EqualOther(c.block));
     }
     return(false);
 }
Ejemplo n.º 2
0
        public List <Chunk> HandlePrevRenderChunk(PrevRenderChunk prevChunk)
        {
            _chunkChangedList.Clear();
            Chunk chunk = prevChunk.chunk;
            int   x     = prevChunk.x;
            int   y     = prevChunk.y;
            int   z     = prevChunk.z;
            Block b     = prevChunk.block;

            _chunkChangedList = GetAroundChangeChunks(chunk, x, y, z, b, _chunkChangedList);
            _chunkChangedList = GetSunLightChangeChunks(chunk, x, y, z, b, _chunkChangedList);
            _chunkChangedList = GetBlockLightChangeChunks(chunk, x, y, z, b, _chunkChangedList);
            return(_chunkChangedList);
        }
Ejemplo n.º 3
0
        protected override void Process()
        {
            try{
                PrevRenderChunk prevChunk = DequeuePrevRender();
                if (prevChunk != null)
                {
                    WorldPos pos = prevChunk.chunk.worldPos;
                    if (World.world.GetChunk(pos.x, pos.y, pos.z) == null)
                    {
                        return;
                    }
                    List <Chunk> renderChunks = _prevRenderHandler.HandlePrevRenderChunk(prevChunk);
                    for (int i = 0; i < renderChunks.Count; i++)
                    {
                        EnqueueRender(renderChunks[i], true);
                    }
                }

                Chunk chunk = DequeueHighRender();
                if (chunk == null)
                {
                    chunk = DequeueRender();
                }
                if (chunk != null)
                {
                    WorldPos pos = chunk.worldPos;
                    if (World.world.GetChunk(pos.x, pos.y, pos.z) == null)
                    {
                        return;
                    }
                    MeshData meshData = _manager.GetUnusedMeshData();
                    for (int i = 0; i < chunk.Sections.Length; i++)
                    {
                        Section s = chunk.Sections[i];
                        _meshCalculator.CalculateSectionMesh(s, meshData);
                    }
                    _manager.EnqueueWaitRender(chunk, meshData);
                }
            }catch (Exception e)
            {
                UnityEngine.Debug.LogError(e);
            }
        }
Ejemplo n.º 4
0
 public void EnqueuePrevRender(Chunk chunk, int x, int y, int z, Block block)
 {
     lock (_prevRenderQueue)
     {
         PrevRenderChunk newPrevRenderChunk       = new PrevRenderChunk(chunk, x, y, z, block);
         IEnumerator <PrevRenderChunk> enumerator = _prevRenderQueue.GetEnumerator();
         bool isContains = false;
         while (enumerator.MoveNext())
         {
             if (enumerator.Current.EqualOther(newPrevRenderChunk))
             {
                 isContains = true;
                 break;
             }
         }
         if (!isContains)
         {
             _prevRenderQueue.Enqueue(newPrevRenderChunk);
         }
     }
 }
 public bool EqualOther(PrevRenderChunk c)
 {
     return(chunk.worldPos.EqualOther(c.chunk.worldPos) && x == c.x && y == c.y && z == c.z && block.EqualOther(c.block));
 }