コード例 #1
0
        public List <T> ContainedBy(Rect queryArea)
        {
            List <T> objList = new List <T>();

            using (List <T> .Enumerator enumerator = this.m_Elements.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    T current = enumerator.Current;
                    if (RectUtils.Contains(current.boundingRect, queryArea))
                    {
                        objList.Add(current);
                    }
                    else if (queryArea.Overlaps(current.boundingRect))
                    {
                        objList.Add(current);
                    }
                }
            }
            using (List <QuadTreeNode <T> > .Enumerator enumerator = this.m_ChildrenNodes.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    QuadTreeNode <T> current = enumerator.Current;
                    if (!current.IsEmpty)
                    {
                        if (RectUtils.Contains(current.BoundingRect, queryArea))
                        {
                            objList.AddRange((IEnumerable <T>)current.ContainedBy(queryArea));
                            break;
                        }
                        if (RectUtils.Contains(queryArea, current.BoundingRect))
                        {
                            objList.AddRange((IEnumerable <T>)current.Elements(true));
                        }
                        else if (current.BoundingRect.Overlaps(queryArea))
                        {
                            objList.AddRange((IEnumerable <T>)current.ContainedBy(queryArea));
                        }
                    }
                }
            }
            return(objList);
        }
コード例 #2
0
 public List <T> ContainedBy(Rect area)
 {
     area.x -= m_ScreenSpaceOffset.x;
     area.y -= m_ScreenSpaceOffset.y;
     return(m_Root.ContainedBy(area));
 }