本文整理汇总了Java中com.bulletphysics.collision.narrowphase.ManifoldPoint.getDistance方法的典型用法代码示例。如果您正苦于以下问题:Java ManifoldPoint.getDistance方法的具体用法?Java ManifoldPoint.getDistance怎么用?Java ManifoldPoint.getDistance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.bulletphysics.collision.narrowphase.ManifoldPoint
的用法示例。
在下文中一共展示了ManifoldPoint.getDistance方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: solveCombinedContactFriction
import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入方法依赖的package包/类
public float solveCombinedContactFriction (RigidBody body0, RigidBody body1, ManifoldPoint cp, ContactSolverInfo info,
int iter, IDebugDraw debugDrawer) {
float maxImpulse = 0f;
{
if (cp.getDistance() <= 0f) {
{
// btConstraintPersistentData* cpd = (btConstraintPersistentData*) cp.m_userPersistentData;
float impulse = ContactConstraint.resolveSingleCollisionCombined(body0, body1, cp, info);
if (maxImpulse < impulse) {
maxImpulse = impulse;
}
}
}
}
return maxImpulse;
}
示例2: solve
import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入方法依赖的package包/类
protected float solve (RigidBody body0, RigidBody body1, ManifoldPoint cp, ContactSolverInfo info, int iter,
IDebugDraw debugDrawer) {
float maxImpulse = 0f;
{
if (cp.getDistance() <= 0f) {
{
ConstraintPersistentData cpd = (ConstraintPersistentData)cp.userPersistentData;
float impulse = cpd.contactSolverFunc.resolveContact(body0, body1, cp, info);
if (maxImpulse < impulse) {
maxImpulse = impulse;
}
}
}
}
return maxImpulse;
}
示例3: solveCombinedContactFriction
import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入方法依赖的package包/类
public float solveCombinedContactFriction(RigidBody body0, RigidBody body1, ManifoldPoint cp, ContactSolverInfo info, int iter, IDebugDraw debugDrawer) {
float maxImpulse = 0f;
{
if (cp.getDistance() <= 0f) {
{
//btConstraintPersistentData* cpd = (btConstraintPersistentData*) cp.m_userPersistentData;
float impulse = ContactConstraint.resolveSingleCollisionCombined(body0, body1, cp, info);
if (maxImpulse < impulse) {
maxImpulse = impulse;
}
}
}
}
return maxImpulse;
}
示例4: solve
import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入方法依赖的package包/类
protected float solve(RigidBody body0, RigidBody body1, ManifoldPoint cp, ContactSolverInfo info, int iter, IDebugDraw debugDrawer) {
float maxImpulse = 0f;
{
if (cp.getDistance() <= 0f) {
{
ConstraintPersistentData cpd = (ConstraintPersistentData) cp.userPersistentData;
float impulse = cpd.contactSolverFunc.resolveContact(body0, body1, cp, info);
if (maxImpulse < impulse) {
maxImpulse = impulse;
}
}
}
}
return maxImpulse;
}
示例5: update
import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入方法依赖的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);
}
}
}
}
}
示例6: solveFriction
import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入方法依赖的package包/类
protected float solveFriction (RigidBody body0, RigidBody body1, ManifoldPoint cp, ContactSolverInfo info, int iter,
IDebugDraw debugDrawer) {
{
if (cp.getDistance() <= 0f) {
ConstraintPersistentData cpd = (ConstraintPersistentData)cp.userPersistentData;
cpd.frictionSolverFunc.resolveContact(body0, body1, cp, info);
}
}
return 0f;
}
示例7: solveFriction
import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入方法依赖的package包/类
protected float solveFriction(RigidBody body0, RigidBody body1, ManifoldPoint cp, ContactSolverInfo info, int iter, IDebugDraw debugDrawer) {
{
if (cp.getDistance() <= 0f) {
ConstraintPersistentData cpd = (ConstraintPersistentData) cp.userPersistentData;
cpd.frictionSolverFunc.resolveContact(body0, body1, cp, info);
}
}
return 0f;
}
示例8: recoverFromPenetration
import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入方法依赖的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;
}
示例9: recoverFromPenetration
import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入方法依赖的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;
}