summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHein-Pieter van Braam <hp@tmm.cx>2018-08-20 00:22:47 +0200
committerHein-Pieter van Braam <hp@tmm.cx>2018-08-20 00:22:47 +0200
commit33669a8bcacf108e8fbf1bb64cf94b38381634e6 (patch)
treeda5f76c06eec0d67ed4508ab612d474dc4e10990
parent968b31e971da8040d939a38dcdfbc3445100daa8 (diff)
Remove faces in in QuickHull::build() that we don't need anymore
We delete the faces for consideration in this loop but we can still sometimes find an edge that connects to this face. We now interate over all edges and disconnect edges connecting to this face. This fixes #16560 and fixes #17569
-rw-r--r--core/math/quick_hull.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp
index cb923d264e..45c106102e 100644
--- a/core/math/quick_hull.cpp
+++ b/core/math/quick_hull.cpp
@@ -397,7 +397,6 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
Map<Edge, RetFaceConnect>::Element *F = ret_edges.find(e);
ERR_CONTINUE(!F);
-
List<Geometry::MeshData::Face>::Element *O = F->get().left == E ? F->get().right : F->get().left;
ERR_CONTINUE(O == E);
ERR_CONTINUE(O == NULL);
@@ -426,7 +425,6 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
Edge e2(idx, idxn);
Map<Edge, RetFaceConnect>::Element *F2 = ret_edges.find(e2);
-
ERR_CONTINUE(!F2);
//change faceconnect, point to this face instead
if (F2->get().left == O)
@@ -439,6 +437,15 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
}
}
+ // remove all edge connections to this face
+ for (Map<Edge, RetFaceConnect>::Element *E = ret_edges.front(); E; E = E->next()) {
+ if (E->get().left == O)
+ E->get().left = NULL;
+
+ if (E->get().right == O)
+ E->get().right = NULL;
+ }
+
ret_edges.erase(F); //remove the edge
ret_faces.erase(O); //remove the face
}