int numpoints = manifoldPtr.getNumContacts();
BulletStats.gTotalContactPoints += numpoints;
Vector3f tmpVec = Stack.alloc(Vector3f.class);
Matrix3f tmpMat3 = Stack.alloc(Matrix3f.class);
Vector3f pos1 = Stack.alloc(Vector3f.class);
Vector3f pos2 = Stack.alloc(Vector3f.class);
Vector3f rel_pos1 = Stack.alloc(Vector3f.class);
Vector3f rel_pos2 = Stack.alloc(Vector3f.class);
Vector3f vel1 = Stack.alloc(Vector3f.class);
Vector3f vel2 = Stack.alloc(Vector3f.class);
Vector3f vel = Stack.alloc(Vector3f.class);
Vector3f totalImpulse = Stack.alloc(Vector3f.class);
Vector3f torqueAxis0 = Stack.alloc(Vector3f.class);
Vector3f torqueAxis1 = Stack.alloc(Vector3f.class);
Vector3f ftorqueAxis0 = Stack.alloc(Vector3f.class);
Vector3f ftorqueAxis1 = Stack.alloc(Vector3f.class);
for (int i = 0; i < numpoints; i++) {
ManifoldPoint cp = manifoldPtr.getContactPoint(i);
if (cp.getDistance() <= 0f) {
cp.getPositionWorldOnA(pos1);
cp.getPositionWorldOnB(pos2);
rel_pos1.sub(pos1, body0.getCenterOfMassPosition(tmpVec));
rel_pos2.sub(pos2, body1.getCenterOfMassPosition(tmpVec));
// this jacobian entry is re-used for all iterations
Matrix3f mat1 = body0.getCenterOfMassTransform(Stack.alloc(Transform.class)).basis;
mat1.transpose();
Matrix3f mat2 = body1.getCenterOfMassTransform(Stack.alloc(Transform.class)).basis;
mat2.transpose();
JacobianEntry jac = jacobiansPool.get();
jac.init(mat1, mat2,
rel_pos1, rel_pos2, cp.normalWorldOnB,
body0.getInvInertiaDiagLocal(Stack.alloc(Vector3f.class)), body0.getInvMass(),