internal void SearchBounds(AxisAlignedBoundingBox bounds, List <T> queryResults) { var items = new Stack <Branch>(new Branch[] { this }); while (items.Any()) { Branch item = items.Pop(); if (item.Leaves.Count > 0) { for (int i = 0; i < item.Leaves.Count; ++i) { if (bounds.Intersects(item.Leaves[i].Bounds)) { queryResults.Add(item.Leaves[i].Value); } } } for (int i = 0; i < 8; ++i) { if (item.Branches[i] != null) { items.Push(item.Branches[i]); } } } }
public void SearchBounds(AxisAlignedBoundingBox bounds, List <T> results) { if (bounds.Intersects(Aabb)) { // check all the items that are part of this object foreach (var item in Items) { if (item.Aabb.Intersects(bounds)) { results.Add(item.Item); } } nodeA?.SearchBounds(bounds, results); nodeB?.SearchBounds(bounds, results); } }