Hi,
I've been struggling and reading and reading more about OBB-OBB intersection tests using the SAT theory.
Now, suddenly I thought of another solution.
- I can find if a point is inside a OBB (see the function below)
-- besides some basic math it requires 1 vector-matrix multiplication
- what if I take OBB A as a base, and pass the 8 points of OBB B to a the function that checks if a point is inside an OBB
-- if it is, I can quit early and I have intersection
-- if the 8 points are not inside, there's no intersection
For a full SAT test, I understood that I need at least 15 dot products and some more basic math.
The answer what would be quicker, would ofcourse only be answered with facts, by profiling.
But in general, would you think this approach sounds reasonable?
(accepting that I'm not able to pickup the SAT term theory fully and I don't want to copy/paste another solution)
Any input is appreciated.
bool PointInOBB(const OBB &pOBB, const XMFLOAT4X4 &pMatTransform, const XMFLOAT3 &pPoint)
{
XMMATRIX xmTransform = XMLoadFloat4x4(&pMatTransform);
XMMATRIX xmInverse = XMMatrixInverse(NULL, xmTransform);
XMVECTOR point = XMLoadFloat3(&pPoint);
XMFLOAT3 transformedPoint;
XMVECTOR tempTransformed = XMVector3TransformCoord(point, xmInverse);
XMStoreFloat3(&transformedPoint, tempTransformed);
if( fabs(transformedPoint.x) < pOBB.Extents.x * 0.5f &&
fabs(transformedPoint.y) < pOBB.Extents.y * 0.5f &&
fabs(transformedPoint.z) < pOBB.Extents.z * 0.5f) return true;
return false;
}