summaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-03-14 00:38:30 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-03-14 00:38:30 +0000
commit9c7286466a1da04f45f633af9086e543d99c7df5 (patch)
treeaf6db3d21ce79b855c421744a7f6cfc5bb817b36 /game
parentAdd deformation test case with lower spec (diff)
downloadilt-9c7286466a1da04f45f633af9086e543d99c7df5.tar.bz2
ilt-9c7286466a1da04f45f633af9086e543d99c7df5.tar.xz
ilt-9c7286466a1da04f45f633af9086e543d99c7df5.zip
Simplify cut loop and termination case search
Looks for a halfedge from current vertex to end vertex.
Diffstat (limited to 'game')
-rw-r--r--game/geoData.cpp66
1 files changed, 30 insertions, 36 deletions
diff --git a/game/geoData.cpp b/game/geoData.cpp
index ac2f035..c48881f 100644
--- a/game/geoData.cpp
+++ b/game/geoData.cpp
@@ -492,43 +492,37 @@ GeoData::setHeights(const std::span<const GlobalPosition3D> triangleStrip)
out.emplace_back(first.boundaryVertex);
out.emplace_back(first.extrusionVertex);
for (auto currentVertex = first.extrusionVertex;
- std::none_of(voh_begin(currentVertex), voh_end(currentVertex),
- [&](const auto currentVertexOut) {
- // The next half edge goes to the termination point
- const auto next = next_halfedge_handle(currentVertexOut);
- const auto nextVertex = to_vertex_handle(next);
- return (nextVertex == second.extrusionVertex);
- })
- && std::any_of(
- voh_begin(currentVertex), voh_end(currentVertex), [&](const auto currentVertexOut) {
- const auto next = next_halfedge_handle(currentVertexOut);
- const auto nextVertex = to_vertex_handle(next);
- const auto startVertex = from_vertex_handle(next);
- if (nextVertex == *++out.rbegin()) {
- // This half edge goes back to the previous vertex
- return false;
+ !find_halfedge(currentVertex, second.extrusionVertex).is_valid();) {
+ auto n = std::any_of(
+ voh_begin(currentVertex), voh_end(currentVertex), [&](const auto currentVertexOut) {
+ const auto next = next_halfedge_handle(currentVertexOut);
+ const auto nextVertex = to_vertex_handle(next);
+ const auto startVertex = from_vertex_handle(next);
+ if (nextVertex == *++out.rbegin()) {
+ // This half edge goes back to the previous vertex
+ return false;
+ }
+ const auto edge = edge_handle(next);
+ const auto ep0 = point(startVertex);
+ const auto ep1 = point(nextVertex);
+ const auto diff = RelativePosition3D(ep1 - ep0);
+ const auto length = glm::length(diff);
+ const auto dir = diff / length;
+ const Ray r {ep0, dir};
+ return std::any_of(triangles.begin(), triangles.end(), [&](const auto & triangle) {
+ BaryPosition bary;
+ RelativeDistance dist {};
+
+ if (r.intersectTriangle(triangle.x, triangle.y, triangle.z, bary, dist)
+ && dist <= length - 1 && dist >= 1) {
+ const auto splitPos = triangle * bary;
+ currentVertex = out.emplace_back(split(edge, splitPos));
+ return true;
}
- const auto edge = edge_handle(next);
- const auto ep0 = point(startVertex);
- const auto ep1 = point(nextVertex);
- const auto diff = RelativePosition3D(ep1 - ep0);
- const auto length = glm::length(diff);
- const auto dir = diff / length;
- const Ray r {ep0, dir};
- return std::any_of(triangles.begin(), triangles.end(), [&](const auto & triangle) {
- BaryPosition bary;
- RelativeDistance dist {};
-
- if (r.intersectTriangle(triangle.x, triangle.y, triangle.z, bary, dist)
- && dist <= length - 1 && dist >= 1) {
- const auto splitPos = triangle * bary;
- currentVertex = out.emplace_back(split(edge, splitPos));
- return true;
- }
- return false;
- });
- });) {
- ;
+ return false;
+ });
+ });
+ assert(n);
}
out.emplace_back(second.extrusionVertex);
if (first.boundaryVertex != second.boundaryVertex) {