BEPUphysics.BroadPhaseSystems.SortAndSweep.Testing.SortAndSweep3D.Add C# (CSharp) Метод

Add() публичный Метод

public Add ( BroadPhaseEntry entry ) : void
entry BEPUphysics.BroadPhaseEntries.BroadPhaseEntry
Результат void
        public override void Add(BroadPhaseEntry entry)
        {
            base.Add(entry);
            //binary search for the approximately correct location.  This helps prevent large first-frame sort times.
            //X Axis:
            int minIndex = 0; //inclusive
            int maxIndex = entriesX.Count; //exclusive
            int index = 0;
            while (maxIndex - minIndex > 0)
            {
                index = (maxIndex + minIndex) / 2;
                if (entriesX.Elements[index].boundingBox.Min.X > entry.boundingBox.Min.X)
                    maxIndex = index;
                else if (entriesX.Elements[index].boundingBox.Min.X < entry.boundingBox.Min.X)
                    minIndex = ++index;
                else
                    break; //Found an equal value!
            }
            entriesX.Insert(index, entry);

            //Y Axis:
            minIndex = 0; //inclusive
            maxIndex = entriesY.Count; //exclusive
            while (maxIndex - minIndex > 0)
            {
                index = (maxIndex + minIndex) / 2;
                if (entriesY.Elements[index].boundingBox.Min.Y > entry.boundingBox.Min.Y)
                    maxIndex = index;
                else if (entriesY.Elements[index].boundingBox.Min.Y < entry.boundingBox.Min.Y)
                    minIndex = ++index;
                else
                    break; //Found an equal value!
            }
            entriesY.Insert(index, entry);

            //Z Axis:
            minIndex = 0; //inclusive
            maxIndex = entriesZ.Count; //exclusive
            while (maxIndex - minIndex > 0)
            {
                index = (maxIndex + minIndex) / 2;
                if (entriesZ.Elements[index].boundingBox.Min.Z > entry.boundingBox.Min.Z)
                    maxIndex = index;
                else if (entriesZ.Elements[index].boundingBox.Min.Z < entry.boundingBox.Min.Z)
                    minIndex = ++index;
                else
                    break; //Found an equal value!
            }
            entriesZ.Insert(index, entry);
        }