本文整理汇总了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();
}
示例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);
}