// public interface to traversal.. public List <BVHNode <T> > Traverse(NodeTraversalTest hitTest) { var hits = new List <BVHNode <T> >(); this._traverse(rootBVH, hitTest, hits); return(hits); }
// internal functional traversal... private void _traverse(BVHNode <T> curNode, NodeTraversalTest hitTest, List <BVHNode <T> > hitlist) { if (curNode == null) { return; } if (hitTest(curNode.Box)) { hitlist.Add(curNode); _traverse(curNode.Left, hitTest, hitlist); _traverse(curNode.Right, hitTest, hitlist); } }