예제 #1
0
 /// <summary>
 /// Adds a new item into the Quadrant.
 /// </summary>
 public void Add(T item, Rect bounds)
 {
     if (!LastLevelQuadrant)
     {
         if (topRightBounds.Contains(bounds))
         {
             TopRight ??= new Quadrant(topRightBounds);
             TopRight.Add(item, bounds);
         }
         else if (topLeftBounds.Contains(bounds))
         {
             TopLeft ??= new Quadrant(topLeftBounds);
             TopLeft.Add(item, bounds);
         }
         else if (bottomRightBounds.Contains(bounds))
         {
             BottomRight ??= new Quadrant(bottomRightBounds);
             BottomRight.Add(item, bounds);
         }
         else if (bottomLeftBounds.Contains(bounds))
         {
             BottomLeft ??= new Quadrant(bottomLeftBounds);
             BottomLeft.Add(item, bounds);
         }
         else
         {
             ItemsInQuadrant.Add(item);
         }
     }
     else
     {
         ItemsInQuadrant.Add(item);
     }
     Count++;
 }