Adding more bounds overlap tests.

This commit is contained in:
Бранимир Караџић 2019-02-05 19:42:48 -08:00
parent d0146fdfbb
commit f19491c274
2 changed files with 49 additions and 4 deletions

View File

@ -1165,6 +1165,50 @@ public:
dde.draw(diskB); dde.draw(diskB);
} }
{
Aabb aabbA;
toAabb(aabbA, { px+kStepX*6.0f, py, pz+kStepZ*1.0f }, { 0.5f, 0.5f, 0.5f });
Capsule capsuleB =
{
{ xx+kStepX*5.9f, yy-1.0f, zz+kStepZ*1.0f+0.1f },
{ xx+kStepX*6.0f, yy+1.0f, zz+kStepZ*1.0f },
0.2f,
};
olp = overlap(aabbA, capsuleB);
dde.setColor(olp ? kOverlapA : 0xffffffff);
dde.setWireframe(false);
dde.draw(aabbA);
dde.setColor(olp ? kOverlapB : 0xffffffff);
dde.setWireframe(true);
dde.draw(capsuleB);
}
{
Aabb aabbA;
toAabb(aabbA, { px+kStepX*8.0f, py, pz+kStepZ*1.0f }, { 0.5f, 0.5f, 0.5f });
Cone coneB =
{
{ xx+kStepX*7.9f, yy-1.0f, zz+kStepZ*1.0f+0.1f },
{ xx+kStepX*8.0f, yy+1.0f, zz+kStepZ*1.0f },
0.25f,
};
olp = overlap(aabbA, coneB);
dde.setColor(olp ? kOverlapA : 0xffffffff);
dde.setWireframe(false);
dde.draw(aabbA);
dde.setColor(olp ? kOverlapB : 0xffffffff);
dde.setWireframe(true);
dde.draw(coneB);
}
// Triangle --- // Triangle ---
{ {
Triangle triangleA = Triangle triangleA =

View File

@ -1259,14 +1259,15 @@ bool overlap(const Aabb& _aabb, const Cylinder& _cylinder)
bool overlap(const Aabb& _aabb, const Capsule& _capsule) bool overlap(const Aabb& _aabb, const Capsule& _capsule)
{ {
BX_UNUSED(_aabb, _capsule); const Vec3 pos = closestPoint(LineSegment{_capsule.pos, _capsule.end}, getCenter(_aabb) );
return false; return overlap(_aabb, Sphere{pos, _capsule.radius});
} }
bool overlap(const Aabb& _aabb, const Cone& _cone) bool overlap(const Aabb& _aabb, const Cone& _cone)
{ {
BX_UNUSED(_aabb, _cone); float tt;
return false; const Vec3 pos = closestPoint(LineSegment{_cone.pos, _cone.end}, getCenter(_aabb), tt);
return overlap(_aabb, Sphere{pos, lerp(_cone.radius, 0.0f, tt)});
} }
bool overlap(const Aabb& _aabb, const Disk& _disk) bool overlap(const Aabb& _aabb, const Disk& _disk)