Contains() 공개 정적인 메소드

public static Contains ( Rect a, Rect b ) : bool
a UnityEngine.Rect
b UnityEngine.Rect
리턴 bool
예제 #1
0
        public void Insert(T item)
        {
            if (!RectUtils.Contains(m_BoundingRect, item.boundingRect))
            {
                Rect intersection = new Rect();
                if (!RectUtils.Intersection(item.boundingRect, m_BoundingRect, out intersection))
                {
                    // Ignore elements completely outside the quad tree
                    return;
                }
            }

            if (m_ChildrenNodes.Count == 0)
            {
                Subdivide();
            }

            // insert into children nodes
            foreach (QuadTreeNode <T> node in m_ChildrenNodes)
            {
                if (RectUtils.Contains(node.BoundingRect, item.boundingRect))
                {
                    node.Insert(item);
                    return;
                }
            }

            // item is not completely contained in any of the children nodes
            // insert here
            this.m_Elements.Add(item);
        }
예제 #2
0
        public List <T> ContainedBy(Rect queryArea)
        {
            List <T> list = new List <T>();

            foreach (T current in this.m_Elements)
            {
                if (RectUtils.Contains(current.boundingRect, queryArea) || queryArea.Overlaps(current.boundingRect))
                {
                    list.Add(current);
                }
            }
            foreach (QuadTreeNode <T> current2 in this.m_ChildrenNodes)
            {
                if (!current2.IsEmpty)
                {
                    if (RectUtils.Contains(current2.BoundingRect, queryArea))
                    {
                        list.AddRange(current2.ContainedBy(queryArea));
                        break;
                    }
                    if (RectUtils.Contains(queryArea, current2.BoundingRect))
                    {
                        list.AddRange(current2.Elements(true));
                    }
                    else if (current2.BoundingRect.Overlaps(queryArea))
                    {
                        list.AddRange(current2.ContainedBy(queryArea));
                    }
                }
            }
            return(list);
        }
예제 #3
0
 public void Insert(T item)
 {
     if (!RectUtils.Contains(this.m_BoundingRect, item.boundingRect))
     {
         Rect intersection = new Rect();
         if (!RectUtils.Intersection(item.boundingRect, this.m_BoundingRect, out intersection))
         {
             return;
         }
     }
     if (this.m_ChildrenNodes.Count == 0)
     {
         this.Subdivide();
     }
     using (List <QuadTreeNode <T> > .Enumerator enumerator = this.m_ChildrenNodes.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             QuadTreeNode <T> current = enumerator.Current;
             if (RectUtils.Contains(current.BoundingRect, item.boundingRect))
             {
                 current.Insert(item);
                 return;
             }
         }
     }
     this.m_Elements.Add(item);
 }
예제 #4
0
        public List <T> ContainedBy(Rect queryArea)
        {
            List <T> results = new List <T>();

            foreach (T item in m_Elements)
            {
                if (RectUtils.Contains(item.boundingRect, queryArea) || queryArea.Overlaps(item.boundingRect))
                {
                    results.Add(item);
                }
            }

            foreach (QuadTreeNode <T> node in m_ChildrenNodes)
            {
                if (node.IsEmpty)
                {
                    continue;
                }

                if (RectUtils.Contains(node.BoundingRect, queryArea))
                {
                    // the node completely contains the queryArea
                    // recurse down and stop
                    results.AddRange(node.ContainedBy(queryArea));
                    break;
                }

                if (RectUtils.Contains(queryArea, node.BoundingRect))
                {
                    // the queryArea completely contains this node
                    // just add everything under this node, recursively
                    results.AddRange(node.Elements(true));
                    continue;
                }

                if (node.BoundingRect.Overlaps(queryArea))
                {
                    // the node intersects
                    // recurse and continue iterating siblings
                    results.AddRange(node.ContainedBy(queryArea));
                }
            }

            return(results);
        }
예제 #5
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);
        }
예제 #6
0
        public List <T> ContainedBy(Rect queryArea)
        {
            List <T> list = new List <T>();

            foreach (T local in this.m_Elements)
            {
                if (RectUtils.Contains(local.boundingRect, queryArea))
                {
                    list.Add(local);
                }
                else if (queryArea.Overlaps(local.boundingRect))
                {
                    list.Add(local);
                }
            }
            foreach (QuadTreeNode <T> node in this.m_ChildrenNodes)
            {
                if (!node.IsEmpty)
                {
                    if (RectUtils.Contains(node.BoundingRect, queryArea))
                    {
                        list.AddRange(node.ContainedBy(queryArea));
                        return(list);
                    }
                    if (RectUtils.Contains(queryArea, node.BoundingRect))
                    {
                        list.AddRange(node.Elements(true));
                    }
                    else if (node.BoundingRect.Overlaps(queryArea))
                    {
                        list.AddRange(node.ContainedBy(queryArea));
                    }
                }
            }
            return(list);
        }
예제 #7
0
 public void Insert(T item)
 {
     if (!RectUtils.Contains(this.m_BoundingRect, item.boundingRect))
     {
         Rect intersection = new Rect();
         if (!RectUtils.Intersection(item.boundingRect, this.m_BoundingRect, out intersection))
         {
             return;
         }
     }
     if (this.m_ChildrenNodes.Count == 0)
     {
         this.Subdivide();
     }
     foreach (QuadTreeNode <T> node in this.m_ChildrenNodes)
     {
         if (RectUtils.Contains(node.BoundingRect, item.boundingRect))
         {
             node.Insert(item);
             return;
         }
     }
     this.m_Elements.Add(item);
 }
예제 #8
0
 public void Insert(T item)
 {
     if (!RectUtils.Contains(this.m_BoundingRect, item.boundingRect))
     {
         Rect rect = default(Rect);
         if (!RectUtils.Intersection(item.boundingRect, this.m_BoundingRect, out rect))
         {
             return;
         }
     }
     if (this.m_ChildrenNodes.Count == 0)
     {
         this.Subdivide();
     }
     foreach (QuadTreeNode <T> current in this.m_ChildrenNodes)
     {
         if (RectUtils.Contains(current.BoundingRect, item.boundingRect))
         {
             current.Insert(item);
             return;
         }
     }
     this.m_Elements.Add(item);
 }