Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updated test
  • Loading branch information
orange-cpp committed Nov 9, 2025
commit cd18b088cb7a9570afb90dcb86afa067142e0de6
2 changes: 1 addition & 1 deletion include/omath/collision/gjk_algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace omath::collision
}

[[nodiscard]]
static bool check_collision(const MeshCollider& collider_a, const MeshCollider& collider_b)
static bool is_collide(const MeshCollider& collider_a, const MeshCollider& collider_b)
{
// Get initial support point in any direction
auto support = find_support_vertex(collider_a, collider_b, {1, 0, 0});
Expand Down
28 changes: 25 additions & 3 deletions tests/general/unit_test_gjk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <gtest/gtest.h>
#include <omath/collision/gjk_algorithm.hpp>

TEST(UnitTestGjk, TestCollision)
TEST(UnitTestGjk, TestCollisionTrue)
{
const std::vector<omath::Vector3<float>> mesh = {
{-1.f, -1.f, -1.f},
Expand All @@ -18,7 +18,29 @@ TEST(UnitTestGjk, TestCollision)
};

const omath::collision::MeshCollider collider_a(mesh, {0.f, 0.f, 0.f});
const omath::collision::MeshCollider collider_b(mesh, {0.f, 3.f, 0.f});
const omath::collision::MeshCollider collider_b(mesh, {0.f, 0.5f, 0.f});

const auto result = omath::collision::GjkAlgorithm::check_collision(collider_a, collider_b);
const auto result = omath::collision::GjkAlgorithm::is_collide(collider_a, collider_b);

EXPECT_TRUE(result);
}
TEST(UnitTestGjk, TestCollisionFalse)
{
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, 4.1f, 0.f});

const auto result = omath::collision::GjkAlgorithm::is_collide(collider_a, collider_b);

EXPECT_FALSE(result);
}