public bool SameWith(PackingData other) { if (Width != other.Width || Height != other.Height) { return(false); } int end = TextureColors.Length - Width; for (int i = Width; i < end; i++) { if (TextureColors[i] != other.TextureColors[i]) { return(false); } } return(true); }
private static void GetAreas() { AreaList.Clear(); PackingList.Clear(); AreaPackingMap.Clear(); Int3 min, max; for (int d = 0; d < 6; d++) { for (int x = 0; x < SizeX; x++) { for (int y = 0; y < SizeY; y++) { for (int z = 0; z < SizeZ; z++) { var face = Faces[x, y, z, d]; if (face != null && !face.Aread) { GetFaceRange(x, y, z, d, out min, out max); // Area var area = new Area(); area.Init(min, max, d); AreaList.Add(area); // Texture var colors = new Color[area.SizeU * area.SizeV]; int currentIndex = 0; for (int u = min.X; u <= max.X; u++) { for (int v = min.Y; v <= max.Y; v++) { for (int w = min.Z; w <= max.Z; w++) { colors[currentIndex] = Colors[u, v, w]; currentIndex++; } } } // Lightmap if (!SupportLightMap) { var packingData = new PackingData(area.SizeU, area.SizeV, colors); bool hasSame = false; for (int i = 0; i < PackingList.Count; i++) { if (packingData.SameWith(PackingList[i])) { hasSame = true; AreaPackingMap.Add(i); break; } } if (!hasSame) { AreaPackingMap.Add(PackingList.Count); PackingList.Add(packingData); } } else { PackingList.Add(new PackingData(area.SizeU, area.SizeV, colors)); } } } } } } }