public List <T> IntersectsWith(Rect queryArea) { List <T> list = new List <T>(); foreach (T local in this.m_Elements) { if (RectUtils.Intersects(local.boundingRect, queryArea)) { list.Add(local); } } foreach (QuadTreeNode <T> node in this.m_ChildrenNodes) { if (!node.IsEmpty && RectUtils.Intersects(node.BoundingRect, queryArea)) { list.AddRange(node.IntersectsWith(queryArea)); return(list); } } return(list); }
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); }
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); }
public List <T> IntersectsWith(Rect queryArea) { List <T> list = new List <T>(); foreach (T current in this.m_Elements) { if (RectUtils.Intersects(current.boundingRect, queryArea)) { list.Add(current); } } foreach (QuadTreeNode <T> current2 in this.m_ChildrenNodes) { if (!current2.IsEmpty) { if (RectUtils.Intersects(current2.BoundingRect, queryArea)) { list.AddRange(current2.IntersectsWith(queryArea)); break; } } } return(list); }
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); }
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)) { list.Add(current); } else if (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); }
public static Rect Inflate(Rect a, float factor) { return(RectUtils.Inflate(a, factor, factor)); }
public static Rect OffsetX(Rect r, float offsetX) { return(RectUtils.Offset(r, offsetX, 0f)); }