[Bf-blender-cvs] [77c83d3be11] newboolean: Fixed the regression after making binary ops not do self-intersection.
Howard Trickey
noreply at git.blender.org
Mon Jul 20 18:00:06 CEST 2020
Commit: 77c83d3be11484649b7bc4cbb9b49c90fdb7882d
Author: Howard Trickey
Date: Mon Jul 20 11:58:37 2020 -0400
Branches: newboolean
https://developer.blender.org/rB77c83d3be11484649b7bc4cbb9b49c90fdb7882d
Fixed the regression after making binary ops not do self-intersection.
Now the new Boolean code is only about 3 to 4 times slower than the
current BMesh one.
===================================================================
M source/blender/blenlib/intern/boolean.cc
M source/blender/blenlib/intern/mesh_intersect.cc
M tests/gtests/blenlib/BLI_boolean_test.cc
M tests/gtests/blenlib/BLI_mesh_intersect_test.cc
===================================================================
diff --git a/source/blender/blenlib/intern/boolean.cc b/source/blender/blenlib/intern/boolean.cc
index 1e56a9560ed..37fe09920d8 100644
--- a/source/blender/blenlib/intern/boolean.cc
+++ b/source/blender/blenlib/intern/boolean.cc
@@ -110,23 +110,6 @@ static std::ostream &operator<<(std::ostream &os, const Span<int> &a)
return os;
}
-static std::ostream &operator<<(std::ostream &os, const Span<uint> &a)
-{
- for (int i : a.index_range()) {
- os << a[i];
- if (i != a.size() - 1) {
- os << " ";
- }
- }
- return os;
-}
-
-static std::ostream &operator<<(std::ostream &os, const Vector<uint> &ivec)
-{
- os << Span<uint>(ivec);
- return os;
-}
-
static std::ostream &operator<<(std::ostream &os, const Array<int> &iarr)
{
os << Span<int>(iarr);
@@ -1984,7 +1967,7 @@ Mesh boolean_trimesh(Mesh &tm_in,
bool use_self,
MArena *arena)
{
- constexpr int dbg_level = 2;
+ constexpr int dbg_level = 0;
if (dbg_level > 0) {
std::cout << "BOOLEAN of " << nshapes << " operand" << (nshapes == 1 ? "" : "s")
<< " op=" << bool_optype_name(op) << "\n";
diff --git a/source/blender/blenlib/intern/mesh_intersect.cc b/source/blender/blenlib/intern/mesh_intersect.cc
index a03a6d15825..35efe4d9e4a 100644
--- a/source/blender/blenlib/intern/mesh_intersect.cc
+++ b/source/blender/blenlib/intern/mesh_intersect.cc
@@ -2162,7 +2162,7 @@ class TriOverlaps {
std::function<int(int)> shape_fn,
bool use_self)
{
- constexpr int dbg_level = 1;
+ constexpr int dbg_level = 0;
if (dbg_level > 0) {
std::cout << "TriOverlaps construction\n";
}
@@ -2216,6 +2216,19 @@ class TriOverlaps {
tree_, tree_, &overlap_tot_, only_different_shapes, &cbdata);
}
}
+ /* The rest of the code is simpler and easier to parallelize if, in the two-trees case,
+ * we repeat the overlaps with indexA and indexB reversed. It is important that
+ * in the repeated part, sorting will then bring things with indexB together.
+ */
+ if (two_trees_no_self) {
+ overlap_ = static_cast<BVHTreeOverlap *>(
+ MEM_reallocN(overlap_, 2 * overlap_tot_ * sizeof(overlap_[0])));
+ for (uint i = 0; i < overlap_tot_; ++i) {
+ overlap_[overlap_tot_ + i].indexA = overlap_[i].indexB;
+ overlap_[overlap_tot_ + i].indexB = overlap_[i].indexA;
+ }
+ overlap_tot_ += overlap_tot_;
+ }
/* Sort the overlaps to bring all the intersects with a given indexA together. */
std::sort(overlap_, overlap_ + overlap_tot_, bvhtreeverlap_cmp);
if (dbg_level > 0) {
@@ -2521,7 +2534,7 @@ Mesh trimesh_nary_intersect(
perfdata_init();
doperfmax(0, static_cast<int>(tm_in.face_size()));
doperfmax(1, static_cast<int>(clinfo.tot_cluster()));
- doperfmax(2, static_cast<int>(ov.overlap().size)));
+ doperfmax(2, static_cast<int>(tri_ov.overlap().size()));
#endif
Array<CDT_data> cluster_subdivided(clinfo.tot_cluster());
for (int c : clinfo.index_range()) {
@@ -2672,6 +2685,10 @@ static void perfdata_init(void)
perfdata.max.append(0);
perfdata.max_name.append("total faces");
+ /* max 1. */
+ perfdata.max.append(0);
+ perfdata.max_name.append("total clusters");
+
/* max 2. */
perfdata.max.append(0);
perfdata.max_name.append("total overlaps");
diff --git a/tests/gtests/blenlib/BLI_boolean_test.cc b/tests/gtests/blenlib/BLI_boolean_test.cc
index 73f38b31545..7985d0a2f6d 100644
--- a/tests/gtests/blenlib/BLI_boolean_test.cc
+++ b/tests/gtests/blenlib/BLI_boolean_test.cc
@@ -103,7 +103,6 @@ class MeshBuilder {
}
};
-#if 0
TEST(boolean_trimesh, Empty)
{
MArena arena;
@@ -232,7 +231,6 @@ TEST(boolean_trimesh, CubeTet)
write_obj_mesh(out, "cubetet_union");
}
}
-#endif
TEST(boolean_trimesh, BinaryTetTet)
{
@@ -266,7 +264,6 @@ TEST(boolean_trimesh, BinaryTetTet)
}
}
-#if 0
TEST(boolean_trimesh, TetTetCoplanar)
{
const char *spec = R"(8 8
@@ -466,6 +463,5 @@ TEST(boolean_polymesh, TetTeTCoplanarDiff)
write_obj_mesh(out, "tettet_coplanar_diff");
}
}
-#endif
} // namespace blender::meshintersect
diff --git a/tests/gtests/blenlib/BLI_mesh_intersect_test.cc b/tests/gtests/blenlib/BLI_mesh_intersect_test.cc
index c912d6951c0..0a0d42e174c 100644
--- a/tests/gtests/blenlib/BLI_mesh_intersect_test.cc
+++ b/tests/gtests/blenlib/BLI_mesh_intersect_test.cc
@@ -813,7 +813,7 @@ static void spheresphere_test(int nrings, double y_offset, bool use_self)
TEST(mesh_intersect_perf, SphereSphere)
{
- spheresphere_test(64, 0.5, true);
+ spheresphere_test(64, 0.5, false);
}
#endif
More information about the Bf-blender-cvs
mailing list