query method

void query (TreeCallback callback, AABB aabb)
override

Query an AABB for overlapping proxies. The callback class is called for each proxy that overlaps the supplied AABB.

@param callback @param araabbgAABB

Implementation

void query(TreeCallback callback, AABB aabb) {
  _nodeStackIndex = 0;
  _nodeStack[_nodeStackIndex++] = _root;

  while (_nodeStackIndex > 0) {
    int node = _nodeStack[--_nodeStackIndex];
    if (node == NULL_NODE) {
      continue;
    }

    if (AABB.testOverlap(_aabb[node], aabb)) {
      int child1 = _child1[node];
      if (child1 == NULL_NODE) {
        bool proceed = callback.treeCallback(node);
        if (!proceed) {
          return;
        }
      } else {
        if (_nodeStack.length - _nodeStackIndex - 2 <= 0) {
          _nodeStack = BufferUtils.reallocateBufferInt(
              _nodeStack, _nodeStack.length, _nodeStack.length * 2);
        }
        _nodeStack[_nodeStackIndex++] = child1;
        _nodeStack[_nodeStackIndex++] = _child2[node];
      }
    }
  }
}