private void Invalidate(IEnumerable <TrixelEmplacement> trixels, bool trixelsExist)
        {
            int num = Enumerable.Count <TrixelEmplacement>(trixels);

            ArtObjectMaterializer.InvalidationContext context = new ArtObjectMaterializer.InvalidationContext()
            {
                Trixels      = Enumerable.Take <TrixelEmplacement>(trixels, num / 2),
                TrixelsExist = trixelsExist,
                Added        = (ICollection <TrixelFace>) new List <TrixelFace>(),
                Removed      = (ICollection <TrixelFace>) new List <TrixelFace>()
            };
            this.otherThreadContext = new ArtObjectMaterializer.InvalidationContext()
            {
                Trixels      = Enumerable.Skip <TrixelEmplacement>(trixels, num / 2),
                TrixelsExist = trixelsExist,
                Added        = (ICollection <TrixelFace>) new List <TrixelFace>(),
                Removed      = (ICollection <TrixelFace>) new List <TrixelFace>()
            };
            Thread thread = new Thread(new ThreadStart(this.InvalidateOtherThread));

            thread.Start();
            this.Invalidate(context);
            thread.Join();
            this.added.UnionWith((IEnumerable <TrixelFace>)context.Added);
            this.added.UnionWith((IEnumerable <TrixelFace>) this.otherThreadContext.Added);
            this.removed.UnionWith((IEnumerable <TrixelFace>)context.Removed);
            this.removed.UnionWith((IEnumerable <TrixelFace>) this.otherThreadContext.Removed);
            this.Dirty = true;
        }
 private void Invalidate(ArtObjectMaterializer.InvalidationContext context)
 {
     using (IEnumerator <TrixelEmplacement> enumerator = context.Trixels.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             TrixelEmplacement trixel = enumerator.Current;
             for (int index = 0; index < 6; ++index)
             {
                 FaceOrientation   face      = (FaceOrientation)index;
                 TrixelEmplacement traversed = trixel.GetTraversal(face);
                 if (this.IsBorderTrixelFace(traversed))
                 {
                     if (Enumerable.Any <TrixelSurface>((IEnumerable <TrixelSurface>) this.surfaces, (Func <TrixelSurface, bool>)(x =>
                     {
                         if (x.Orientation == face)
                         {
                             return(x.AnyRectangleContains(trixel));
                         }
                         else
                         {
                             return(false);
                         }
                     })))
                     {
                         context.Removed.Add(new TrixelFace(trixel, face));
                     }
                     if (context.TrixelsExist)
                     {
                         context.Added.Add(new TrixelFace(trixel, face));
                     }
                 }
                 else
                 {
                     FaceOrientation oppositeFace = FezMath.GetOpposite(face);
                     if (Enumerable.Any <TrixelSurface>((IEnumerable <TrixelSurface>) this.surfaces, (Func <TrixelSurface, bool>)(x =>
                     {
                         if (x.Orientation == oppositeFace)
                         {
                             return(x.AnyRectangleContains(traversed));
                         }
                         else
                         {
                             return(false);
                         }
                     })))
                     {
                         context.Removed.Add(new TrixelFace(traversed, oppositeFace));
                     }
                     if (!context.TrixelsExist)
                     {
                         context.Added.Add(new TrixelFace(traversed, oppositeFace));
                     }
                 }
             }
         }
     }
 }
Exemple #3
0
 private void Invalidate(IEnumerable<TrixelEmplacement> trixels, bool trixelsExist)
 {
   int num = Enumerable.Count<TrixelEmplacement>(trixels);
   ArtObjectMaterializer.InvalidationContext context = new ArtObjectMaterializer.InvalidationContext()
   {
     Trixels = Enumerable.Take<TrixelEmplacement>(trixels, num / 2),
     TrixelsExist = trixelsExist,
     Added = (ICollection<TrixelFace>) new List<TrixelFace>(),
     Removed = (ICollection<TrixelFace>) new List<TrixelFace>()
   };
   this.otherThreadContext = new ArtObjectMaterializer.InvalidationContext()
   {
     Trixels = Enumerable.Skip<TrixelEmplacement>(trixels, num / 2),
     TrixelsExist = trixelsExist,
     Added = (ICollection<TrixelFace>) new List<TrixelFace>(),
     Removed = (ICollection<TrixelFace>) new List<TrixelFace>()
   };
   Thread thread = new Thread(new ThreadStart(this.InvalidateOtherThread));
   thread.Start();
   this.Invalidate(context);
   thread.Join();
   this.added.UnionWith((IEnumerable<TrixelFace>) context.Added);
   this.added.UnionWith((IEnumerable<TrixelFace>) this.otherThreadContext.Added);
   this.removed.UnionWith((IEnumerable<TrixelFace>) context.Removed);
   this.removed.UnionWith((IEnumerable<TrixelFace>) this.otherThreadContext.Removed);
   this.Dirty = true;
 }