Skip to content

Commit

Permalink
Remove faces in in QuickHull::build() that we don't need anymore
Browse files Browse the repository at this point in the history
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 godotengine#16560 and fixes godotengine#17569
  • Loading branch information
hpvb committed Aug 19, 2018
1 parent 968b31e commit 33669a8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions core/math/quick_hull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand All @@ -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
}
Expand Down

0 comments on commit 33669a8

Please sign in to comment.