本文整理汇总了Java中com.bulletphysics.linearmath.MiscUtil.resize方法的典型用法代码示例。如果您正苦于以下问题:Java MiscUtil.resize方法的具体用法?Java MiscUtil.resize怎么用?Java MiscUtil.resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.bulletphysics.linearmath.MiscUtil
的用法示例。
在下文中一共展示了MiscUtil.resize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: split
import com.bulletphysics.linearmath.MiscUtil; //导入方法依赖的package包/类
private static void split (ObjectArrayList<Node> leaves, ObjectArrayList<Node> left, ObjectArrayList<Node> right, Vector3 org,
Vector3 axis) {
Stack stack = Stack.enter();
Vector3 tmp = stack.allocVector3();
MiscUtil.resize(left, 0, NEW_NODE_SUPPLIER);
MiscUtil.resize(right, 0, NEW_NODE_SUPPLIER);
for (int i = 0, ni = leaves.size(); i < ni; i++) {
leaves.getQuick(i).volume.Center(tmp);
tmp.sub(org);
if (axis.dot(tmp) < 0f) {
left.add(leaves.getQuick(i));
} else {
right.add(leaves.getQuick(i));
}
}
stack.leave();
}
示例2: calchull
import com.bulletphysics.linearmath.MiscUtil; //导入方法依赖的package包/类
private int calchull (ObjectArrayList<Vector3> verts, int verts_count, IntArray tris_out, int[] tris_count, int vlimit) {
int rc = calchullgen(verts, verts_count, vlimit);
if (rc == 0) return 0;
IntArray ts = new IntArray();
for (int i = 0; i < tris.size(); i++) {
if (tris.getQuick(i) != null) {
for (int j = 0; j < 3; j++) {
ts.add((tris.getQuick(i)).getCoord(j));
}
deAllocateTriangle(tris.getQuick(i));
}
}
tris_count[0] = ts.size / 3;
MiscUtil.resize(tris_out, ts.size, 0);
for (int i = 0; i < ts.size; i++) {
tris_out.set(i, ts.get(i));
}
MiscUtil.resize(tris, 0, NEW_TRI_SUPPLIER);
return 1;
}
示例3: calchull
import com.bulletphysics.linearmath.MiscUtil; //导入方法依赖的package包/类
private int calchull(ObjectArrayList<Vector3f> verts, int verts_count, IntArrayList tris_out, int[] tris_count, int vlimit) {
int rc = calchullgen(verts, verts_count, vlimit);
if (rc == 0) return 0;
IntArrayList ts = new IntArrayList();
for (int i=0; i<tris.size(); i++) {
if (tris.getQuick(i) != null) {
for (int j = 0; j < 3; j++) {
ts.add((tris.getQuick(i)).getCoord(j));
}
deAllocateTriangle(tris.getQuick(i));
}
}
tris_count[0] = ts.size() / 3;
MiscUtil.resize(tris_out, ts.size(), 0);
for (int i=0; i<ts.size(); i++) {
tris_out.set(i, ts.get(i));
}
MiscUtil.resize(tris, 0, Tri.class);
return 1;
}
示例4: calchull
import com.bulletphysics.linearmath.MiscUtil; //导入方法依赖的package包/类
private int calchull(List<Vector3f> verts, int verts_count, IntArrayList tris_out, int[] tris_count, int vlimit) {
int rc = calchullgen(verts, verts_count, vlimit);
if (rc == 0) return 0;
IntArrayList ts = new IntArrayList();
for (int i=0; i<tris.size(); i++) {
if (tris.get(i) != null) {
for (int j = 0; j < 3; j++) {
ts.add((tris.get(i)).getCoord(j));
}
deAllocateTriangle(tris.get(i));
}
}
tris_count[0] = ts.size() / 3;
MiscUtil.resize(tris_out, ts.size(), 0);
for (int i=0; i<ts.size(); i++) {
tris_out.set(i, ts.get(i));
}
MiscUtil.resize(tris, 0, Tri.class);
return 1;
}
示例5: ShapeHull
import com.bulletphysics.linearmath.MiscUtil; //导入方法依赖的package包/类
public ShapeHull(ConvexShape shape) {
this.shape = shape;
this.vertices.clear();
this.indices.clear();
this.numIndices = 0;
MiscUtil.resize(unitSpherePoints, NUM_UNITSPHERE_POINTS+ConvexShape.MAX_PREFERRED_PENETRATION_DIRECTIONS*2, Suppliers.NEW_VECTOR3_SUPPLIER);
for (int i=0; i<constUnitSpherePoints.size(); i++) {
unitSpherePoints.getQuick(i).set(constUnitSpherePoints.getQuick(i));
}
}
示例6: growTables
import com.bulletphysics.linearmath.MiscUtil; //导入方法依赖的package包/类
private void growTables() {
int newCapacity = overlappingPairArray.capacity();
if (hashTable.size < newCapacity) {
// grow hashtable and next table
int curHashtableSize = hashTable.size;
MiscUtil.resize(hashTable, newCapacity, 0);
MiscUtil.resize(next, newCapacity, 0);
for (int i=0; i<newCapacity; ++i) {
hashTable.set(i, NULL_PAIR);
}
for (int i=0; i<newCapacity; ++i) {
next.set(i, NULL_PAIR);
}
for (int i=0; i<curHashtableSize; i++) {
BroadphasePair pair = overlappingPairArray.getQuick(i);
int proxyId1 = pair.pProxy0.getUid();
int proxyId2 = pair.pProxy1.getUid();
/*if (proxyId1 > proxyId2)
btSwap(proxyId1, proxyId2);*/
int hashValue = getHash(proxyId1, proxyId2) & (overlappingPairArray.capacity() - 1); // New hash value with new mask
next.set(i, hashTable.get(hashValue));
hashTable.set(hashValue, i);
}
}
}
示例7: ShapeHull
import com.bulletphysics.linearmath.MiscUtil; //导入方法依赖的package包/类
public ShapeHull(ConvexShape shape) {
this.shape = shape;
this.vertices.clear();
this.indices.clear();
this.numIndices = 0;
MiscUtil.resize(unitSpherePoints, NUM_UNITSPHERE_POINTS+ConvexShape.MAX_PREFERRED_PENETRATION_DIRECTIONS*2, Vector3f.class);
for (int i=0; i<constUnitSpherePoints.size(); i++) {
unitSpherePoints.getQuick(i).set(constUnitSpherePoints.getQuick(i));
}
}
示例8: growTables
import com.bulletphysics.linearmath.MiscUtil; //导入方法依赖的package包/类
private void growTables() {
int newCapacity = overlappingPairArray.capacity();
if (hashTable.size() < newCapacity) {
// grow hashtable and next table
int curHashtableSize = hashTable.size();
MiscUtil.resize(hashTable, newCapacity, 0);
MiscUtil.resize(next, newCapacity, 0);
for (int i=0; i<newCapacity; ++i) {
hashTable.set(i, NULL_PAIR);
}
for (int i=0; i<newCapacity; ++i) {
next.set(i, NULL_PAIR);
}
for (int i=0; i<curHashtableSize; i++) {
BroadphasePair pair = overlappingPairArray.getQuick(i);
int proxyId1 = pair.pProxy0.getUid();
int proxyId2 = pair.pProxy1.getUid();
/*if (proxyId1 > proxyId2)
btSwap(proxyId1, proxyId2);*/
int hashValue = getHash(proxyId1, proxyId2) & (overlappingPairArray.capacity() - 1); // New hash value with new mask
next.set(i, hashTable.get(hashValue));
hashTable.set(hashValue, i);
}
}
}
示例9: split
import com.bulletphysics.linearmath.MiscUtil; //导入方法依赖的package包/类
private static void split(ObjectArrayList<Node> leaves, ObjectArrayList<Node> left, ObjectArrayList<Node> right, Vector3f org, Vector3f axis) {
Vector3f tmp = Stack.alloc(Vector3f.class);
MiscUtil.resize(left, 0, Node.class);
MiscUtil.resize(right, 0, Node.class);
for (int i=0, ni=leaves.size(); i<ni; i++) {
leaves.getQuick(i).volume.Center(tmp);
tmp.sub(org);
if (axis.dot(tmp) < 0f) {
left.add(leaves.getQuick(i));
}
else {
right.add(leaves.getQuick(i));
}
}
}
示例10: growTables
import com.bulletphysics.linearmath.MiscUtil; //导入方法依赖的package包/类
private void growTables() {
int newCapacity = overlappingPairArray.capacity();
if (hashTable.size() < newCapacity) {
// grow hashtable and next table
int curHashtableSize = hashTable.size();
MiscUtil.resize(hashTable, newCapacity, 0);
MiscUtil.resize(next, newCapacity, 0);
for (int i=0; i<newCapacity; ++i) {
hashTable.set(i, NULL_PAIR);
}
for (int i=0; i<newCapacity; ++i) {
next.set(i, NULL_PAIR);
}
for (int i=0; i<curHashtableSize; i++) {
BroadphasePair pair = overlappingPairArray.get(i);
int proxyId1 = pair.pProxy0.getUid();
int proxyId2 = pair.pProxy1.getUid();
/*if (proxyId1 > proxyId2)
btSwap(proxyId1, proxyId2);*/
int hashValue = getHash(proxyId1, proxyId2) & (overlappingPairArray.capacity() - 1); // New hash value with new mask
next.set(i, hashTable.get(hashValue));
hashTable.set(hashValue, i);
}
}
}
示例11: bringOutYourDead
import com.bulletphysics.linearmath.MiscUtil; //导入方法依赖的package包/类
private void bringOutYourDead(List<Vector3f> verts, int vcount, List<Vector3f> overts, int[] ocount, IntArrayList indices, int indexcount) {
IntArrayList usedIndices = new IntArrayList();
MiscUtil.resize(usedIndices, vcount, 0);
/*
JAVA NOTE: redudant
for (int i=0; i<vcount; i++) {
usedIndices.set(i, 0);
}
*/
ocount[0] = 0;
for (int i=0; i<indexcount; i++) {
int v = indices.get(i); // original array index
assert (v >= 0 && v < vcount);
if (usedIndices.get(v) != 0) { // if already remapped
indices.set(i, usedIndices.get(v) - 1); // index to new array
}
else {
indices.set(i, ocount[0]); // new index mapping
overts.get(ocount[0]).set(verts.get(v)); // copy old vert to new vert array
ocount[0]++; // increment output vert count
assert (ocount[0] >= 0 && ocount[0] <= vcount);
usedIndices.set(v, ocount[0]); // assign new index remapping
}
}
}
示例12: buildHull
import com.bulletphysics.linearmath.MiscUtil; //导入方法依赖的package包/类
public boolean buildHull(float margin) {
Stack stack = Stack.enter();
Vector3 norm = stack.allocVector3();
int numSampleDirections = NUM_UNITSPHERE_POINTS;
{
int numPDA = shape.getNumPreferredPenetrationDirections();
if (numPDA != 0) {
for (int i=0; i<numPDA; i++) {
shape.getPreferredPenetrationDirection(i, norm);
unitSpherePoints.getQuick(numSampleDirections).set(norm);
numSampleDirections++;
}
}
}
ObjectArrayList<Vector3> supportPoints = new ObjectArrayList<Vector3>();
MiscUtil.resize(supportPoints, NUM_UNITSPHERE_POINTS + ConvexShape.MAX_PREFERRED_PENETRATION_DIRECTIONS * 2, Suppliers.NEW_VECTOR3_SUPPLIER);
for (int i=0; i<numSampleDirections; i++) {
shape.localGetSupportingVertex(unitSpherePoints.getQuick(i), supportPoints.getQuick(i));
}
HullDesc hd = new HullDesc();
hd.flags = HullFlags.TRIANGLES;
hd.vcount = numSampleDirections;
//#ifdef BT_USE_DOUBLE_PRECISION
//hd.mVertices = &supportPoints[0];
//hd.mVertexStride = sizeof(btVector3);
//#else
hd.vertices = supportPoints;
//hd.vertexStride = 3 * 4;
//#endif
HullLibrary hl = new HullLibrary();
HullResult hr = new HullResult();
if (!hl.createConvexHull(hd, hr)) {
stack.leave();
return false;
}
MiscUtil.resize(vertices, hr.numOutputVertices, Suppliers.NEW_VECTOR3_SUPPLIER);
for (int i=0; i<hr.numOutputVertices; i++) {
vertices.getQuick(i).set(hr.outputVertices.getQuick(i));
}
numIndices = hr.numIndices;
MiscUtil.resize(indices, numIndices, 0);
for (int i=0; i<numIndices; i++) {
indices.set(i, hr.indices.get(i));
}
// free temporary hull result that we just copied
hl.releaseResult(hr);
stack.leave();
return true;
}
示例13: calculateOverlappingPairs
import com.bulletphysics.linearmath.MiscUtil; //导入方法依赖的package包/类
public void calculateOverlappingPairs (Dispatcher dispatcher) {
if (pairCache.hasDeferredRemoval()) {
ObjectArrayList<BroadphasePair> overlappingPairArray = pairCache.getOverlappingPairArray();
// perform a sort, to find duplicates and to sort 'invalid' pairs to the end
MiscUtil.quickSort(overlappingPairArray, BroadphasePair.broadphasePairSortPredicate);
MiscUtil.resize(overlappingPairArray, overlappingPairArray.size() - invalidPair, NEW_BROADPHASE_PAIR_SUPPLIER);
invalidPair = 0;
int i;
BroadphasePair previousPair = new BroadphasePair();
previousPair.pProxy0 = null;
previousPair.pProxy1 = null;
previousPair.algorithm = null;
for (i = 0; i < overlappingPairArray.size(); i++) {
BroadphasePair pair = overlappingPairArray.getQuick(i);
boolean isDuplicate = (pair.equals(previousPair));
previousPair.set(pair);
boolean needsRemoval = false;
if (!isDuplicate) {
boolean hasOverlap = testAabbOverlap(pair.pProxy0, pair.pProxy1);
if (hasOverlap) {
needsRemoval = false;// callback->processOverlap(pair);
} else {
needsRemoval = true;
}
} else {
// remove duplicate
needsRemoval = true;
// should have no algorithm
assert (pair.algorithm == null);
}
if (needsRemoval) {
pairCache.cleanOverlappingPair(pair, dispatcher);
// m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1);
// m_overlappingPairArray.pop_back();
pair.pProxy0 = null;
pair.pProxy1 = null;
invalidPair++;
BulletStats.gOverlappingPairs--;
}
}
// if you don't like to skip the invalid pairs in the array, execute following code:
// #define CLEAN_INVALID_PAIRS 1
// #ifdef CLEAN_INVALID_PAIRS
// perform a sort, to sort 'invalid' pairs to the end
MiscUtil.quickSort(overlappingPairArray, BroadphasePair.broadphasePairSortPredicate);
MiscUtil.resize(overlappingPairArray, overlappingPairArray.size() - invalidPair, NEW_BROADPHASE_PAIR_SUPPLIER);
invalidPair = 0;
// #endif//CLEAN_INVALID_PAIRS
// printf("overlappingPairArray.size()=%d\n",overlappingPairArray.size());
}
}
示例14: allocate
import com.bulletphysics.linearmath.MiscUtil; //导入方法依赖的package包/类
public void allocate(int N) {
MiscUtil.resize(elements, N, NEW_ELEMENT_SUPPLIER);
}
示例15: bringOutYourDead
import com.bulletphysics.linearmath.MiscUtil; //导入方法依赖的package包/类
private void bringOutYourDead (ObjectArrayList<Vector3> verts, int vcount, ObjectArrayList<Vector3> overts, int[] ocount,
IntArray indices, int indexcount) {
IntArray tmpIndices = new IntArray();
for (int i = 0; i < vertexIndexMapping.size; i++) {
tmpIndices.add(vertexIndexMapping.size);
}
IntArray usedIndices = new IntArray();
MiscUtil.resize(usedIndices, vcount, 0);
/*
* JAVA NOTE: redudant for (int i=0; i<vcount; i++) { usedIndices.set(i, 0); }
*/
ocount[0] = 0;
for (int i = 0; i < indexcount; i++) {
int v = indices.get(i); // original array index
assert (v >= 0 && v < vcount);
if (usedIndices.get(v) != 0) { // if already remapped
indices.set(i, usedIndices.get(v) - 1); // index to new array
} else {
indices.set(i, ocount[0]); // new index mapping
overts.getQuick(ocount[0]).set(verts.getQuick(v)); // copy old vert to new vert array
for (int k = 0; k < vertexIndexMapping.size; k++) {
if (tmpIndices.get(k) == v) {
vertexIndexMapping.set(k, ocount[0]);
}
}
ocount[0]++; // increment output vert count
assert (ocount[0] >= 0 && ocount[0] <= vcount);
usedIndices.set(v, ocount[0]); // assign new index remapping
}
}
}