removed nesting

This commit is contained in:
2025-12-14 11:08:06 +03:00
parent e10cbf9356
commit 90c4ea2036

View File

@@ -115,21 +115,19 @@ namespace omath::collision
out.iterations = it + 1; out.iterations = it + 1;
} }
// Fallback: pick closest face as best-effort answer if (faces.empty())
if (!faces.empty()) return std::nullopt;
{
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<int>(vertexes.size());
out.num_faces = static_cast<int>(faces.size());
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<int>(vertexes.size());
out.num_faces = static_cast<int>(faces.size());
return out; out.penetration_vector = out.normal * out.depth;
}
return std::nullopt; return out;
} }
private: private: