protected AABB newInstance() { return new AABB(); } };
private void expandBuffers(int oldSize, int newSize) { m_aabb = BufferUtils.reallocateBuffer(AABB.class, m_aabb, oldSize, newSize); m_userData = BufferUtils.reallocateBuffer(Object.class, m_userData, oldSize, newSize); m_parent = BufferUtils.reallocateBuffer(m_parent, oldSize, newSize); m_child1 = BufferUtils.reallocateBuffer(m_child1, oldSize, newSize); m_child2 = BufferUtils.reallocateBuffer(m_child2, oldSize, newSize); m_height = BufferUtils.reallocateBuffer(m_height, oldSize, newSize); // Build a linked list for the free list. for (int i = oldSize; i < newSize; i++) { m_aabb[i] = new AABB(); m_parent[i] = (i == newSize - 1) ? NULL_NODE : i + 1; m_height[i] = -1; m_child1[i] = -1; m_child2[i] = -1; } m_freeList = oldSize; }
private void validateMetrics(int node) { if (node == NULL_NODE) { return; } int child1 = m_child1[node]; int child2 = m_child2[node]; if (child1 == NULL_NODE) { assert (child1 == NULL_NODE); assert (child2 == NULL_NODE); assert (m_height[node] == 0); return; } assert (child1 != NULL_NODE && 0 <= child1 && child1 < m_nodeCapacity); assert (child2 != child1 && 0 <= child2 && child2 < m_nodeCapacity); int height1 = m_height[child1]; int height2 = m_height[child2]; int height; height = 1 + MathUtils.max(height1, height2); assert (m_height[node] == height); AABB aabb = new AABB(); aabb.combine(m_aabb[child1], m_aabb[child2]); assert (aabb.lowerBound.equals(m_aabb[node].lowerBound)); assert (aabb.upperBound.equals(m_aabb[node].upperBound)); validateMetrics(child1); validateMetrics(child2); }
private void validateMetrics(DynamicTreeNode node) { if (node == null) { return; } DynamicTreeNode child1 = node.child1; DynamicTreeNode child2 = node.child2; if (node.child1 == null) { assert (child1 == null); assert (child2 == null); assert (node.height == 0); return; } assert (child1 != null && 0 <= child1.id && child1.id < m_nodeCapacity); assert (child2 != null && 0 <= child2.id && child2.id < m_nodeCapacity); int height1 = child1.height; int height2 = child2.height; int height; height = 1 + MathUtils.max(height1, height2); assert (node.height == height); AABB aabb = new AABB(); aabb.combine(child1.aabb, child2.aabb); assert (aabb.lowerBound.equals(node.aabb.lowerBound)); assert (aabb.upperBound.equals(node.aabb.upperBound)); validateMetrics(child1); validateMetrics(child2); }
AABB b = new AABB(); while (count > 1) { float minCost = Float.MAX_VALUE;
protected AABB newInstance() { return new AABB(); } };
public void MoveProxy() { for (int i = 0; i < e_actorCount; ++i) { int j = MathUtils.abs(rand.nextInt() % e_actorCount); Actor actor = m_actors[j]; if (actor.proxyId == -1) { continue; } AABB aabb0 = new AABB(actor.aabb); MoveAABB(actor.aabb); Vec2 displacement = actor.aabb.getCenter().sub(aabb0.getCenter()); m_tree.moveProxy(actor.proxyId, new AABB(actor.aabb), displacement); return; } }
private void expandBuffers(int oldSize, int newSize) { m_aabb = BufferUtils.reallocateBuffer(AABB.class, m_aabb, oldSize, newSize); m_userData = BufferUtils.reallocateBuffer(Object.class, m_userData, oldSize, newSize); m_parent = BufferUtils.reallocateBuffer(m_parent, oldSize, newSize); m_child1 = BufferUtils.reallocateBuffer(m_child1, oldSize, newSize); m_child2 = BufferUtils.reallocateBuffer(m_child2, oldSize, newSize); m_height = BufferUtils.reallocateBuffer(m_height, oldSize, newSize); // Build a linked list for the free list. for (int i = oldSize; i < newSize; i++) { m_aabb[i] = new AABB(); m_parent[i] = (i == newSize - 1) ? NULL_NODE : i + 1; m_height[i] = -1; m_child1[i] = -1; m_child2[i] = -1; } m_freeList = oldSize; }
private void validateMetrics(int node) { if (node == NULL_NODE) { return; } int child1 = m_child1[node]; int child2 = m_child2[node]; if (child1 == NULL_NODE) { assert (child1 == NULL_NODE); assert (child2 == NULL_NODE); assert (m_height[node] == 0); return; } assert (child1 != NULL_NODE && 0 <= child1 && child1 < m_nodeCapacity); assert (child2 != child1 && 0 <= child2 && child2 < m_nodeCapacity); int height1 = m_height[child1]; int height2 = m_height[child2]; int height; height = 1 + MathUtils.max(height1, height2); assert (m_height[node] == height); AABB aabb = new AABB(); aabb.combine(m_aabb[child1], m_aabb[child2]); assert (aabb.lowerBound.equals(m_aabb[node].lowerBound)); assert (aabb.upperBound.equals(m_aabb[node].upperBound)); validateMetrics(child1); validateMetrics(child2); }
private void validateMetrics(DynamicTreeNode node) { if (node == null) { return; } DynamicTreeNode child1 = node.child1; DynamicTreeNode child2 = node.child2; if (node.child1 == null) { assert (child1 == null); assert (child2 == null); assert (node.height == 0); return; } assert (child1 != null && 0 <= child1.id && child1.id < m_nodeCapacity); assert (child2 != null && 0 <= child2.id && child2.id < m_nodeCapacity); int height1 = child1.height; int height2 = child2.height; int height; height = 1 + MathUtils.max(height1, height2); assert (node.height == height); AABB aabb = new AABB(); aabb.combine(child1.aabb, child2.aabb); assert (aabb.lowerBound.equals(node.aabb.lowerBound)); assert (aabb.upperBound.equals(node.aabb.upperBound)); validateMetrics(child1); validateMetrics(child2); }
protected AABB newInstance() { return new AABB(); } };
protected AABB newInstance() { return new AABB(); } };
protected AABB newInstance() { return new AABB(); } };
AABB b = new AABB(); while (count > 1) { float minCost = Float.MAX_VALUE;
@Override public void initTest(boolean argDeserialized) { worldExtent = 15.0f; m_proxyExtent = 0.5f; m_tree = new DynamicTree(); for (int i = 0; i < e_actorCount; ++i) { Actor actor = m_actors[i] = new Actor(); GetRandomAABB(actor.aabb); actor.proxyId = m_tree.createProxy(actor.aabb, actor); } m_stepCount = 0; float h = worldExtent; m_queryAABB = new AABB(); m_queryAABB.lowerBound.set(-3.0f, -4.0f + h); m_queryAABB.upperBound.set(5.0f, 6.0f + h); m_rayCastInput = new RayCastInput(); m_rayCastInput.p1.set(-5.0f, 5.0f + h); m_rayCastInput.p2.set(7.0f, -4.0f + h); // m_rayCastInput.p1.set(0.0f, 2.0f + h); // m_rayCastInput.p2.set(0.0f, -2.0f + h); m_rayCastInput.maxFraction = 1.0f; m_rayCastOutput = new RayCastOutput(); m_automated = false; }
/** * @see org.jbox2d.testbed.framework.TestbedTest#step(org.jbox2d.testbed.framework.TestbedSettings) */ @Override public void step(TestbedSettings settings) { super.step(settings); PolyShapesCallback callback = new PolyShapesCallback(getWorld().getPool()); callback.m_circle.m_radius = 2.0f; callback.m_circle.m_p.set(0.0f, 2.1f); callback.m_transform.setIdentity(); callback.debugDraw = getDebugDraw(); AABB aabb = new AABB(); callback.m_circle.computeAABB(aabb, callback.m_transform, 0); getWorld().queryAABB(callback, aabb); Color3f color = new Color3f(0.4f, 0.7f, 0.8f); getDebugDraw().drawCircle(callback.m_circle.m_p, callback.m_circle.m_radius, color); addTextLine("Press 1-5 to drop stuff"); addTextLine("Press 'a' to (de)activate some bodies"); addTextLine("Press 'd' to destroy a body"); addTextLine("Up to 30 bodies in the target circle are highlighted"); }
public void MoveProxy() { for (int i = 0; i < e_actorCount; ++i) { int j = MathUtils.abs(rand.nextInt() % e_actorCount); Actor actor = m_actors[j]; if (actor.proxyId == -1) { continue; } AABB aabb0 = new AABB(actor.aabb); MoveAABB(actor.aabb); Vec2 displacement = actor.aabb.getCenter().sub(aabb0.getCenter()); m_tree.moveProxy(actor.proxyId, new AABB(actor.aabb), displacement); return; } }
private void expandBuffers(int oldSize, int newSize) { m_aabb = BufferUtils.reallocateBuffer(AABB.class, m_aabb, oldSize, newSize); m_userData = BufferUtils.reallocateBuffer(Object.class, m_userData, oldSize, newSize); m_parent = BufferUtils.reallocateBuffer(m_parent, oldSize, newSize); m_child1 = BufferUtils.reallocateBuffer(m_child1, oldSize, newSize); m_child2 = BufferUtils.reallocateBuffer(m_child2, oldSize, newSize); m_height = BufferUtils.reallocateBuffer(m_height, oldSize, newSize); // Build a linked list for the free list. for (int i = oldSize; i < newSize; i++) { m_aabb[i] = new AABB(); m_parent[i] = (i == newSize - 1) ? NULL_NODE : i + 1; m_height[i] = -1; m_child1[i] = -1; m_child2[i] = -1; } m_freeList = oldSize; }
private void expandBuffers(int oldSize, int newSize) { m_aabb = BufferUtils.reallocateBuffer(AABB.class, m_aabb, oldSize, newSize); m_userData = BufferUtils.reallocateBuffer(Object.class, m_userData, oldSize, newSize); m_parent = BufferUtils.reallocateBuffer(m_parent, oldSize, newSize); m_child1 = BufferUtils.reallocateBuffer(m_child1, oldSize, newSize); m_child2 = BufferUtils.reallocateBuffer(m_child2, oldSize, newSize); m_height = BufferUtils.reallocateBuffer(m_height, oldSize, newSize); // Build a linked list for the free list. for (int i = oldSize; i < newSize; i++) { m_aabb[i] = new AABB(); m_parent[i] = (i == newSize - 1) ? NULL_NODE : i + 1; m_height[i] = -1; m_child1[i] = -1; m_child2[i] = -1; } m_freeList = oldSize; }
/** * @see org.jbox2d.testbed.framework.TestbedTest#step(org.jbox2d.testbed.framework.TestbedSettings) */ @Override public void step(TestbedSettings settings) { super.step(settings); PolyShapesCallback callback = new PolyShapesCallback(getWorld().getPool()); callback.m_circle.m_radius = 2.0f; callback.m_circle.m_p.set(0.0f, 2.1f); callback.m_transform.setIdentity(); callback.debugDraw = getDebugDraw(); AABB aabb = new AABB(); callback.m_circle.computeAABB(aabb, callback.m_transform, 0); getWorld().queryAABB(callback, aabb); Color3f color = new Color3f(0.4f, 0.7f, 0.8f); getDebugDraw().drawCircle(callback.m_circle.m_p, callback.m_circle.m_radius, color); addTextLine("Press 1-5 to drop stuff"); addTextLine("Press 'a' to (de)activate some bodies"); addTextLine("Press 'd' to destroy a body"); addTextLine("Up to 30 bodies in the target circle are highlighted"); }