Esempio n. 1
0
        private bool Probe(Image[] imgsToAdd, int idealAtlasW, int idealAtlasH, float imgArea, int maxAtlasDimension, ProbeResult pr)
        {
            Node node = new Node();

            node.pixRect = new PixRect(0, 0, idealAtlasW, idealAtlasH);
            for (int i = 0; i < imgsToAdd.Length; i++)
            {
                if (node.Insert(imgsToAdd[i], false) == null)
                {
                    return(false);
                }
                if (i == imgsToAdd.Length - 1)
                {
                    int num  = 0;
                    int num2 = 0;
                    this.GetExtent(node, ref num, ref num2);
                    float efficiency = 1f - ((float)(num * num2) - imgArea) / (float)(num * num2);
                    float squareness;
                    if (num < num2)
                    {
                        squareness = (float)num / (float)num2;
                    }
                    else
                    {
                        squareness = (float)num2 / (float)num;
                    }
                    bool fits = num <= maxAtlasDimension && num2 <= maxAtlasDimension;
                    pr.Set(num, num2, node, fits, efficiency, squareness);
                    return(true);
                }
            }
            return(false);
        }