From 90c4ea20364fce12688bba71f6a1903a92a2d544 Mon Sep 17 00:00:00 2001 From: Orange Date: Sun, 14 Dec 2025 11:08:06 +0300 Subject: [PATCH] removed nesting --- include/omath/collision/epa_algorithm.hpp | 24 +++++++++++------------ 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/include/omath/collision/epa_algorithm.hpp b/include/omath/collision/epa_algorithm.hpp index 0496b87..cd5ed36 100644 --- a/include/omath/collision/epa_algorithm.hpp +++ b/include/omath/collision/epa_algorithm.hpp @@ -115,21 +115,19 @@ namespace omath::collision out.iterations = it + 1; } - // Fallback: pick closest face as best-effort answer - if (!faces.empty()) - { - const auto best = *std::ranges::min_element(faces, [](const auto& first, const auto& second) - { return first.d < second.d; }); - out.normal = best.n; - out.depth = best.d; - out.num_vertices = static_cast(vertexes.size()); - out.num_faces = static_cast(faces.size()); + if (faces.empty()) + return std::nullopt; - out.penetration_vector = out.normal * out.depth; + const auto best = *std::ranges::min_element(faces, [](const auto& first, const auto& second) + { return first.d < second.d; }); + out.normal = best.n; + out.depth = best.d; + out.num_vertices = static_cast(vertexes.size()); + out.num_faces = static_cast(faces.size()); - return out; - } - return std::nullopt; + out.penetration_vector = out.normal * out.depth; + + return out; } private: