Ejemplo n.º 1
0
        public void UpdateItemBounds(T item)
        {
            ItemInfo info;

            if (_Items.TryGetValue(item, out info))
            {
                var oldBounds      = info.Bounds;
                var oldTopLeft     = info.TopLeft;
                var oldBottomRight = info.BottomRight;
                info.Bounds      = item.Bounds;
                info.TopLeft     = _Partition.GetIndexFromPoint(info.Bounds.TopLeft);
                info.BottomRight = _Partition.GetIndexFromPoint(info.Bounds.BottomRight);

                if ((oldTopLeft.First == info.TopLeft.First) &&
                    (oldTopLeft.Second == info.TopLeft.Second) &&
                    (oldBottomRight.First == info.BottomRight.First) &&
                    (oldBottomRight.Second == info.BottomRight.Second))
                {
                    return;
                }

                InternalRemove(info, oldTopLeft, oldBottomRight, false);

                using (var e = _Partition.GetSectorsFromBounds(info.TopLeft, info.BottomRight, true))
                    while (e.MoveNext())
                    {
                        e.Current.Add(info);
                    }
            }
        }
Ejemplo n.º 2
0
 internal GetSectorsFromBoundsEnumerator(SpatialPartition <TSector> sectors, Bounds bounds, bool create)
     : this(sectors, sectors.GetIndexFromPoint(bounds.TopLeft), sectors.GetIndexFromPoint(bounds.BottomRight), create)
 {
 }