This problem can be solved by rotating one of the OBBs into the other's coordinate frame. Then the intersection test becomes an AABB to OBB test which can be solved using the separating axis theorem.
To rotate the second OBB into the first OBB's coordinate frame, use the following code:
/// <summary>Test whether two oriented boxes intersect with each other</summary>
/// <param name="firstBox">First box to test</param>
/// <param name="secondBox">Second box to test</param>
/// <returns>True if the oriented boxes are overlapping</returns>
public static bool StaticTest(
Vector3 firstBoxExtents, Matrix33 firstBoxOrientation,
Vector3 secondBoxCenter, Vector3 secondBoxExtents, Matrix33 secondBoxOrientation
) {
// We rotate the second box into the local coordinate frame of the first box so
// this check becomes an AABB to OBB test
// We transform the second box position to the coordinate frame of the first box
Vector3 local = new Vector3(
Vector3.DotProduct(secondBoxCenter, firstBoxOrientation.Right),
Vector3.DotProduct(secondBoxCenter, firstBoxOrientation.Up),
Vector3.DotProduct(secondBoxCenter, firstBoxOrientation.Into)
);
// Next, we rotate the orientation matrix of the second box to obtain the relative
// orientation in the coordinate frame of the first box
Matrix33 relativeOrientation = Matrix33.Zero;
for(int row = 0; row < 3; ++row) {
for(int col = 0; col < 3; ++col) {
relativeOrientation[row, col] =
Vector3.DotProduct(secondBoxOrientation[row], firstBoxOrientation[col]);
}
}
// Now we can do an easier axis aligned box to oriented box intersection check
return Interference.AabbObbInterference.StaticTest(
firstBoxExtents, secondBoxExtents, local, relativeOrientation
);
}
/// <param name="firstBox">First box to test</param>
/// <param name="secondBox">Second box to test</param>
/// <returns>True if the oriented boxes are overlapping</returns>
public static bool StaticTest(
Vector3 firstBoxExtents, Matrix33 firstBoxOrientation,
Vector3 secondBoxCenter, Vector3 secondBoxExtents, Matrix33 secondBoxOrientation
) {
// We rotate the second box into the local coordinate frame of the first box so
// this check becomes an AABB to OBB test
// We transform the second box position to the coordinate frame of the first box
Vector3 local = new Vector3(
Vector3.DotProduct(secondBoxCenter, firstBoxOrientation.Right),
Vector3.DotProduct(secondBoxCenter, firstBoxOrientation.Up),
Vector3.DotProduct(secondBoxCenter, firstBoxOrientation.Into)
);
// Next, we rotate the orientation matrix of the second box to obtain the relative
// orientation in the coordinate frame of the first box
Matrix33 relativeOrientation = Matrix33.Zero;
for(int row = 0; row < 3; ++row) {
for(int col = 0; col < 3; ++col) {
relativeOrientation[row, col] =
Vector3.DotProduct(secondBoxOrientation[row], firstBoxOrientation[col]);
}
}
// Now we can do an easier axis aligned box to oriented box intersection check
return Interference.AabbObbInterference.StaticTest(
firstBoxExtents, secondBoxExtents, local, relativeOrientation
);
}
See
Static Intersection Test Between AABB and OBB
for the contents of the AabbObbInterference.StaticTest function used
to do the final intersection test in this method after the OBB has become an AABB.