Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHoward Trickey <howard.trickey@gmail.com>2021-06-27 00:49:52 +0300
committerHoward Trickey <howard.trickey@gmail.com>2021-06-27 00:49:52 +0300
commit7223a0348f53df7e19677f05aaef89852c0f0187 (patch)
tree907a2d1ebe02411d269964779760b6ab2d6a9a6c /source/blender/blenlib/tests
parentabc62003314af2b39136bf43031590d4fbfb72df (diff)
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.
Diffstat (limited to 'source/blender/blenlib/tests')
-rw-r--r--source/blender/blenlib/tests/BLI_mesh_intersect_test.cc70
1 files changed, 70 insertions, 0 deletions
diff --git a/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc b/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc
index ec57cf29cad..1a9ffbd3403 100644
--- a/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc
+++ b/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc
@@ -174,6 +174,76 @@ TEST(mesh_intersect, Mesh)
EXPECT_TRUE(f->is_tri());
}
+TEST(mesh_intersect, TriangulateTri)
+{
+ const char *spec = R"(3 1
+ 0 0 0
+ 1 0 0
+ 1/2 1 0
+ 0 1 2
+ )";
+
+ IMeshBuilder mb(spec);
+ IMesh im_tri = triangulate_polymesh(mb.imesh, &mb.arena);
+ EXPECT_EQ(im_tri.faces().size(), 1);
+}
+
+TEST(mesh_intersect, TriangulateQuad)
+{
+ const char *spec = R"(4 1
+ 0 0 0
+ 1 0 0
+ 1 1 0
+ 0 1 0
+ 0 1 2 3
+ )";
+
+ IMeshBuilder mb(spec);
+ IMesh im_tri = triangulate_polymesh(mb.imesh, &mb.arena);
+ EXPECT_EQ(im_tri.faces().size(), 2);
+}
+
+TEST(mesh_intersect, TriangulatePentagon)
+{
+ const char *spec = R"(5 1
+ 0 0 0
+ 1 0 0
+ 1 1 0
+ 1/2 2 0
+ 0 1 0
+ 0 1 2 3 4
+ )";
+
+ IMeshBuilder mb(spec);
+ IMesh im_tri = triangulate_polymesh(mb.imesh, &mb.arena);
+ EXPECT_EQ(im_tri.faces().size(), 3);
+ if (DO_OBJ) {
+ write_obj_mesh(im_tri, "pentagon");
+ }
+}
+
+TEST(mesh_intersect, TriangulateTwoFaces)
+{
+ const char *spec = R"(7 2
+ 461/250 -343/125 103/1000
+ -3/40 -453/200 -97/500
+ 237/100 -321/200 -727/500
+ 451/1000 -563/500 -1751/1000
+ 12/125 -2297/1000 -181/1000
+ 12/125 -411/200 -493/1000
+ 1959/1000 -2297/1000 -493/1000
+ 1 3 2 0 6 5 4
+ 6 0 1 4
+ )";
+
+ IMeshBuilder mb(spec);
+ IMesh im_tri = triangulate_polymesh(mb.imesh, &mb.arena);
+ EXPECT_EQ(im_tri.faces().size(), 7);
+ if (DO_OBJ) {
+ write_obj_mesh(im_tri, "twofaces");
+ }
+}
+
TEST(mesh_intersect, OneTri)
{
const char *spec = R"(3 1