Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
 public void UpdateSurfaces()
 {
     TrixelFace[] array1 = Enumerable.ToArray <TrixelFace>((IEnumerable <TrixelFace>) this.removed);
     Array.Sort <TrixelFace>(array1, (IComparer <TrixelFace>)ArtObjectMaterializer.invalidTrixelFaceComparer);
     foreach (TrixelFace trixelFace in array1)
     {
         TrixelFace    tf             = trixelFace;
         TrixelSurface trixelSurface1 = (TrixelSurface)null;
         foreach (TrixelSurface trixelSurface2 in Enumerable.Where <TrixelSurface>((IEnumerable <TrixelSurface>) this.surfaces, (Func <TrixelSurface, bool>)(x =>
         {
             if (x.Orientation == tf.Face)
             {
                 return(x.Trixels.Contains(tf.Id));
             }
             else
             {
                 return(false);
             }
         })))
         {
             trixelSurface2.Trixels.Remove(tf.Id);
             if (trixelSurface2.Trixels.Count == 0)
             {
                 trixelSurface1 = trixelSurface2;
             }
             else
             {
                 trixelSurface2.MarkAsDirty();
             }
         }
         if (trixelSurface1 != null)
         {
             this.surfaces.Remove(trixelSurface1);
         }
     }
     this.removed.Clear();
     TrixelFace[] array2 = Enumerable.ToArray <TrixelFace>((IEnumerable <TrixelFace>) this.added);
     Array.Sort <TrixelFace>(array2, (IComparer <TrixelFace>)ArtObjectMaterializer.invalidTrixelFaceComparer);
     foreach (TrixelFace trixelFace in array2)
     {
         TrixelFace      tf = trixelFace;
         TrixelSurface[] trixelSurfaceArray = Enumerable.ToArray <TrixelSurface>(Enumerable.Where <TrixelSurface>((IEnumerable <TrixelSurface>) this.surfaces, (Func <TrixelSurface, bool>)(x => x.CanContain(tf.Id, tf.Face))));
         if (trixelSurfaceArray.Length > 0)
         {
             TrixelSurface trixelSurface1 = trixelSurfaceArray[0];
             trixelSurface1.Trixels.Add(tf.Id);
             trixelSurface1.MarkAsDirty();
             if (trixelSurfaceArray.Length > 1)
             {
                 foreach (TrixelSurface trixelSurface2 in Enumerable.Skip <TrixelSurface>((IEnumerable <TrixelSurface>)trixelSurfaceArray, 1))
                 {
                     trixelSurface1.Trixels.UnionWith((IEnumerable <TrixelEmplacement>)trixelSurface2.Trixels);
                     this.surfaces.Remove(trixelSurface2);
                 }
             }
         }
         else
         {
             this.surfaces.Add(new TrixelSurface(tf.Face, tf.Id));
         }
     }
     this.added.Clear();
     this.RebuildParts();
 }