public void Query(Ib2QueryCallback w, b2AABB aabb) { int stackCount = 0; var stack = _stack; var nodes = m_nodes; stack[stackCount++] = m_root; while (stackCount > 0) { int nodeId = stack[--stackCount]; if (nodeId == b2TreeNode.b2_nullNode) { continue; } b2TreeNode node = nodes[nodeId]; if (b2Collision.b2TestOverlap(ref node.aabb, ref aabb)) { if (node.child1 == b2TreeNode.b2_nullNode) { bool proceed = w.QueryCallback(nodeId); if (proceed == false) { return; } } else { //if (node.child1 != b2TreeNode.b2_nullNode) stack[stackCount++] = node.child1; if (node.child2 != b2TreeNode.b2_nullNode) { stack[stackCount++] = node.child2; } } } } }
public void Query(Ib2QueryCallback w, b2AABB aabb) { Stack <int> stack = new Stack <int>(); stack.Push(m_root); while (stack.Count > 0) { int nodeId = stack.Pop(); if (nodeId == b2TreeNode.b2_nullNode) { continue; } b2TreeNode node = m_nodes[nodeId]; if (b2Collision.b2TestOverlap(ref node.aabb, ref aabb)) { if (node.IsLeaf()) { bool proceed = w.QueryCallback(nodeId); if (proceed == false) { return; } } else { if (node.child1 != b2TreeNode.b2_nullNode) { stack.Push(node.child1); } if (node.child2 != b2TreeNode.b2_nullNode) { stack.Push(node.child2); } } } } }
public void Query(Ib2QueryCallback w, b2AABB aabb) { Stack<int> stack = new Stack<int>(); stack.Push(m_root); while (stack.Count > 0) { int nodeId = stack.Pop(); if (nodeId == b2TreeNode.b2_nullNode) { continue; } b2TreeNode node = m_nodes[nodeId]; if (b2Collision.b2TestOverlap(ref node.aabb, ref aabb)) { if (node.IsLeaf()) { bool proceed = w.QueryCallback(nodeId); if (proceed == false) { return; } } else { if(node.child1 != b2TreeNode.b2_nullNode) stack.Push(node.child1); if (node.child2 != b2TreeNode.b2_nullNode) stack.Push(node.child2); } } } }