Пример #1
0
 private void DirtySortAxis(List <SweepPoint> axis)
 {
     axis.Sort(new Comparison <SweepPoint>(this.QuickSort));
     this.activeList.Clear();
     for (int i = 0; i < axis.Count; i++)
     {
         SweepPoint sweepPoint = axis[i];
         bool       begin      = sweepPoint.Begin;
         if (begin)
         {
             foreach (IBroadphaseEntity current in this.activeList)
             {
                 bool flag = base.CheckBoundingBoxes(current, sweepPoint.Body);
                 if (flag)
                 {
                     this.fullOverlaps.Add(new OverlapPair(current, sweepPoint.Body));
                 }
             }
             this.activeList.Add(sweepPoint.Body);
         }
         else
         {
             this.activeList.Remove(sweepPoint.Body);
         }
     }
 }
Пример #2
0
        private int QuickSort(SweepPoint sweepPoint1, SweepPoint sweepPoint2)
        {
            FP   value  = sweepPoint1.Value;
            FP   value2 = sweepPoint2.Value;
            bool flag   = value > value2;
            int  result;

            if (flag)
            {
                result = 1;
            }
            else
            {
                bool flag2 = value2 > value;
                if (flag2)
                {
                    result = -1;
                }
                else
                {
                    result = 0;
                }
            }
            return(result);
        }
 public void Restore(CollisionSystemPersistentSAP cs)
 {
     cs.bodyList.Clear();
     cs.bodyList.AddRange(this.bodyList);
     cs.axis1.Clear();
     this.index  = 0;
     this.length = this.axis1.Count;
     while (this.index < this.length)
     {
         SweetPointClone sweetPointClone = this.axis1[this.index];
         SweepPoint      sweepPoint      = new SweepPoint(null, false, 0);
         sweetPointClone.Restore(sweepPoint);
         cs.axis1.Add(sweepPoint);
         this.index++;
     }
     cs.axis2.Clear();
     this.index  = 0;
     this.length = this.axis2.Count;
     while (this.index < this.length)
     {
         SweetPointClone sweetPointClone2 = this.axis2[this.index];
         SweepPoint      sweepPoint2      = new SweepPoint(null, false, 0);
         sweetPointClone2.Restore(sweepPoint2);
         cs.axis2.Add(sweepPoint2);
         this.index++;
     }
     cs.axis3.Clear();
     this.index  = 0;
     this.length = this.axis3.Count;
     while (this.index < this.length)
     {
         SweetPointClone sweetPointClone3 = this.axis3[this.index];
         SweepPoint      sweepPoint3      = new SweepPoint(null, false, 0);
         sweetPointClone3.Restore(sweepPoint3);
         cs.axis3.Add(sweepPoint3);
         this.index++;
     }
     cs.fullOverlaps.Clear();
     cs.fullOverlaps.AddRange(this.fullOverlaps);
     cs.activeList.Clear();
     cs.activeList.AddRange(this.activeList);
     cs.swapOrder = this.swapOrder;
 }
Пример #4
0
 private void SortAxis(List <SweepPoint> axis)
 {
     for (int i = 1; i < axis.Count; i++)
     {
         SweepPoint sweepPoint = axis[i];
         FP         value      = sweepPoint.Value;
         int        num        = i - 1;
         while (num >= 0 && axis[num].Value > value)
         {
             SweepPoint sweepPoint2 = axis[num];
             bool       flag        = sweepPoint.Begin && !sweepPoint2.Begin;
             if (flag)
             {
                 bool flag2 = base.CheckBoundingBoxes(sweepPoint2.Body, sweepPoint.Body);
                 if (flag2)
                 {
                     HashList <OverlapPair> obj = this.fullOverlaps;
                     lock (obj)
                     {
                         this.fullOverlaps.Add(new OverlapPair(sweepPoint2.Body, sweepPoint.Body));
                     }
                 }
             }
             bool flag3 = !sweepPoint.Begin && sweepPoint2.Begin;
             if (flag3)
             {
                 HashList <OverlapPair> obj2 = this.fullOverlaps;
                 lock (obj2)
                 {
                     this.fullOverlaps.Remove(new OverlapPair(sweepPoint2.Body, sweepPoint.Body));
                 }
             }
             axis[num + 1] = sweepPoint2;
             num--;
         }
         axis[num + 1] = sweepPoint;
     }
 }
Пример #5
0
 public void Restore(SweepPoint sp)
 {
     sp.Body  = this.body;
     sp.Begin = this.begin;
     sp.Axis  = this.axis;
 }
Пример #6
0
 public void Clone(SweepPoint sp)
 {
     this.body  = sp.Body;
     this.begin = sp.Begin;
     this.axis  = sp.Axis;
 }