From 7b0e2127dce775d376f5df7cc00a15c0cb5d132b Mon Sep 17 00:00:00 2001 From: Orange Date: Sun, 9 Nov 2025 16:57:52 +0300 Subject: [PATCH] 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. --- tests/general/unit_test_gjk.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/general/unit_test_gjk.cpp b/tests/general/unit_test_gjk.cpp index bd0fdac..8c306cc 100644 --- a/tests/general/unit_test_gjk.cpp +++ b/tests/general/unit_test_gjk.cpp @@ -43,4 +43,25 @@ TEST(UnitTestGjk, TestCollisionFalse) const auto result = omath::collision::GjkAlgorithm<>::is_collide(collider_a, collider_b); EXPECT_FALSE(result); +} + +TEST(UnitTestGjk, TestCollisionEqualOrigin) +{ + const std::vector> 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); } \ No newline at end of file