static int[] reallocateBuffer(ParticleBufferInt buffer, int oldCapacity, int newCapacity, boolean deferred) { assert (newCapacity > oldCapacity); return BufferUtils.reallocateBuffer(buffer.data, buffer.userSuppliedCapacity, oldCapacity, newCapacity, deferred); }
static <T> T[] reallocateBuffer(ParticleBuffer<T> buffer, int oldCapacity, int newCapacity, boolean deferred) { assert (newCapacity > oldCapacity); return BufferUtils.reallocateBuffer(buffer.dataClass, buffer.data, buffer.userSuppliedCapacity, oldCapacity, newCapacity, deferred); }
/** * Reallocate a buffer. A 'deferred' buffer is reallocated only if it is not NULL. If * 'userSuppliedCapacity' is not zero, buffer is user supplied and must be kept. */ public static <T> T[] reallocateBuffer(Class<T> klass, T[] buffer, int userSuppliedCapacity, int oldCapacity, int newCapacity, boolean deferred) { assert (newCapacity > oldCapacity); assert (userSuppliedCapacity == 0 || newCapacity <= userSuppliedCapacity); if ((!deferred || buffer != null) && userSuppliedCapacity == 0) { buffer = reallocateBuffer(klass, buffer, oldCapacity, newCapacity); } return buffer; }
/** * Reallocate a float buffer. A 'deferred' buffer is reallocated only if it is not NULL. If * 'userSuppliedCapacity' is not zero, buffer is user supplied and must be kept. */ public static float[] reallocateBuffer(float[] buffer, int userSuppliedCapacity, int oldCapacity, int newCapacity, boolean deferred) { assert (newCapacity > oldCapacity); assert (userSuppliedCapacity == 0 || newCapacity <= userSuppliedCapacity); if ((!deferred || buffer != null) && userSuppliedCapacity == 0) { buffer = reallocateBuffer(buffer, oldCapacity, newCapacity); } return buffer; }
/** * Reallocate an int buffer. A 'deferred' buffer is reallocated only if it is not NULL. If * 'userSuppliedCapacity' is not zero, buffer is user supplied and must be kept. */ public static int[] reallocateBuffer(int[] buffer, int userSuppliedCapacity, int oldCapacity, int newCapacity, boolean deferred) { assert (newCapacity > oldCapacity); assert (userSuppliedCapacity == 0 || newCapacity <= userSuppliedCapacity); if ((!deferred || buffer != null) && userSuppliedCapacity == 0) { buffer = reallocateBuffer(buffer, oldCapacity, newCapacity); } return buffer; }
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; }
public void addContact(int a, int b) { assert(a != b); Vec2 pa = m_positionBuffer.data[a]; Vec2 pb = m_positionBuffer.data[b]; float dx = pb.x - pa.x; float dy = pb.y - pa.y; float d2 = dx * dx + dy * dy; // assert(d2 != 0); if (d2 < m_squaredDiameter) { if (m_contactCount >= m_contactCapacity) { int oldCapacity = m_contactCapacity; int newCapacity = m_contactCount != 0 ? 2 * m_contactCount : Settings.minParticleBufferCapacity; m_contactBuffer = BufferUtils.reallocateBuffer(ParticleContact.class, m_contactBuffer, oldCapacity, newCapacity); m_contactCapacity = newCapacity; } float invD = d2 != 0 ? MathUtils.sqrt(1 / d2) : Float.MAX_VALUE; ParticleContact contact = m_contactBuffer[m_contactCount]; contact.indexA = a; contact.indexB = b; contact.flags = m_flagsBuffer.data[a] | m_flagsBuffer.data[b]; contact.weight = 1 - d2 * invD * m_inverseDiameter; contact.normal.x = invD * dx; contact.normal.y = invD * dy; m_contactCount++; } }
@Override public final void query(TreeCallback callback, AABB aabb) { nodeStackIndex = 0; nodeStack[nodeStackIndex++] = m_root; while (nodeStackIndex > 0) { int node = nodeStack[--nodeStackIndex]; if (node == NULL_NODE) { continue; } if (AABB.testOverlap(m_aabb[node], aabb)) { int child1 = m_child1[node]; if (child1 == NULL_NODE) { boolean proceed = callback.treeCallback(node); if (!proceed) { return; } } else { if (nodeStack.length - nodeStackIndex - 2 <= 0) { nodeStack = BufferUtils.reallocateBuffer(nodeStack, nodeStack.length, nodeStack.length * 2); } nodeStack[nodeStackIndex++] = child1; nodeStack[nodeStackIndex++] = m_child2[node]; } } } }
: Settings.minParticleBufferCapacity; system.m_triadBuffer = BufferUtils.reallocateBuffer(Triad.class, system.m_triadBuffer, oldCapacity, newCapacity); system.m_triadCapacity = newCapacity;
reallocateBuffer(m_velocityBuffer, m_internalAllocatedCapacity, capacity, false); m_accumulationBuffer = BufferUtils.reallocateBuffer(m_accumulationBuffer, 0, m_internalAllocatedCapacity, capacity, false); m_accumulation2Buffer = BufferUtils.reallocateBuffer(Vec2.class, m_accumulation2Buffer, 0, m_internalAllocatedCapacity, capacity, true); m_depthBuffer = BufferUtils.reallocateBuffer(m_depthBuffer, 0, m_internalAllocatedCapacity, capacity, true); m_colorBuffer.data = reallocateBuffer(m_colorBuffer, m_internalAllocatedCapacity, capacity, true); m_groupBuffer = BufferUtils.reallocateBuffer(ParticleGroup.class, m_groupBuffer, 0, m_internalAllocatedCapacity, capacity, false); m_userDataBuffer.data = int newCapacity = m_proxyCount != 0 ? 2 * m_proxyCount : Settings.minParticleBufferCapacity; m_proxyBuffer = BufferUtils.reallocateBuffer(Proxy.class, m_proxyBuffer, oldCapacity, newCapacity); m_proxyCapacity = newCapacity;
: Settings.minParticleBufferCapacity; system.m_triadBuffer = BufferUtils.reallocateBuffer(Triad.class, system.m_triadBuffer, oldCapacity, newCapacity); system.m_triadCapacity = newCapacity;
static <T> T[] reallocateBuffer(ParticleBuffer<T> buffer, int oldCapacity, int newCapacity, boolean deferred) { assert (newCapacity > oldCapacity); return BufferUtils.reallocateBuffer(buffer.dataClass, buffer.data, buffer.userSuppliedCapacity, oldCapacity, newCapacity, deferred); }
static int[] reallocateBuffer(ParticleBufferInt buffer, int oldCapacity, int newCapacity, boolean deferred) { assert (newCapacity > oldCapacity); return BufferUtils.reallocateBuffer(buffer.data, buffer.userSuppliedCapacity, oldCapacity, newCapacity, deferred); }
/** * Reallocate an int buffer. A 'deferred' buffer is reallocated only if it is not NULL. If * 'userSuppliedCapacity' is not zero, buffer is user supplied and must be kept. */ public static int[] reallocateBuffer(int[] buffer, int userSuppliedCapacity, int oldCapacity, int newCapacity, boolean deferred) { assert (newCapacity > oldCapacity); assert (userSuppliedCapacity == 0 || newCapacity <= userSuppliedCapacity); if ((!deferred || buffer != null) && userSuppliedCapacity == 0) { buffer = reallocateBuffer(buffer, oldCapacity, newCapacity); } return buffer; }
/** * Reallocate a float buffer. A 'deferred' buffer is reallocated only if it is not NULL. If * 'userSuppliedCapacity' is not zero, buffer is user supplied and must be kept. */ public static float[] reallocateBuffer(float[] buffer, int userSuppliedCapacity, int oldCapacity, int newCapacity, boolean deferred) { assert (newCapacity > oldCapacity); assert (userSuppliedCapacity == 0 || newCapacity <= userSuppliedCapacity); if ((!deferred || buffer != null) && userSuppliedCapacity == 0) { buffer = reallocateBuffer(buffer, oldCapacity, newCapacity); } return buffer; }
/** * Reallocate a buffer. A 'deferred' buffer is reallocated only if it is not NULL. If * 'userSuppliedCapacity' is not zero, buffer is user supplied and must be kept. */ public static <T> T[] reallocateBuffer(Class<T> klass, T[] buffer, int userSuppliedCapacity, int oldCapacity, int newCapacity, boolean deferred) { assert (newCapacity > oldCapacity); assert (userSuppliedCapacity == 0 || newCapacity <= userSuppliedCapacity); if ((!deferred || buffer != null) && userSuppliedCapacity == 0) { buffer = reallocateBuffer(klass, buffer, oldCapacity, newCapacity); } return buffer; }
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; }
m_pairCount != 0 ? 2 * m_pairCount : Settings.minParticleBufferCapacity; m_pairBuffer = BufferUtils.reallocateBuffer(Pair.class, m_pairBuffer, oldCapacity, newCapacity); m_pairCapacity = newCapacity;
: Settings.minParticleBufferCapacity; system.m_bodyContactBuffer = BufferUtils.reallocateBuffer(ParticleBodyContact.class, system.m_bodyContactBuffer, oldCapacity, newCapacity); system.m_bodyContactCapacity = newCapacity;
m_pairCount != 0 ? 2 * m_pairCount : Settings.minParticleBufferCapacity; m_pairBuffer = BufferUtils.reallocateBuffer(Pair.class, m_pairBuffer, oldCapacity, newCapacity); m_pairCapacity = newCapacity;