From 1ba15f1f7f94616d52e8bbd80e22c9e34e45a81e Mon Sep 17 00:00:00 2001 From: Howard Trickey Date: Sun, 7 Mar 2021 18:13:19 -0500 Subject: Speedup for usual non-manifold exact boolean case. The commit rB6f63417b500d that made exact boolean work on meshes with holes (like Suzanne) unfortunately dramatically slowed things down on other non-manifold meshes that don't have holes and didn't need the per-triangle insideness test. This adds a hole_tolerant parameter, false by default, that the user can enable to get good results on non-manifold meshes with holes. Using false for this parameter speeds up the time from 90 seconds to 10 seconds on an example with 1.2M triangles. --- source/blender/bmesh/tools/bmesh_boolean.cc | 9 ++++++++- source/blender/bmesh/tools/bmesh_boolean.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'source/blender/bmesh') diff --git a/source/blender/bmesh/tools/bmesh_boolean.cc b/source/blender/bmesh/tools/bmesh_boolean.cc index ea5d66e195c..fec33a04e6f 100644 --- a/source/blender/bmesh/tools/bmesh_boolean.cc +++ b/source/blender/bmesh/tools/bmesh_boolean.cc @@ -354,6 +354,7 @@ static bool bmesh_boolean(BMesh *bm, const bool use_self, const bool use_separate_all, const bool keep_hidden, + const bool hole_tolerant, const BoolOpType boolean_mode) { IMeshArena arena; @@ -389,7 +390,7 @@ static bool bmesh_boolean(BMesh *bm, }; } IMesh m_out = boolean_mesh( - m_in, boolean_mode, nshapes, shape_fn, use_self, &m_triangulated, &arena); + m_in, boolean_mode, nshapes, shape_fn, use_self, hole_tolerant, &m_triangulated, &arena); # ifdef PERF_DEBUG double boolean_time = PIL_check_seconds_timer(); std::cout << "boolean done, time = " << boolean_time - mesh_time << "\n"; @@ -437,6 +438,7 @@ bool BM_mesh_boolean(BMesh *bm, const int nshapes, const bool use_self, const bool keep_hidden, + const bool hole_tolerant, const int boolean_mode) { return blender::meshintersect::bmesh_boolean( @@ -449,6 +451,7 @@ bool BM_mesh_boolean(BMesh *bm, use_self, false, keep_hidden, + hole_tolerant, static_cast(boolean_mode)); } @@ -468,6 +471,7 @@ bool BM_mesh_boolean_knife(BMesh *bm, const int nshapes, const bool use_self, const bool use_separate_all, + const bool hole_tolerant, const bool keep_hidden) { return blender::meshintersect::bmesh_boolean(bm, @@ -479,6 +483,7 @@ bool BM_mesh_boolean_knife(BMesh *bm, use_self, use_separate_all, keep_hidden, + hole_tolerant, blender::meshintersect::BoolOpType::None); } #else @@ -490,6 +495,7 @@ bool BM_mesh_boolean(BMesh *UNUSED(bm), const int UNUSED(nshapes), const bool UNUSED(use_self), const bool UNUSED(keep_hidden), + const bool UNUSED(hole_tolerant), const int UNUSED(boolean_mode)) { UNUSED_VARS(looptris, test_fn); @@ -512,6 +518,7 @@ bool BM_mesh_boolean_knife(BMesh *UNUSED(bm), const int UNUSED(nshapes), const bool UNUSED(use_self), const bool UNUSED(use_separate_all), + const bool UNUSED(hole_tolerant), const bool UNUSED(keep_hidden)) { UNUSED_VARS(looptris, test_fn); diff --git a/source/blender/bmesh/tools/bmesh_boolean.h b/source/blender/bmesh/tools/bmesh_boolean.h index 2cc32e143fc..ed77242e14c 100644 --- a/source/blender/bmesh/tools/bmesh_boolean.h +++ b/source/blender/bmesh/tools/bmesh_boolean.h @@ -32,6 +32,7 @@ bool BM_mesh_boolean(BMesh *bm, const int nshapes, const bool use_self, const bool keep_hidden, + const bool hole_tolerant, const int boolean_mode); bool BM_mesh_boolean_knife(BMesh *bm, @@ -42,6 +43,7 @@ bool BM_mesh_boolean_knife(BMesh *bm, const int nshapes, const bool use_self, const bool use_separate_all, + const bool hole_tolerant, const bool keep_hidden); #ifdef __cplusplus -- cgit v1.2.3