Beispiel #1
0
        // ----------------------------------------------------------------------------

        public bool Remove(OctTreeOccupant occupant)
        {
            if (IsLeaf)
            {
                return(m_occupants.Remove(occupant));
            }
            else
            {
                int removed = 0;
                for (int i = 0; i < m_children.Count; ++i)
                {
                    if (m_children[i].m_bounds.Contains(occupant))
                    {
                        removed += m_children[i].Remove(occupant) ? 1 : 0;
                    }
                }
                return(removed > 0);
            }
        }
Beispiel #2
0
        // ----------------------------------------------------------------------------

        public bool Insert(OctTreeOccupant occupant)
        {
            if (IsLeaf)
            {
                if (m_occupants.Contains(occupant) == false)
                {
                    m_occupants.Add(occupant);
                }
                return(true);
            }
            else
            {
                int inserted = 0;
                for (int i = 0; i < m_children.Count; ++i)
                {
                    if (m_children[i].m_bounds.Contains(occupant))
                    {
                        inserted += m_children[i].Insert(occupant) ? 1 : 0;
                    }
                }
                return(inserted > 0);
            }
        }