Adding more bounds overlap tests.

This commit is contained in:
Бранимир Караџић 2019-02-05 23:09:57 -08:00
parent 3118ccfc07
commit cefce11fe4
2 changed files with 49 additions and 2 deletions

View File

@ -1308,6 +1308,40 @@ public:
dde.draw(diskB);
}
{
Triangle triangleA =
{
{ px-0.4f, py+0.0f, pz-0.4f },
{ px+0.0f, py-0.3f, pz-0.5f },
{ px+0.0f, py+0.5f, pz+0.3f },
};
translate(triangleA, {kStepX*5.0f, 0.0f, kStepZ*2.0f});
Obb obbB;
bx::mtxSRT(obbB.mtx
, 1.0f
, 0.25f
, 0.25f
, bx::toRad(10.0f)
, bx::toRad(30.0f)
, bx::toRad(70.0f)
, xx+kStepX*5.0f
, yy
, zz+kStepZ*2.0f
);
olp = overlap(triangleA, obbB);
dde.setColor(olp ? kOverlapA : 0xffffffff);
dde.setWireframe(false);
dde.draw(triangleA);
dde.setColor(olp ? kOverlapB : 0xffffffff);
dde.setWireframe(true);
dde.draw(obbB);
}
// Capsule ---
{
Capsule capsuleA =

View File

@ -1542,7 +1542,20 @@ bool overlap(const Triangle& _triangle, const Disk& _disk)
bool overlap(const Triangle& _triangle, const Obb& _obb)
{
BX_UNUSED(_triangle, _obb);
return false;
Srt srt = toSrt(_obb.mtx);
const Quaternion invRotation = invert(srt.rotation);
const Triangle triangle =
{
mul(sub(_triangle.v0, srt.translation), invRotation),
mul(sub(_triangle.v1, srt.translation), invRotation),
mul(sub(_triangle.v2, srt.translation), invRotation),
};
Aabb aabb;
toAabb(aabb, srt.scale);
return overlap(triangle, aabb);
}