Browse Source

Merge pull request #21202 from hpvb/fix-16560

Remove faces in in QuickHull::build() that we don't need anymore
Rémi Verschelde 7 years ago
parent
commit
acf67a1a19
1 changed files with 9 additions and 2 deletions
  1. 9 2
      core/math/quick_hull.cpp

+ 9 - 2
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
 			}