public Image[] GetRects(Image[] imgsToAdd, int maxDimension, int padding, out int outW, out int outH) { ProbeResult probeResult = null; float num = 0f; int num2 = 0; int num3 = 0; for (int i = 0; i < imgsToAdd.Length; i++) { Image image = imgsToAdd[i]; num += (float)(image.width * image.height); num2 = Mathf.Max(num2, image.width); num3 = Mathf.Max(num3, image.height); } int num4 = (int)Mathf.Sqrt(num); int num5 = num4; int num6 = num4; if (num2 > num4) { num5 = num2; num6 = Mathf.Max(Mathf.CeilToInt(num / (float)num2), num3); } if (num3 > num4) { num5 = Mathf.Max(Mathf.CeilToInt(num / (float)num3), num2); num6 = num3; } if (num5 == 0) { num5 = 1; } if (num6 == 0) { num6 = 1; } int num7 = (int)((float)num5 * 0.15f); int num8 = (int)((float)num6 * 0.15f); if (num7 == 0) { } if (num8 == 0) { } ProbeResult probeResult2 = new ProbeResult(); if (this.Probe(imgsToAdd, maxDimension, maxDimension, num, maxDimension, probeResult2)) { probeResult = probeResult2; } outW = 0; outH = 0; if (probeResult == null) { return(null); } outW = probeResult.width; outH = probeResult.height; List <Image> list = new List <Image>(); TexPacker.flattenTree(probeResult.root, list); list.Sort(new TexPacker.ImgIDComparer()); if (list.Count != imgsToAdd.Length) { LogSystem.LogWarning(new object[] { "Result images not the same lentgh as source" }); } return(list.ToArray()); }
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); }