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


Java PersistentManifold.getNumContacts方法代码示例

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


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

示例1: update

import com.bulletphysics.collision.narrowphase.PersistentManifold; //导入方法依赖的package包/类
public static void update() {
	world.stepSimulation(Time.getDeltaSeconds());
	
	for (PersistentManifold pm : world.getDispatcher().getInternalManifoldPointer()) {
		GameObject objectA = (GameObject)((CollisionObject)pm.getBody0()).getUserPointer();
		GameObject objectB = (GameObject)((CollisionObject)pm.getBody1()).getUserPointer();
		
		if (objectA != null && objectB != null) {
			for (int contactId = 0; contactId < pm.getNumContacts(); contactId++) {
				ManifoldPoint mp = pm.getContactPoint(contactId);
				if (mp.getDistance() < 0.0f) {
					objectA.onCollision(mp,objectB);
				}
			}
		}
	}
}
 
开发者ID:Axodoss,项目名称:Wicken,代码行数:18,代码来源:PhysicsSystem.java

示例2: needsCollision

import com.bulletphysics.collision.narrowphase.PersistentManifold; //导入方法依赖的package包/类
@Override
public boolean needsCollision (BroadphaseProxy proxy0) {
	// don't collide with itself
	if (proxy0.clientObject == me) {
		return false;
	}

	// don't do CCD when the collision filters are not matching
	if (!super.needsCollision(proxy0)) {
		return false;
	}

	CollisionObject otherObj = (CollisionObject)proxy0.clientObject;

	// call needsResponse, see http://code.google.com/p/bullet/issues/detail?id=179
	if (dispatcher.needsResponse(me, otherObj)) {
		// don't do CCD when there are already contact points (touching contact/penetration)
		ObjectArrayList<PersistentManifold> manifoldArray = new ObjectArrayList<PersistentManifold>();
		BroadphasePair collisionPair = pairCache.findPair(me.getBroadphaseHandle(), proxy0);
		if (collisionPair != null) {
			if (collisionPair.algorithm != null) {
				// manifoldArray.resize(0);
				collisionPair.algorithm.getAllContactManifolds(manifoldArray);
				for (int j = 0; j < manifoldArray.size(); j++) {
					PersistentManifold manifold = manifoldArray.getQuick(j);
					if (manifold.getNumContacts() > 0) {
						return false;
					}
				}
			}
		}
	}
	return true;
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:35,代码来源:DiscreteDynamicsWorld.java

示例3: needsCollision

import com.bulletphysics.collision.narrowphase.PersistentManifold; //导入方法依赖的package包/类
@Override
public boolean needsCollision(BroadphaseProxy proxy0) {
	// don't collide with itself
	if (proxy0.clientObject == me) {
		return false;
	}

	// don't do CCD when the collision filters are not matching
	if (!super.needsCollision(proxy0)) {
		return false;
	}

	CollisionObject otherObj = (CollisionObject)proxy0.clientObject;

	// call needsResponse, see http://code.google.com/p/bullet/issues/detail?id=179
	if (dispatcher.needsResponse(me, otherObj)) {
		// don't do CCD when there are already contact points (touching contact/penetration)
		ObjectArrayList<PersistentManifold> manifoldArray = new ObjectArrayList<PersistentManifold>();
		BroadphasePair collisionPair = pairCache.findPair(me.getBroadphaseHandle(), proxy0);
		if (collisionPair != null) {
			if (collisionPair.algorithm != null) {
				//manifoldArray.resize(0);
				collisionPair.algorithm.getAllContactManifolds(manifoldArray);
				for (int j=0; j<manifoldArray.size(); j++) {
					PersistentManifold manifold = manifoldArray.getQuick(j);
					if (manifold.getNumContacts() > 0) {
						return false;
					}
				}
			}
		}
	}
	return true;
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:35,代码来源:DiscreteDynamicsWorld.java

示例4: recoverFromPenetration

import com.bulletphysics.collision.narrowphase.PersistentManifold; //导入方法依赖的package包/类
protected boolean recoverFromPenetration (CollisionWorld collisionWorld) {
	boolean penetration = false;
	Stack stack = Stack.enter();

	collisionWorld.getDispatcher().dispatchAllCollisionPairs(ghostObject.getOverlappingPairCache(),
		collisionWorld.getDispatchInfo(), collisionWorld.getDispatcher());

	currentPosition.set(ghostObject.getWorldTransform(stack.allocTransform()).origin);

	float maxPen = 0.0f;
	for (int i = 0; i < ghostObject.getOverlappingPairCache().getNumOverlappingPairs(); i++) {
		manifoldArray.clear();

		BroadphasePair collisionPair = ghostObject.getOverlappingPairCache().getOverlappingPairArray().getQuick(i);

		if (collisionPair.algorithm != null) {
			collisionPair.algorithm.getAllContactManifolds(manifoldArray);
		}

		for (int j = 0; j < manifoldArray.size(); j++) {
			PersistentManifold manifold = manifoldArray.getQuick(j);
			float directionSign = manifold.getBody0() == ghostObject ? -1.0f : 1.0f;
			for (int p = 0; p < manifold.getNumContacts(); p++) {
				ManifoldPoint pt = manifold.getContactPoint(p);

				float dist = pt.getDistance();
				if (dist < 0.0f) {
					if (dist < maxPen) {
						maxPen = dist;
						touchingNormal.set(pt.normalWorldOnB);// ??
						touchingNormal.scl(directionSign);
					}

					currentPosition.x += directionSign * dist * 0.2f * pt.normalWorldOnB.x;
					currentPosition.y += directionSign * dist * 0.2f * pt.normalWorldOnB.y;
					currentPosition.z += directionSign * dist * 0.2f * pt.normalWorldOnB.z;

					penetration = true;
				} else {
					// printf("touching %f\n", dist);
				}
			}

			// manifold->clearManifold();
		}
	}

	Transform newTrans = ghostObject.getWorldTransform(stack.allocTransform());
	newTrans.origin.set(currentPosition);
	ghostObject.setWorldTransform(newTrans);
	// printf("m_touchingNormal = %f,%f,%f\n",m_touchingNormal[0],m_touchingNormal[1],m_touchingNormal[2]);

	// System.out.println("recoverFromPenetration "+penetration+" "+touchingNormal);

	stack.leave();
	return penetration;
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:58,代码来源:KinematicCharacterController.java

示例5: recoverFromPenetration

import com.bulletphysics.collision.narrowphase.PersistentManifold; //导入方法依赖的package包/类
protected boolean recoverFromPenetration(CollisionWorld collisionWorld) {
	boolean penetration = false;

	collisionWorld.getDispatcher().dispatchAllCollisionPairs(
			ghostObject.getOverlappingPairCache(), collisionWorld.getDispatchInfo(), collisionWorld.getDispatcher());

	currentPosition.set(ghostObject.getWorldTransform(Stack.alloc(Transform.class)).origin);

	float maxPen = 0.0f;
	for (int i=0; i<ghostObject.getOverlappingPairCache().getNumOverlappingPairs(); i++) {
		manifoldArray.clear();

		BroadphasePair collisionPair = ghostObject.getOverlappingPairCache().getOverlappingPairArray().getQuick(i);

		if (collisionPair.algorithm != null) {
			collisionPair.algorithm.getAllContactManifolds(manifoldArray);
		}

		for (int j=0; j<manifoldArray.size(); j++) {
			PersistentManifold manifold = manifoldArray.getQuick(j);
			float directionSign = manifold.getBody0() == ghostObject? -1.0f : 1.0f;
			for (int p=0; p<manifold.getNumContacts(); p++) {
				ManifoldPoint pt = manifold.getContactPoint(p);

				float dist = pt.getDistance();
				if (dist < 0.0f) {
					if (dist < maxPen) {
						maxPen = dist;
						touchingNormal.set(pt.normalWorldOnB);//??
						touchingNormal.scale(directionSign);
					}

					currentPosition.scaleAdd(directionSign * dist * 0.2f, pt.normalWorldOnB, currentPosition);

					penetration = true;
				}
				else {
					//printf("touching %f\n", dist);
				}
			}

			//manifold->clearManifold();
		}
	}
	
	Transform newTrans = ghostObject.getWorldTransform(Stack.alloc(Transform.class));
	newTrans.origin.set(currentPosition);
	ghostObject.setWorldTransform(newTrans);
	//printf("m_touchingNormal = %f,%f,%f\n",m_touchingNormal[0],m_touchingNormal[1],m_touchingNormal[2]);

	//System.out.println("recoverFromPenetration "+penetration+" "+touchingNormal);

	return penetration;
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:55,代码来源:KinematicCharacterController.java


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