private void SortAxis(List <SweepPoint> axis) { for (int j = 1; j < axis.Count; j++) { SweepPoint keyelement = axis[j]; float key = keyelement.Value; int i = j - 1; while (i >= 0 && axis[i].Value > key) { SweepPoint swapper = axis[i]; if (keyelement.Begin && !swapper.Begin) { if (CheckBoundingBoxes(swapper.Body, keyelement.Body)) { lock (fullOverlaps) fullOverlaps.Add(new OverlapPair(swapper.Body, keyelement.Body)); } } if (!keyelement.Begin && swapper.Begin) { lock (fullOverlaps) fullOverlaps.Remove(new OverlapPair(swapper.Body, keyelement.Body)); } axis[i + 1] = swapper; i = i - 1; } axis[i + 1] = keyelement; } }
private void DirtySortAxis(List <SweepPoint> axis) { axis.Sort(QuickSort); activeList.Clear(); for (int i = 0; i < axis.Count; i++) { SweepPoint keyelement = axis[i]; if (keyelement.Begin) { foreach (IBroadphaseEntity body in activeList) { if (CheckBoundingBoxes(body, keyelement.Body)) { fullOverlaps.Add(new OverlapPair(body, keyelement.Body)); } } activeList.Add(keyelement.Body); } else { activeList.Remove(keyelement.Body); } } }
private void DirtySortAxis(List <SweepPoint> axis) { axis.Sort(QuickSort); activeList.Clear(); for (int i = 0; i < axis.Count; i++) { SweepPoint keyelement = axis[i]; if (keyelement.Begin) { foreach (IBroadphaseEntity body in activeList) { int count = t2bM.IncrementCounter(body.BroadphaseTag, keyelement.Body.BroadphaseTag); if (count == 3) { fullOverlaps.Add(new BodyPair(body, keyelement.Body)); } } activeList.Add(keyelement.Body); } else { activeList.Remove(keyelement.Body); } } }
private void SortAxis(List <SweepPoint> axis) { for (int j = 1; j < axis.Count; j++) { SweepPoint keyelement = axis[j]; float key = keyelement.GetValue(); int i = j - 1; while (i >= 0 && axis[i].GetValue() > key) { SweepPoint swapper = axis[i]; if (keyelement.Begin && !swapper.Begin) { lock (t2bM) { int count = t2bM.IncrementCounter(keyelement.Body.BroadphaseTag, swapper.Body.BroadphaseTag); if (count == 3) { BodyPair pair = new BodyPair(keyelement.Body, swapper.Body); fullOverlaps.Add(pair); } } } if (!keyelement.Begin && swapper.Begin) { lock (t2bM) { int count = t2bM.DecrementCounter(keyelement.Body.BroadphaseTag, swapper.Body.BroadphaseTag); if (count == 2) { BodyPair pair = new BodyPair(keyelement.Body, swapper.Body); fullOverlaps.Remove(pair); } } } axis[i + 1] = swapper; i = i - 1; } axis[i + 1] = keyelement; } }
private int QuickSort(SweepPoint sweepPoint1, SweepPoint sweepPoint2) { float val1 = sweepPoint1.Value; float val2 = sweepPoint2.Value; if (val1 > val2) { return(1); } else if (val2 > val1) { return(-1); } else { return(0); } }
private int QuickSort(SweepPoint sweepPoint1, SweepPoint sweepPoint2) { float val1 = sweepPoint1.Value; float val2 = sweepPoint2.Value; if (val1 > val2) return 1; else if (val2 > val1) return -1; else return 0; }
public void Clone(SweepPoint sp) { body = sp.Body; begin = sp.Begin; axis = sp.Axis; }
public void Restore(SweepPoint sp) { sp.Body = body; sp.Begin = begin; sp.Axis = axis; }