Vector3f boxMaxLocal = Stack.alloc(Vector3f.class);
castShape.getAabb(rotationXform, boxMinLocal, boxMaxLocal);
triangleMesh.performConvexcast(tccb, convexFromLocal, convexToLocal, boxMinLocal, boxMaxLocal);
}
else {
ConcaveShape triangleMesh = (ConcaveShape)collisionShape;
Transform worldTocollisionObject = Stack.alloc(Transform.class);
worldTocollisionObject.inverse(colObjWorldTransform);
Vector3f convexFromLocal = Stack.alloc(Vector3f.class);
convexFromLocal.set(convexFromTrans.origin);
worldTocollisionObject.transform(convexFromLocal);
Vector3f convexToLocal = Stack.alloc(Vector3f.class);
convexToLocal.set(convexToTrans.origin);
worldTocollisionObject.transform(convexToLocal);
// rotation of box in local mesh space = MeshRotation^-1 * ConvexToRotation
Transform rotationXform = Stack.alloc(Transform.class);
Matrix3f tmpMat = Stack.alloc(Matrix3f.class);
tmpMat.mul(worldTocollisionObject.basis, convexToTrans.basis);
rotationXform.set(tmpMat);
BridgeTriangleConvexcastCallback tccb = new BridgeTriangleConvexcastCallback(castShape, convexFromTrans, convexToTrans, resultCallback, collisionObject, triangleMesh, colObjWorldTransform);
tccb.hitFraction = resultCallback.closestHitFraction;
tccb.normalInWorldSpace = false;
Vector3f boxMinLocal = Stack.alloc(Vector3f.class);
Vector3f boxMaxLocal = Stack.alloc(Vector3f.class);
castShape.getAabb(rotationXform, boxMinLocal, boxMaxLocal);
Vector3f rayAabbMinLocal = Stack.alloc(convexFromLocal);
VectorUtil.setMin(rayAabbMinLocal, convexToLocal);
Vector3f rayAabbMaxLocal = Stack.alloc(convexFromLocal);
VectorUtil.setMax(rayAabbMaxLocal, convexToLocal);
rayAabbMinLocal.add(boxMinLocal);
rayAabbMaxLocal.add(boxMaxLocal);
triangleMesh.processAllTriangles(tccb, rayAabbMinLocal, rayAabbMaxLocal);
}
}
else {
// todo: use AABB tree or other BVH acceleration structure!
if (collisionShape.isCompound()) {