BEPUphysics.BroadPhaseSystems.SortAndSweep.Grid2DSortAndSweep.UpdateEntry C# (CSharp) Method

UpdateEntry() private method

private UpdateEntry ( int i ) : void
i int
return void
        void UpdateEntry(int i)
        {

            //Compute the current cells occupied by the entry.
            var entry = entries.Elements[i];
            Int2 min, max;
            ComputeCell(ref entry.item.boundingBox.Min, out min);
            ComputeCell(ref entry.item.boundingBox.Max, out max);
            //For any cell that used to be occupied (defined by the previous min/max),
            //remove the entry.
            for (int j = entry.previousMin.Y; j <= entry.previousMax.Y; j++)
            {
                for (int k = entry.previousMin.Z; k <= entry.previousMax.Z; k++)
                {
                    if (j >= min.Y && j <= max.Y && k >= min.Z && k <= max.Z)
                        continue; //This cell is currently occupied, do not remove.
                    var index = new Int2 {Y = j, Z = k};
                    cellSetLocker.Enter();
                    cellSet.Remove(ref index, entry);
                    cellSetLocker.Exit();
                }
            }
            //For any cell that is newly occupied (was not previously contained),
            //add the entry.
            for (int j = min.Y; j <= max.Y; j++)
            {
                for (int k = min.Z; k <= max.Z; k++)
                {
                    if (j >= entry.previousMin.Y && j <= entry.previousMax.Y && k >= entry.previousMin.Z && k <= entry.previousMax.Z)
                        continue; //This cell is already occupied, do not add.
                    var index = new Int2 {Y = j, Z = k};
                    cellSetLocker.Enter();
                    cellSet.Add(ref index, entry);
                    cellSetLocker.Exit();
                }
            }
            entry.previousMin = min;
            entry.previousMax = max;
        }