Refactor: Simplify GJK simplex handling

Removes the separate `Simplex` class and integrates its functionality directly into the `GjkAlgorithm`. This simplifies the code and reduces unnecessary overhead.

Updates tests to align with refactored implementation.
This commit is contained in:
2025-11-09 16:02:13 +03:00
parent 015fc9b1e7
commit afc0720f08
4 changed files with 110 additions and 50 deletions

View File

@@ -9,12 +9,14 @@
namespace omath::collision
{
template<class ColliderType = MeshCollider>
class GjkAlgorithm final
{
public:
[[nodiscard]]
static Vector3<float> find_support_vertex(const MeshCollider& collider_a, const MeshCollider& collider_b,
const Vector3<float>& direction)
static MeshCollider::VertexType find_support_vertex(const ColliderType& collider_a,
const ColliderType& collider_b,
const MeshCollider::VertexType& direction)
{
return collider_a.find_abs_furthest_vertex(direction) - collider_b.find_abs_furthest_vertex(-direction);
}
@@ -25,7 +27,7 @@ namespace omath::collision
// Get initial support point in any direction
auto support = find_support_vertex(collider_a, collider_b, {1, 0, 0});
Simplex simplex;
Simplex<MeshCollider::VertexType> simplex;
simplex.push_front(support);
auto direction = -support;
@@ -44,4 +46,4 @@ namespace omath::collision
}
}
};
}// namespace omath::collision
} // namespace omath::collision