Пример #1
0
 private static void CalculateDepth(DrawRectInfo a)
 {
     a.Depth = list[0].Depth;
     for (int i = 0; i < list.Count; ++i)
     {
         if (Intersects(a.GetRect(), list[i].GetRect()))
         {
             int depth = list[i].Depth + 1;
             if (list[i].CanBatch(a))
             {
                 depth = list[i].Depth;
             }
             a.Depth = depth > a.Depth ? depth : a.Depth;
         }
     }
 }
Пример #2
0
    public static void GenTreeInfo(TreeNode node)
    {
        if (node.IsRoot)
        {
            Dictionary <int, KeyValuePair <TreeNode, List <DrawRectInfo> > > rectInfos = new Dictionary <int, KeyValuePair <TreeNode, List <DrawRectInfo> > >();
            rectInfos.Add(1, new KeyValuePair <TreeNode, List <DrawRectInfo> >(node, new List <DrawRectInfo>()));
            List <KeyValuePair <TreeNode, UINodeInfo> > infos = node.GetNodesInfo();
            int idx = 0;
            for (int i = 0; i < infos.Count; ++i)
            {
                if (infos[i].Value.Use)
                {
                    DrawRectInfo rectInfo = new DrawRectInfo(infos[i].Value.Name, infos[i].Value.IsOnlyCanvas);
                    rectInfo.Depth              = infos[i].Value.Depth;
                    rectInfo.HierarychyOrder    = idx++;
                    rectInfo.MaterialInstanceID = infos[i].Value.MaterialInstanceID;
                    rectInfo.TextureID          = infos[i].Value.TextureID;
                    rectInfo.Corners            = infos[i].Value.Corners;
                    rectInfo.IsInMask           = infos[i].Value.IsInMask;
                    rectInfo.IsInMask2D         = infos[i].Value.IsInMask2D;
                    infos[i].Value.ConnectInfo(rectInfo);
                    if (!rectInfos.ContainsKey(rectInfo.Depth / DefaultDepth))
                    {
                        rectInfos[rectInfo.Depth / DefaultDepth] = new KeyValuePair <TreeNode, List <DrawRectInfo> >(infos[i].Key, new List <DrawRectInfo>());
                    }
                    rectInfos[rectInfo.Depth / DefaultDepth].Value.Add(rectInfo);
                }
            }

            if (rectInfos.Count > 0)
            {
                int allBatchCount     = 0;
                int allMaskBatchCount = 0;
                KeyValuePair <int, int> temp;
                foreach (var keyValue in rectInfos)
                {
                    temp               = CalculateDepthInCanvas(keyValue.Value.Key, keyValue.Value.Value);
                    allBatchCount     += temp.Key;
                    allMaskBatchCount += temp.Value;
                }
                node.batchCount     = allBatchCount;
                node.maskBatchCount = allMaskBatchCount;
            }
        }
    }
Пример #3
0
 public void ConnectInfo(DrawRectInfo info)
 {
     m_info = info;
 }