From 111e378366e389fda300e0f5317d0c9b95bbd8fb Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Sun, 16 Jul 2023 00:08:23 -0400 Subject: [PATCH] Revert "Fix #109236: Split Edges node skips loose edges" This reverts commit b226c115e263afbb1c2ded1e5a73e954690945c2. Fixes #110005. I have been working on a fix branch, but the problem was fairly fundamental to the algorithm and the fix ended up being a rewrite that I didn't quite finish yet, and I will be away next week. Since the other bug is a crash rather than a change in behavior, better to have the other bug than this one in the meantime. --- .../geometry/intern/mesh_split_edges.cc | 53 ++----------------- 1 file changed, 3 insertions(+), 50 deletions(-) diff --git a/source/blender/geometry/intern/mesh_split_edges.cc b/source/blender/geometry/intern/mesh_split_edges.cc index 2538a4fbd22..9bc7be7ed0b 100644 --- a/source/blender/geometry/intern/mesh_split_edges.cc +++ b/source/blender/geometry/intern/mesh_split_edges.cc @@ -180,33 +180,6 @@ static void split_vertex_per_fan(const int vertex, } } -/** Assign the newly created vertex duplicates to the loose edges around this vertex. */ -static void reassign_loose_edge_verts(const int vertex, - const int start_offset, - const Span fans, - const Span fan_sizes, - const BoundedBitSpan loose_edges, - MutableSpan edges) -{ - int fan_start = 0; - /* We don't need to create a new vertex for the last fan. That fan can just be connected to the - * original vertex. */ - for (const int i : fan_sizes.index_range().drop_back(1)) { - const int new_vert = start_offset + i; - for (const int edge_i : fans.slice(fan_start, fan_sizes[i])) { - if (loose_edges[edge_i]) { - if (edges[edge_i][0] == vertex) { - edges[edge_i][0] = new_vert; - } - else if (edges[edge_i][1] == vertex) { - edges[edge_i][1] = new_vert; - } - } - } - fan_start += fan_sizes[i]; - } -} - /** * Get the index of the adjacent edge to a loop connected to a vertex. In other words, for the * given polygon return the unique edge connected to the given vertex and not on the given loop. @@ -410,7 +383,7 @@ void split_edges(Mesh &mesh, } }); - /* Calculate result indices per source vertex as offsets for parallelizing the next step. */ + /* Step 2.5: Calculate offsets for next step. */ Array vert_offsets(mesh.totvert); int total_verts_num = mesh.totvert; for (const int vert : IndexRange(mesh.totvert)) { @@ -422,7 +395,7 @@ void split_edges(Mesh &mesh, total_verts_num += vertex_fan_sizes[vert].size() - 1; } - /* Split the vertices into their duplicates so that each fan has its own result vertex. + /* Step 3: Split the vertices. * Build a map from each new vertex to an old vertex to use for transferring attributes later. */ const int new_verts_num = total_verts_num - mesh.totvert; Array new_to_old_verts_map(new_verts_num); @@ -442,7 +415,6 @@ void split_edges(Mesh &mesh, } }); - /* Create deduplicated new edges based on the corner vertices at each polygon. */ VectorSet new_edges; new_edges.reserve(new_edges_size + loose_edges.size()); for (const int i : polys.index_range()) { @@ -455,7 +427,6 @@ void split_edges(Mesh &mesh, } loose_edges.foreach_index([&](const int64_t i) { new_edges.add(OrderedEdge(edges[i])); }); - /* Build a map of old to new edges for transferring attributes. */ Array new_to_old_edges_map(new_edges.size()); loose_edges.to_indices(new_to_old_edges_map.as_mutable_span().take_back(loose_edges.size())); for (const int i : polys.index_range()) { @@ -467,28 +438,10 @@ void split_edges(Mesh &mesh, } } - /* Resize the mesh to add the new vertices and rebuild the edges. */ + /* Step 5: Resize the mesh to add the new vertices and rebuild the edges. */ add_new_vertices(mesh, new_to_old_verts_map); add_new_edges(mesh, new_edges.as_span().cast(), new_to_old_edges_map, propagation_info); - /* Connect loose edges to duplicated vertices. */ - if (loose_edges_cache.count > 0) { - MutableSpan new_edges_span = mesh.edges_for_write(); - threading::parallel_for(should_split_vert.index_range(), 512, [&](IndexRange range) { - for (const int vert : range) { - if (!should_split_vert[vert]) { - continue; - } - reassign_loose_edge_verts(vert, - vert_offsets[vert], - vert_to_edge_map[vert], - vertex_fan_sizes[vert], - loose_edges_cache.is_loose_bits, - new_edges_span); - } - }); - } - BKE_mesh_tag_edges_split(&mesh); }