Package org.jbox2d.collision.broadphase

Examples of org.jbox2d.collision.broadphase.TreeNode


    m_nodeCapacity = 16;
    m_nodes = new TreeNode[16];

    // Build a linked list for the free list.
    for (int i = 0; i < m_nodeCapacity; i++) {
      m_nodes[i] = new TreeNode();
      m_nodes[i].parent = i + 1;
      m_nodes[i].height = -1;
    }
    m_nodes[m_nodeCapacity - 1].parent = TreeNode.NULL_NODE;
    m_freeList = 0;
View Full Code Here


   * @return */
  public final int createProxy (final AABB aabb, Object userData) {
    int proxyId = allocateNode();

    // Fatten the aabb
    final TreeNode node = m_nodes[proxyId];
    node.aabb.lowerBound.x = aabb.lowerBound.x - Settings.aabbExtension;
    node.aabb.lowerBound.y = aabb.lowerBound.y - Settings.aabbExtension;
    node.aabb.upperBound.x = aabb.upperBound.x + Settings.aabbExtension;
    node.aabb.upperBound.y = aabb.upperBound.y + Settings.aabbExtension;
    node.userData = userData;
View Full Code Here

   * tree and re-inserted. Otherwise the function returns immediately.
   *
   * @return true if the proxy was re-inserted. */
  public final boolean moveProxy (int proxyId, final AABB aabb, Vec2 displacement) {
    assert (0 <= proxyId && proxyId < m_nodeCapacity);
    final TreeNode node = m_nodes[proxyId];
    assert (node.isLeaf());

    if (node.aabb.contains(aabb)) {
      return false;
    }

View Full Code Here

      int nodeId = intStack.pop();
      if (nodeId == TreeNode.NULL_NODE) {
        continue;
      }

      final TreeNode node = m_nodes[nodeId];

      if (AABB.testOverlap(node.aabb, aabb)) {
        if (node.isLeaf()) {
          boolean proceed = callback.treeCallback(nodeId);
          if (!proceed) {
            return;
          }
        } else {
View Full Code Here

      int nodeId = intStack.pop();
      if (nodeId == TreeNode.NULL_NODE) {
        continue;
      }

      final TreeNode node = m_nodes[nodeId];

      if (!AABB.testOverlap(node.aabb, segAABB)) {
        continue;
      }

      // Separating axis for segment (Gino, p80).
      // |dot(v, p1 - c)| > dot(|v|, h)
      node.aabb.getCenterToOut(c);
      node.aabb.getExtentsToOut(h);
      temp.set(p1).subLocal(c);
      float separation = MathUtils.abs(Vec2.dot(v, temp)) - Vec2.dot(absV, h);
      if (separation > 0.0f) {
        continue;
      }

      if (node.isLeaf()) {
        subInput.p1.set(input.p1);
        subInput.p2.set(input.p2);
        subInput.maxFraction = maxFraction;

        float value = callback.raycastCallback(subInput, nodeId);
View Full Code Here

  }

  private final int computeHeight (int nodeId) {
    assert (0 <= nodeId && nodeId < m_nodeCapacity);

    final TreeNode node = m_nodes[nodeId];

    if (node.isLeaf()) {
      return 0;
    }
    int height1 = computeHeight(node.child1);
    int height2 = computeHeight(node.child2);
    return 1 + MathUtils.max(height1, height2);
View Full Code Here

   *
   * @return */
  public int getMaxBalance () {
    int maxBalance = 0;
    for (int i = 0; i < m_nodeCapacity; ++i) {
      final TreeNode node = m_nodes[i];
      if (node.height <= 1) {
        continue;
      }

      assert (node.isLeaf() == false);

      int child1 = node.child1;
      int child2 = node.child2;
      int balance = MathUtils.abs(m_nodes[child2].height - m_nodes[child1].height);
      maxBalance = MathUtils.max(maxBalance, balance);
View Full Code Here

  public float getAreaRatio () {
    if (m_root == NULL_NODE) {
      return 0.0f;
    }

    final TreeNode root = m_nodes[m_root];
    float rootArea = root.aabb.getPerimeter();

    float totalArea = 0.0f;
    for (int i = 0; i < m_nodeCapacity; ++i) {
      final TreeNode node = m_nodes[i];
      if (node.height < 0) {
        // Free node in pool
        continue;
      }
View Full Code Here

        }
      }

      int index1 = nodes[iMin];
      int index2 = nodes[jMin];
      TreeNode child1 = m_nodes[index1];
      TreeNode child2 = m_nodes[index2];

      int parentIndex = allocateNode();
      TreeNode parent = m_nodes[parentIndex];
      parent.child1 = index1;
      parent.child2 = index2;
      parent.height = 1 + MathUtils.max(child1.height, child2.height);
      parent.aabb.combine(child1.aabb, child2.aabb);
      parent.parent = NULL_NODE;
View Full Code Here

      m_nodes = new TreeNode[m_nodeCapacity];
      System.arraycopy(old, 0, m_nodes, 0, old.length);

      // Build a linked list for the free list.
      for (int i = m_nodeCount; i < m_nodeCapacity; i++) {
        m_nodes[i] = new TreeNode();
        m_nodes[i].parent = i + 1;
        m_nodes[i].height = -1;
      }
      m_nodes[m_nodeCapacity - 1].parent = TreeNode.NULL_NODE;
      m_freeList = m_nodeCount;
View Full Code Here

TOP

Related Classes of org.jbox2d.collision.broadphase.TreeNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.