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


Java ManifoldPoint.init方法代码示例

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


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

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

示例2: addContactPoint

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

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

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

	Vector3f pointA = Stack.alloc(Vector3f.class);
	pointA.scaleAdd(depth, normalOnBInWorld, pointInWorld);

	Vector3f localA = Stack.alloc(Vector3f.class);
	Vector3f localB = Stack.alloc(Vector3f.class);

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


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