Adds GJK collision test with equal origins

Implements a new test case for the GJK algorithm
to verify collision detection when colliders share the same origin.
This enhances the robustness of collision detection in scenarios
where objects are positioned at the same location.
This commit is contained in:
2025-11-09 16:57:52 +03:00
parent 0b663b73d5
commit 7b0e2127dc

View File

@@ -43,4 +43,25 @@ TEST(UnitTestGjk, TestCollisionFalse)
const auto result = omath::collision::GjkAlgorithm<>::is_collide(collider_a, collider_b); const auto result = omath::collision::GjkAlgorithm<>::is_collide(collider_a, collider_b);
EXPECT_FALSE(result); EXPECT_FALSE(result);
}
TEST(UnitTestGjk, TestCollisionEqualOrigin)
{
const std::vector<omath::Vector3<float>> mesh = {
{-1.f, -1.f, -1.f},
{-1.f, -1.f, 1.f},
{-1.f, 1.f, -1.f},
{-1.f, 1.f, 1.f},
{ 1.f, 1.f, 1.f}, // x = +1 vertices (put {1,1,1} first in case your support breaks ties by first-hit)
{ 1.f, 1.f, -1.f},
{ 1.f, -1.f, 1.f},
{ 1.f, -1.f, -1.f}
};
const omath::collision::MeshCollider collider_a(mesh, {0.f, 0.f, 0.f});
const omath::collision::MeshCollider collider_b(mesh, {0.f, 0.f, 0.f});
const auto result = omath::collision::GjkAlgorithm<>::is_collide(collider_a, collider_b);
EXPECT_TRUE(result);
} }