From 66919af46a106a50513e73589440a0d200ae0cd1 Mon Sep 17 00:00:00 2001 From: Orange Date: Tue, 11 Nov 2025 23:37:56 +0300 Subject: [PATCH] Refactors GJK algorithm vertex type Simplifies the GJK algorithm by using a type alias for the vertex type, improving code readability and reducing redundancy. Removes unnecessary includes. --- include/omath/collision/gjk_algorithm.hpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/include/omath/collision/gjk_algorithm.hpp b/include/omath/collision/gjk_algorithm.hpp index 886e4d2..c115f23 100644 --- a/include/omath/collision/gjk_algorithm.hpp +++ b/include/omath/collision/gjk_algorithm.hpp @@ -3,8 +3,6 @@ // #pragma once -#include "mesh_collider.hpp" -#include "omath/linear_algebra/vector3.hpp" #include "simplex.hpp" namespace omath::collision @@ -12,11 +10,12 @@ namespace omath::collision template class GjkAlgorithm final { + using VertexType = typename ColliderType::VertexType; + public: [[nodiscard]] - static ColliderType::VertexType find_support_vertex(const ColliderType& collider_a, - const ColliderType& collider_b, - const ColliderType::VertexType& direction) + static VertexType find_support_vertex(const ColliderType& collider_a, const ColliderType& collider_b, + const VertexType& direction) { return collider_a.find_abs_furthest_vertex(direction) - collider_b.find_abs_furthest_vertex(-direction); } @@ -27,7 +26,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 simplex; simplex.push_front(support); auto direction = -support;