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


Java MiscUtil.quickSort方法代码示例

本文整理汇总了Java中com.bulletphysics.linearmath.MiscUtil.quickSort方法的典型用法代码示例。如果您正苦于以下问题:Java MiscUtil.quickSort方法的具体用法?Java MiscUtil.quickSort怎么用?Java MiscUtil.quickSort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.bulletphysics.linearmath.MiscUtil的用法示例。


在下文中一共展示了MiscUtil.quickSort方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sortIslands

import com.bulletphysics.linearmath.MiscUtil; //导入方法依赖的package包/类
/**
 * This is a special operation, destroying the content of UnionFind.
 * It sorts the elements, based on island id, in order to make it easy to iterate over islands.
 */
public void sortIslands() {
	// first store the original body index, and islandId
	int numElements = elements.size();

	for (int i = 0; i < numElements; i++) {
		elements.getQuick(i).id = find(i);
		elements.getQuick(i).sz = i;
	}

	// Sort the vector using predicate and std::sort
	//std::sort(m_elements.begin(), m_elements.end(), btUnionFindElementSortPredicate);
	//perhaps use radix sort?
	//elements.heapSort(btUnionFindElementSortPredicate());
	
	//Collections.sort(elements);
	MiscUtil.quickSort(elements, elementComparator);
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:22,代码来源:UnionFind.java

示例2: solveConstraints

import com.bulletphysics.linearmath.MiscUtil; //导入方法依赖的package包/类
protected void solveConstraints(ContactSolverInfo solverInfo) {
	BulletStats.pushProfile("solveConstraints");
	try {
		// sorted version of all btTypedConstraint, based on islandId
		sortedConstraints.clear();
		for (int i=0; i<constraints.size(); i++) {
			sortedConstraints.add(constraints.getQuick(i));
		}
		//Collections.sort(sortedConstraints, sortConstraintOnIslandPredicate);
		MiscUtil.quickSort(sortedConstraints, sortConstraintOnIslandPredicate);

		ObjectArrayList<TypedConstraint> constraintsPtr = getNumConstraints() != 0 ? sortedConstraints : null;

		solverCallback.init(solverInfo, constraintSolver, constraintsPtr, sortedConstraints.size(), debugDrawer/*,m_stackAlloc*/, dispatcher1);

		constraintSolver.prepareSolve(getCollisionWorld().getNumCollisionObjects(), getCollisionWorld().getDispatcher().getNumManifolds());

		// solve all the constraints for this island
		islandManager.buildAndProcessIslands(getCollisionWorld().getDispatcher(), getCollisionWorld().getCollisionObjectArray(), solverCallback);

		constraintSolver.allSolved(solverInfo, debugDrawer/*, m_stackAlloc*/);
	}
	finally {
		BulletStats.popProfile();
	}
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:27,代码来源:DiscreteDynamicsWorld.java

示例3: sortIslands

import com.bulletphysics.linearmath.MiscUtil; //导入方法依赖的package包/类
/**
 * This is a special operation, destroying the content of UnionFind.
 * It sorts the elements, based on island id, in order to make it easy to iterate over islands.
 */
public void sortIslands() {
	// first store the original body index, and islandId
	int numElements = elements.size();

	for (int i = 0; i < numElements; i++) {
		elements.get(i).id = find(i);
		elements.get(i).sz = i;
	}

	// Sort the vector using predicate and std::sort
	//std::sort(m_elements.begin(), m_elements.end(), btUnionFindElementSortPredicate);
	//perhaps use radix sort?
	//elements.heapSort(btUnionFindElementSortPredicate());
	
	//Collections.sort(elements);
	MiscUtil.quickSort(elements, elementComparator);
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:22,代码来源:UnionFind.java

示例4: solveConstraints

import com.bulletphysics.linearmath.MiscUtil; //导入方法依赖的package包/类
protected void solveConstraints(ContactSolverInfo solverInfo) {
	BulletStats.pushProfile("solveConstraints");
	try {
		// sorted version of all btTypedConstraint, based on islandId
		sortedConstraints.clear();
		for (int i=0; i<constraints.size(); i++) {
			sortedConstraints.add(constraints.get(i));
		}
		//Collections.sort(sortedConstraints, sortConstraintOnIslandPredicate);
		MiscUtil.quickSort(sortedConstraints, sortConstraintOnIslandPredicate);

		List<TypedConstraint> constraintsPtr = getNumConstraints() != 0 ? sortedConstraints : null;

		solverCallback.init(solverInfo, constraintSolver, constraintsPtr, sortedConstraints.size(), debugDrawer/*,m_stackAlloc*/, dispatcher1);

		constraintSolver.prepareSolve(getCollisionWorld().getNumCollisionObjects(), getCollisionWorld().getDispatcher().getNumManifolds());

		// solve all the constraints for this island
		islandManager.buildAndProcessIslands(getCollisionWorld().getDispatcher(), getCollisionWorld().getCollisionObjectArray(), solverCallback);

		constraintSolver.allSolved(solverInfo, debugDrawer/*, m_stackAlloc*/);
	}
	finally {
		BulletStats.popProfile();
	}
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:27,代码来源:DiscreteDynamicsWorld.java

示例5: solveConstraints

import com.bulletphysics.linearmath.MiscUtil; //导入方法依赖的package包/类
protected void solveConstraints (ContactSolverInfo solverInfo) {
	BulletStats.pushProfile("solveConstraints");
	try {
		// sorted version of all btTypedConstraint, based on islandId
		sortedConstraints.clear();
		for (int i = 0; i < constraints.size(); i++) {
			sortedConstraints.add(constraints.getQuick(i));
		}
		// Collections.sort(sortedConstraints, sortConstraintOnIslandPredicate);
		MiscUtil.quickSort(sortedConstraints, sortConstraintOnIslandPredicate);

		ObjectArrayList<TypedConstraint> constraintsPtr = getNumConstraints() != 0 ? sortedConstraints : null;

		solverCallback.init(solverInfo, constraintSolver, constraintsPtr, sortedConstraints.size(),
			debugDrawer/* ,m_stackAlloc */, dispatcher1);

		constraintSolver.prepareSolve(getCollisionWorld().getNumCollisionObjects(), getCollisionWorld().getDispatcher()
			.getNumManifolds());

		// solve all the constraints for this island
		islandManager.buildAndProcessIslands(getCollisionWorld().getDispatcher(), getCollisionWorld().getCollisionObjectArray(),
			solverCallback);

		constraintSolver.allSolved(solverInfo, debugDrawer/* , m_stackAlloc */);
	} finally {
		BulletStats.popProfile();
	}
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:29,代码来源:DiscreteDynamicsWorld.java

示例6: 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

示例7: 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, BroadphasePair.class);
		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, BroadphasePair.class);
		invalidPair = 0;
		//#endif//CLEAN_INVALID_PAIRS

		//printf("overlappingPairArray.size()=%d\n",overlappingPairArray.size());
	}
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:71,代码来源:AxisSweep3Internal.java

示例8: calculateOverlappingPairs

import com.bulletphysics.linearmath.MiscUtil; //导入方法依赖的package包/类
public void calculateOverlappingPairs(Dispatcher dispatcher) {
	if (pairCache.hasDeferredRemoval()) {
		List<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, BroadphasePair.class);
		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.get(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, BroadphasePair.class);
		invalidPair = 0;
		//#endif//CLEAN_INVALID_PAIRS

		//printf("overlappingPairArray.size()=%d\n",overlappingPairArray.size());
	}
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:71,代码来源:AxisSweep3Internal.java


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