Example #1
0
 public TableNode(int mip, int x, int y, int width, int height)
 {
     MipLevel           = mip;
     Rect               = new RectInt(x, y, width, height);
     Payload            = new PhysicalTileInfo();
     Payload.tileStatus = TileStatus.Uninitialized;
 }
Example #2
0
        public void CreatePage(int quadKey)
        {
            //不重复生成
            rwl.EnterReadLock();
            try
            {
                if (AddressMapping.ContainsKey(quadKey) && AddressMapping[quadKey].tileStatus == TileStatus.Loading)
                {
                    return;
                }
            }
            finally
            {
                rwl.ExitReadLock();
            }


            PhysicalTileInfo info = new PhysicalTileInfo();

            info.tileStatus = TileStatus.Loading;
            rwl.EnterWriteLock();
            try
            {
                info.QuadKey            = quadKey;
                AddressMapping[quadKey] = info;
                tileGenerator.GeneratePageTask(quadKey);
            }
            finally
            {
                rwl.ExitWriteLock();
            }
        }
Example #3
0
        private void RefreshLookupTable()
        {
            var pixels       = m_LookupTexture.GetRawTextureData <Color32>();
            var currentFrame = (byte)Time.frameCount;


            foreach (var kv in AddressMapping)
            {
                PhysicalTileInfo currMapping = kv.Value;

                if (currMapping.ActiveFrame != Time.frameCount || currMapping.tileStatus != TileStatus.LoadingComplete)
                {
                    continue;
                }
                int        currMip    = getMip(currMapping.QuadKey);
                Vector2Int pageXY     = getPageXY(currMapping.QuadKey);
                int        RectLength = mipRectLengthFromMip(currMip);
                Color32    c          = new Color32((byte)currMapping.TileIndex.x, (byte)currMapping.TileIndex.y, (byte)currMip, currentFrame);

                for (int x = pageXY.x; x < pageXY.x + RectLength; x++)
                {
                    for (int y = pageXY.y; y < pageXY.y + RectLength; y++)
                    {
                        var id = y * TableSize + x;
                        if (pixels[id].b > c.b || pixels[id].a != currentFrame)
                        {
                            pixels[id] = c;
                        }
                    }
                }
            }
            m_LookupTexture.Apply(false);
        }
Example #4
0
        public void RefreshLookupTablePointer()
        {
            var pixels       = m_LookupTexture.GetRawTextureData <Color32>();
            var currentFrame = (byte)Time.frameCount;


            foreach (var kv in m_Pages)
            {
                TableNode        currNode    = kv.Value;
                PhysicalTileInfo currMapping = currNode.Payload;

                if (currMapping.ActiveFrame != Time.frameCount || currMapping.tileStatus != TileStatus.LoadingComplete)
                {
                    continue;
                }
                int     currMip = currNode.MipLevel;
                Color32 c       = new Color32((byte)currMapping.TileIndex.x, (byte)currMapping.TileIndex.y, (byte)currMip, currentFrame);

                for (int x = currNode.Rect.x; x < currNode.Rect.xMax; x++)
                {
                    for (int y = currNode.Rect.y; y < currNode.Rect.yMax; y++)
                    {
                        var id = y * TableSize + x;
                        if (pixels[id].b > c.b || pixels[id].a != currentFrame)
                        {
                            pixels[id] = c;
                        }
                    }
                }
            }
            m_LookupTexture.Apply(false);
        }