Nez.Portable/Physics/QuadTree/QuadTreeNode.cs
/// <summary>
/// Insert an item into this QuadTree object.
/// </summary>
/// <param name="item">The item to insert.</param>
Insert an item into this QuadTree object.
Insert an item into this QuadTree object .
internal void insert(QuadTreeObject<T> item)
        {
            if (!_rect.Contains(item.data.bounds))
            {
                Assert.isNull(_parent, "We are not the root, and this object doesn't fit here. How did we get here?");
                if (_parent == null)
                {
                    add(item);
                }
                else
                {
                    return;
                }
            }
            if (_objects == null || (_childTL == null && _objects.Count + 1 <= maxObjectsPerNode))
            {
                add(item);
            }
            else
            {
                if (_childTL == null)
                    subdivide();
                var destTree = getDestinationTree(item);
                if (destTree == this)
                    add(item);
                else
                    destTree.insert(item);
            }
        }
internal void insert ( QuadTreeObject < T > item ) { if ( ! _rect . Contains ( item . data . bounds ) ) { Assert . isNull ( _parent , " " ) ; if ( _parent == null ) { add ( item ) ; } else { return ; } } if ( _objects == null || ( _childTL == null && _objects . Count + 1 <= maxObjectsPerNode ) ) { add ( item ) ; } else { if ( _childTL == null ) subdivide ( ) ; var destTree = getDestinationTree ( item ) ; if ( destTree == this ) add ( item ) ; else destTree . insert ( item ) ; } }
Insert an item into this QuadTree object.
Insert an item into this QuadTree object .
// If this quad doesn't contain the items rectangle, do nothing, unless we are the root // This object is outside of the QuadTree bounds, we should add it at the root level // If there's room to add the object, just add it // No quads, create them and bump objects down where appropriate // Find out which tree this object should go in and add it there
item
QuadTreeObject<T>
The item to insert.
The item to insert .