当前位置: 首页>>代码示例>>Java>>正文


Java MiscUtil.resize方法代码示例

本文整理汇总了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();
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:18,代码来源:Dbvt.java

示例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;
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:25,代码来源:HullLibrary.java

示例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;
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:25,代码来源:HullLibrary.java

示例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;
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:25,代码来源:HullLibrary.java

示例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));
	}
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:12,代码来源:ShapeHull.java

示例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);
		}
	}
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:31,代码来源:HashedOverlappingPairCache.java

示例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));
	}
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:12,代码来源:ShapeHull.java

示例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);
		}
	}
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:31,代码来源:HashedOverlappingPairCache.java

示例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));
		}
	}
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:16,代码来源:Dbvt.java

示例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);
		}
	}
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:31,代码来源:HashedOverlappingPairCache.java

示例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
		}
	}
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:34,代码来源:HullLibrary.java

示例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;
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:60,代码来源:ShapeHull.java

示例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());
	}
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:69,代码来源:AxisSweep3Internal.java

示例14: allocate

import com.bulletphysics.linearmath.MiscUtil; //导入方法依赖的package包/类
public void allocate(int N) {
	MiscUtil.resize(elements, N, NEW_ELEMENT_SUPPLIER);
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:4,代码来源:UnionFind.java

示例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
		}
	}
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:42,代码来源:HullLibrary.java


注:本文中的com.bulletphysics.linearmath.MiscUtil.resize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。