From 7223a0348f53df7e19677f05aaef89852c0f0187 Mon Sep 17 00:00:00 2001 From: Howard Trickey Date: Sat, 26 Jun 2021 17:49:52 -0400 Subject: Fix T89330 Exact Boolean fails on a simple model. The problem was an optimization I put in to triangulate quads. It was wrong if the quad, after projecting onto a 2d plane, was not convex. Handling quads the same as other faces fixes the bug. Unfortunately, this will slow down Exact Boolean when the input has many quads (the usual case, of course). Will attempt to fix that with a later change, but for now, this at least restores correctness. --- source/blender/blenlib/intern/mesh_intersect.cc | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'source/blender/blenlib/intern/mesh_intersect.cc') diff --git a/source/blender/blenlib/intern/mesh_intersect.cc b/source/blender/blenlib/intern/mesh_intersect.cc index 32f0216951a..a9c725d4adf 100644 --- a/source/blender/blenlib/intern/mesh_intersect.cc +++ b/source/blender/blenlib/intern/mesh_intersect.cc @@ -1998,6 +1998,10 @@ static Array polyfill_triangulate_poly(Face *f, IMeshArena *arena) * If this happens, we use the polyfill triangulator instead. We don't * use the polyfill triangulator by default because it can create degenerate * triangles (which we can handle but they'll create non-manifold meshes). + * + * While it is tempting to handle quadrilaterals specially, since that + * is by far the usual case, we need to know if the quad is convex when + * projected before doing so, and that takes a fair amount of computation by itself. */ static Array triangulate_poly(Face *f, IMeshArena *arena) { @@ -2099,20 +2103,6 @@ IMesh triangulate_polymesh(IMesh &imesh, IMeshArena *arena) if (flen == 3) { face_tris.append(f); } - else if (flen == 4) { - const Vert *v0 = (*f)[0]; - const Vert *v1 = (*f)[1]; - const Vert *v2 = (*f)[2]; - const Vert *v3 = (*f)[3]; - int eo_01 = f->edge_orig[0]; - int eo_12 = f->edge_orig[1]; - int eo_23 = f->edge_orig[2]; - int eo_30 = f->edge_orig[3]; - Face *f0 = arena->add_face({v0, v1, v2}, f->orig, {eo_01, eo_12, -1}, {false, false, false}); - Face *f1 = arena->add_face({v0, v2, v3}, f->orig, {-1, eo_23, eo_30}, {false, false, false}); - face_tris.append(f0); - face_tris.append(f1); - } else { Array tris = triangulate_poly(f, arena); for (Face *tri : tris) { -- cgit v1.2.3