createProxy method

int createProxy(
  1. AABB aabb,
  2. Object userData
)
override

Create a proxy. Provide a tight fitting AABB and a userData pointer.

Implementation

int createProxy(final AABB aabb, Object userData) {
  assert(aabb.isValid());
  final DynamicTreeNode node = _allocateNode();
  int proxyId = node.id;
  // Fatten the aabb
  final AABB nodeAABB = node.aabb;
  nodeAABB.lowerBound.x = aabb.lowerBound.x - Settings.aabbExtension;
  nodeAABB.lowerBound.y = aabb.lowerBound.y - Settings.aabbExtension;
  nodeAABB.upperBound.x = aabb.upperBound.x + Settings.aabbExtension;
  nodeAABB.upperBound.y = aabb.upperBound.y + Settings.aabbExtension;
  node.userData = userData;

  _insertLeaf(proxyId);

  return proxyId;
}