private List <TrixelEmplacement> FindBiggestRectangle(TrixelEmplacement center, ICollection <TrixelEmplacement> subSurface, out Rectangle rectangle) { List <TrixelEmplacement> rectangleTrixels = new List <TrixelEmplacement>(); TrixelEmplacement other = new TrixelEmplacement(center); int num1 = 1; int num2 = 0; int num3 = 1; int num4 = 0; int num5 = 1; int num6 = -1; do { rectangleTrixels.Add(new TrixelEmplacement(other)); if (num3 > 0) { other.Position += this.Tangent * (float)num5; if (--num3 == 0) { num6 *= -1; num4 = ++num2; } } else if (num4 > 0) { other.Position += this.Bitangent * (float)num6; if (--num4 == 0) { num5 *= -1; num3 = ++num1; } } }while (subSurface.Contains(other)); int num7 = TrixelSurface.ClampToRectangleSpiral(rectangleTrixels.Count); if (num7 != rectangleTrixels.Count) { rectangleTrixels.RemoveRange(num7, rectangleTrixels.Count - num7); } rectangle = TrixelSurface.GetRectangleSpiralLimits(num7); if (rectangleTrixels.Count < subSurface.Count) { this.ExpandSide(ref rectangle, center, subSurface, rectangleTrixels, true, 1); this.ExpandSide(ref rectangle, center, subSurface, rectangleTrixels, true, -1); this.ExpandSide(ref rectangle, center, subSurface, rectangleTrixels, false, 1); this.ExpandSide(ref rectangle, center, subSurface, rectangleTrixels, false, -1); } return(rectangleTrixels); }
private void InitializeSurfaces() { this.surfaces.Clear(); foreach (FaceOrientation faceOrientation in Util.GetValues<FaceOrientation>()) { TrixelEmplacement firstTrixel = new TrixelEmplacement(FezMath.IsPositive(faceOrientation) ? FezMath.AsVector(faceOrientation) * (this.size * 16f - Vector3.One) : Vector3.Zero); TrixelSurface trixelSurface = new TrixelSurface(faceOrientation, firstTrixel); Vector3 mask1 = FezMath.GetMask(FezMath.AsAxis(FezMath.GetTangent(faceOrientation))); int num1 = (int) Vector3.Dot(this.size, mask1) * 16; Vector3 mask2 = FezMath.GetMask(FezMath.AsAxis(FezMath.GetBitangent(faceOrientation))); int num2 = (int) Vector3.Dot(this.size, mask2) * 16; trixelSurface.RectangularParts.Add(new RectangularTrixelSurfacePart() { Orientation = faceOrientation, TangentSize = num1, BitangentSize = num2, Start = firstTrixel }); for (int index1 = 0; index1 < num1; ++index1) { for (int index2 = 0; index2 < num2; ++index2) trixelSurface.Trixels.Add(new TrixelEmplacement(firstTrixel + mask1 * (float) index1 + mask2 * (float) index2)); } this.surfaces.Add(trixelSurface); } }