public List <T> Query(T queryArea) { List <T> intersectingElements = new List <T>(elements.Count); for (int i = 0; i < elements.Count; i++) { if (elements[i].AABounds.Intersects(queryArea.AABounds)) { intersectingElements.Add(elements[i]); } } if (nw == null) { return(intersectingElements); } List <T>[] lChildren = new List <T> [4]; lChildren[0] = rNW.Intersects(queryArea.AABounds) ? nw.Query(queryArea) : null; lChildren[1] = rNE.Intersects(queryArea.AABounds) ? ne.Query(queryArea) : null; lChildren[2] = rSW.Intersects(queryArea.AABounds) ? sw.Query(queryArea) : null; lChildren[3] = rSE.Intersects(queryArea.AABounds) ? se.Query(queryArea) : null; for (int i = 0; i < 4; i++) { if (lChildren[i] != null) { intersectingElements.AddRange(lChildren[i]); } } return(intersectingElements); }
public List <T> Query(T queryArea) { return(rootNode.Query(queryArea)); }