Original Post
So I found this thread, which I've implemented, but no dice. Does anybody have any idea as to why it isn't working? Here's my code: To note, I've also tried the ray version posted on that thread I linked to(a sort of swept SAT I believe?) to no avail.
bool LineToAABB(const ceLineSeg& line, const bvAABB &aabb)
{
// center box at origin
D3DXVECTOR3 vSegDir = (line.vEndPt - line.vStartPt) * 0.5f; // segment half width vector
D3DXVECTOR3 vBoxExtents = (aabb.vMax - aabb.vMin) * 0.5f; // aabb half width vector
D3DXVECTOR3 vCentered = line.vStartPt + vSegDir - (aabb.vMin + aabb.vMax) * 0.5f; // put at origin
D3DXVECTOR3 absDir = vSegDir; // no negatives
absDir.x = fabs(absDir.x);
absDir.y = fabs(absDir.y);
absDir.z = fabs(absDir.z);
if (fabs(vCentered.x) > vBoxExtents.x + absDir.x ||
fabs(vCentered.z) > vBoxExtents.z + absDir.z ||
fabs(vCentered.y) > vBoxExtents.y + absDir.y)
return false;
#define FLOAT_EPSILON 0.0000001
if (fabs(vSegDir.y * vCentered.z - vSegDir.z * vCentered.y) >
vBoxExtents.y * absDir.z + vBoxExtents.z * absDir.y + FLOAT_EPSILON)
return false;
if (fabs(vSegDir.z * vCentered.x - vSegDir.x * vCentered.z) >
vBoxExtents.z * absDir.x + vBoxExtents.x * absDir.z + FLOAT_EPSILON)
return false;
if (fabs(vSegDir.x * vCentered.y - vSegDir.y * vCentered.x) >
vBoxExtents.x * absDir.y + vBoxExtents.y * absDir.x + FLOAT_EPSILON)
return false;
return true;