Skip to content

Commit 90c4ea2

Browse files
committed
removed nesting
1 parent e10cbf9 commit 90c4ea2

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

include/omath/collision/epa_algorithm.hpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,21 +115,19 @@ namespace omath::collision
115115
out.iterations = it + 1;
116116
}
117117

118-
// Fallback: pick closest face as best-effort answer
119-
if (!faces.empty())
120-
{
121-
const auto best = *std::ranges::min_element(faces, [](const auto& first, const auto& second)
122-
{ return first.d < second.d; });
123-
out.normal = best.n;
124-
out.depth = best.d;
125-
out.num_vertices = static_cast<int>(vertexes.size());
126-
out.num_faces = static_cast<int>(faces.size());
118+
if (faces.empty())
119+
return std::nullopt;
127120

128-
out.penetration_vector = out.normal * out.depth;
121+
const auto best = *std::ranges::min_element(faces, [](const auto& first, const auto& second)
122+
{ return first.d < second.d; });
123+
out.normal = best.n;
124+
out.depth = best.d;
125+
out.num_vertices = static_cast<int>(vertexes.size());
126+
out.num_faces = static_cast<int>(faces.size());
129127

130-
return out;
131-
}
132-
return std::nullopt;
128+
out.penetration_vector = out.normal * out.depth;
129+
130+
return out;
133131
}
134132

135133
private:

0 commit comments

Comments
 (0)