• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ManifoldPoint类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ManifoldPoint类属于com.bulletphysics.collision.narrowphase包,在下文中一共展示了ManifoldPoint类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:19,代码来源:SequentialImpulseConstraintSolver.java


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


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


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


示例5: contactProcessed

import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入依赖的package包/类
@Override
public boolean contactProcessed(ManifoldPoint arg0, Object obj1, Object obj2)
{
  CollisionObject o1 = (CollisionObject) obj1;
  CollisionObject o2 = (CollisionObject) obj2;

  for (PhysicsBody body : watchList)
  {
    if (body.body == o1)
    {

      body.collidedWith(o2);
    }
    else if (body.body == o2)
    {

      body.collidedWith(o1);
    }
  }
  return false;
}
 
开发者ID:l50,项目名称:redrun,代码行数:22,代码来源:PhysicsWorld.java


示例6: contactAdded

import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入依赖的package包/类
public boolean contactAdded(ManifoldPoint cp, CollisionObject colObj0, int partId0, int index0, CollisionObject colObj1, int partId1, int index1) {
	float friction0 = colObj0.getFriction();
	float friction1 = colObj1.getFriction();
	float restitution0 = colObj0.getRestitution();
	float restitution1 = colObj1.getRestitution();

	if ((colObj0.getCollisionFlags() & CollisionFlags.CUSTOM_MATERIAL_CALLBACK) != 0) {
		friction0 = 1f; //partId0,index0
		restitution0 = 0f;
	}
	if ((colObj1.getCollisionFlags() & CollisionFlags.CUSTOM_MATERIAL_CALLBACK) != 0) {
		if ((index1 & 1) != 0) {
			friction1 = 1f; //partId1,index1
		}
		else {
			friction1 = 0f;
		}
		restitution1 = 0f;
	}

	cp.combinedFriction = calculateCombinedFriction(friction0, friction1);
	cp.combinedRestitution = calculateCombinedRestitution(restitution0, restitution1);

	// this return value is currently ignored, but to be on the safe side: return false if you don't calculate friction
	return true;
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:27,代码来源:ConcaveDemo.java


示例7: 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);
				}
			}
		}
	}
}
 
开发者ID:Axodoss,项目名称:Wicken,代码行数:18,代码来源:PhysicsSystem.java


示例8: getEvent

import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入依赖的package包/类
public PhysicsCollisionEvent getEvent(int type, PhysicsCollisionObject source, PhysicsCollisionObject nodeB, ManifoldPoint cp) {
    PhysicsCollisionEvent event = eventBuffer.poll();
    if (event == null) {
        event = new PhysicsCollisionEvent(type, source, nodeB, cp);
    }else{
        event.refactor(type, source, nodeB, cp);
    }
    return event;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:10,代码来源:PhysicsCollisionEventFactory.java


示例9: PhysicsCollisionEvent

import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入依赖的package包/类
public PhysicsCollisionEvent(int type, PhysicsCollisionObject source, PhysicsCollisionObject nodeB, ManifoldPoint cp) {
    super(source);
    this.type = type;
    this.nodeA = source;
    this.nodeB = nodeB;
    this.cp = cp;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:PhysicsCollisionEvent.java


示例10: refactor

import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入依赖的package包/类
/**
 * used by event factory, called when event reused
 */
public void refactor(int type, PhysicsCollisionObject source, PhysicsCollisionObject nodeB, ManifoldPoint cp) {
    this.source = source;
    this.type = type;
    this.nodeA = source;
    this.nodeB = nodeB;
    this.cp = cp;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:11,代码来源:PhysicsCollisionEvent.java


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


示例12: resolveSingleFrictionEmpty

import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入依赖的package包/类
public static float resolveSingleFrictionEmpty(
		RigidBody body1,
		RigidBody body2,
		ManifoldPoint contactPoint,
		ContactSolverInfo solverInfo) {
	return 0f;
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:8,代码来源:ContactConstraint.java


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


示例14: onCollision

import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入依赖的package包/类
@Override
public void onCollision(ManifoldPoint mp, GameObject object) {
	// TODO: check if impact material is equal to "material"
	// TODO: check how hard the impact is, should include "mass" in the calculation
	
	final float lowerLimit = 20.0f;
	final float upperLimit = 100.0f;
	
	if (mp.appliedImpulse > lowerLimit) {
	
		int soundId = 0;
		if (mp.appliedImpulse >= upperLimit) {
			soundId = impacts.length - 1;
		} else {
			soundId = (int)(((mp.appliedImpulse - lowerLimit) / (upperLimit - lowerLimit)) * (float)impacts.length);
		}
		
		Sound impactSound = impacts[soundId];
		
		if (!impactSound.isPlaying()) {
			javax.vecmath.Vector3f pos = new javax.vecmath.Vector3f();
			mp.getPositionWorldOnA(pos );
			impactSound.setPosition(new Vector3f(pos.x, pos.y, pos.z));
			impactSound.play();
		}
	}
}
 
开发者ID:Axodoss,项目名称:Wicken,代码行数:28,代码来源:SoundOnImpact.java


示例15: get

import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入依赖的package包/类
@Override
public ManifoldPoint get() {
	return new ManifoldPoint();
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:5,代码来源:ManifoldResult.java


示例16: addContactPoint

import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入依赖的package包/类
public void addContactPoint(Vector3 normalOnBInWorld, Vector3 pointInWorld, float depth) {
	assert (manifoldPtr != null);
	//order in manifold needs to match

	if (depth > manifoldPtr.getContactBreakingThreshold()) {
		return;
	}

	boolean isSwapped = manifoldPtr.getBody0() != body0;

	Stack stack = Stack.enter();
	Vector3 pointA = stack.allocVector3();
	pointA.set(normalOnBInWorld).scl(depth).add(pointInWorld);

	Vector3 localA = stack.allocVector3();
	Vector3 localB = stack.allocVector3();

	if (isSwapped) {
		rootTransB.invXform(pointA, localA);
		rootTransA.invXform(pointInWorld, localB);
	}
	else {
		rootTransA.invXform(pointA, localA);
		rootTransB.invXform(pointInWorld, localB);
	}

	ManifoldPoint newPt = pointsPool.get();
	newPt.init(localA, localB, normalOnBInWorld, depth);

	newPt.positionWorldOnA.set(pointA);
	newPt.positionWorldOnB.set(pointInWorld);

	int insertIndex = manifoldPtr.getCacheEntry(newPt);

	newPt.combinedFriction = calculateCombinedFriction(body0, body1);
	newPt.combinedRestitution = calculateCombinedRestitution(body0, body1);

	// BP mod, store contact triangles.
	newPt.partId0 = partId0;
	newPt.partId1 = partId1;
	newPt.index0 = index0;
	newPt.index1 = index1;

	/// todo, check this for any side effects
	if (insertIndex >= 0) {
		//const btManifoldPoint& oldPoint = m_manifoldPtr->getContactPoint(insertIndex);
		manifoldPtr.replaceContactPoint(newPt, insertIndex);
	}
	else {
		insertIndex = manifoldPtr.addManifoldPoint(newPt);
	}

	// User can override friction and/or restitution
	if (BulletGlobals.getContactAddedCallback() != null &&
			// and if either of the two bodies requires custom material
			((body0.getCollisionFlags() & CollisionFlags.CUSTOM_MATERIAL_CALLBACK) != 0 ||
			(body1.getCollisionFlags() & CollisionFlags.CUSTOM_MATERIAL_CALLBACK) != 0)) {
		//experimental feature info, for per-triangle material etc.
		CollisionObject obj0 = isSwapped ? body1 : body0;
		CollisionObject obj1 = isSwapped ? body0 : body1;
		BulletGlobals.getContactAddedCallback().contactAdded(manifoldPtr.getContactPoint(insertIndex), obj0, partId0, index0, obj1, partId1, index1);
	}

	pointsPool.release(newPt);
	stack.leave();
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:67,代码来源:ManifoldResult.java


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


示例18: resolveContact

import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入依赖的package包/类
public float resolveContact (RigidBody body1, RigidBody body2, ManifoldPoint contactPoint, ContactSolverInfo info) {
	return resolveSingleCollision(body1, body2, contactPoint, info);
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:4,代码来源:ContactConstraint.java


示例19: resolveSingleCollision

import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入依赖的package包/类
/** Response between two dynamic objects with friction. */
public static float resolveSingleCollision (RigidBody body1, RigidBody body2, ManifoldPoint contactPoint,
	ContactSolverInfo solverInfo) {

	Stack stack = Stack.enter();
	Vector3 tmpVec = stack.allocVector3();

	Vector3 pos1_ = contactPoint.getPositionWorldOnA(stack.allocVector3());
	Vector3 pos2_ = contactPoint.getPositionWorldOnB(stack.allocVector3());
	Vector3 normal = contactPoint.normalWorldOnB;

	// constant over all iterations
	Vector3 rel_pos1 = stack.allocVector3();
	rel_pos1.set(pos1_).sub(body1.getCenterOfMassPosition(tmpVec));

	Vector3 rel_pos2 = stack.allocVector3();
	rel_pos2.set(pos2_).sub(body2.getCenterOfMassPosition(tmpVec));

	Vector3 vel1 = body1.getVelocityInLocalPoint(rel_pos1, stack.allocVector3());
	Vector3 vel2 = body2.getVelocityInLocalPoint(rel_pos2, stack.allocVector3());
	Vector3 vel = stack.allocVector3();
	vel.set(vel1).sub(vel2);

	float rel_vel;
	rel_vel = normal.dot(vel);

	float Kfps = 1f / solverInfo.timeStep;

	// btScalar damping = solverInfo.m_damping ;
	float Kerp = solverInfo.erp;
	float Kcor = Kerp * Kfps;

	ConstraintPersistentData cpd = (ConstraintPersistentData)contactPoint.userPersistentData;
	assert (cpd != null);
	float distance = cpd.penetration;
	float positionalError = Kcor * -distance;
	float velocityError = cpd.restitution - rel_vel; // * damping;

	float penetrationImpulse = positionalError * cpd.jacDiagABInv;

	float velocityImpulse = velocityError * cpd.jacDiagABInv;

	float normalImpulse = penetrationImpulse + velocityImpulse;

	// See Erin Catto's GDC 2006 paper: Clamp the accumulated impulse
	float oldNormalImpulse = cpd.appliedImpulse;
	float sum = oldNormalImpulse + normalImpulse;
	cpd.appliedImpulse = 0f > sum ? 0f : sum;

	normalImpulse = cpd.appliedImpulse - oldNormalImpulse;

	// #ifdef USE_INTERNAL_APPLY_IMPULSE
	Vector3 tmp = stack.allocVector3();
	if (body1.getInvMass() != 0f) {
		tmp.set(contactPoint.normalWorldOnB).scl(body1.getInvMass());
		body1.internalApplyImpulse(tmp, cpd.angularComponentA, normalImpulse);
	}
	if (body2.getInvMass() != 0f) {
		tmp.set(contactPoint.normalWorldOnB).scl(body2.getInvMass());
		body2.internalApplyImpulse(tmp, cpd.angularComponentB, -normalImpulse);
	}
	// #else //USE_INTERNAL_APPLY_IMPULSE
	// body1.applyImpulse(normal*(normalImpulse), rel_pos1);
	// body2.applyImpulse(-normal*(normalImpulse), rel_pos2);
	// #endif //USE_INTERNAL_APPLY_IMPULSE

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


示例20: resolveSingleFrictionEmpty

import com.bulletphysics.collision.narrowphase.ManifoldPoint; //导入依赖的package包/类
public static float resolveSingleFrictionEmpty (RigidBody body1, RigidBody body2, ManifoldPoint contactPoint,
	ContactSolverInfo solverInfo) {
	return 0f;
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:5,代码来源:ContactConstraint.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GroupManager类代码示例发布时间:2022-05-22
下一篇:
Java UPlayer类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap