/// <summary> /// /// </summary> /// <param name="item"></param> /// <returns>true when the item was added</returns> public bool AddItem(T item) { // Only add the item if it intersects with this node if (AABB.FullyEncloses(item.AABB)) { if (IsLeaf) { SubDivide(); } // Try to add the item to a childnode but if no childnode will take it add it to this node if (!TopLeft.AddItem(item)) { if (!TopRight.AddItem(item)) { if (!BottomLeft.AddItem(item)) { if (!BottomRight.AddItem(item)) { Items.Add(item); } } } } return(true); } return(false); }
/// <summary> /// Adds a new item to the QuadTree /// </summary> /// <param name="item"></param> public void InsertItem(T item) { RootNode.AddItem(item); }