/// <summary> /// Finds all of the overlapping pairs between this DynamicTree and the specified other DynamicTree. /// </summary> public void QueryPairsWith(DynamicTree <T> other, Transform t1, Transform t2, Vector2 displacement, Action <T, T> callback) { if (_nodeCount > other._nodeCount) { other.QueryPairsWith(this, t2, t1, -displacement, callback); return; } _queryPairsCurOtherTree = other; _queryPairsCurCallback = callback; Stack <int> stack = _queryStack.Value; if (_root != NullNode) { stack.Push(_root); } while (stack.Count > 0) { TreeNode <T> node = _nodes[stack.Pop()]; if (node.IsLeaf()) { AABB aabb = node.AABB; // Transform into other coordinate system and predict displacement. AABB.Transform(ref t1, ref aabb); aabb.Displace(displacement); AABB.InvTransform(ref t2, ref aabb); _queryPairsCurUserData = node.UserData; Debug.Assert(((FixtureProxy)(object)_queryPairsCurUserData).Fixture != null); other.Query(_queryPairsOtherQueryCallback, ref aabb, out _, null); } else { if (node.Child1 != NullNode) { stack.Push(node.Child1); } if (node.Child2 != NullNode) { stack.Push(node.Child2); } } } _queryPairsCurOtherTree = null; _queryPairsCurCallback = null; _queryPairsCurUserData = default(T); }