[Bf-blender-cvs] [18e84a915a2] soc-2021-adaptive-cloth: adaptive_cloth: Mesh: collapse edge: all v1 should point to n1

ishbosamiya noreply at git.blender.org
Mon Jul 19 17:35:43 CEST 2021


Commit: 18e84a915a299c50c2a4a9b038688878bfc4064f
Author: ishbosamiya
Date:   Thu Jul 15 11:31:18 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rB18e84a915a299c50c2a4a9b038688878bfc4064f

adaptive_cloth: Mesh: collapse edge: all v1 should point to n1

Sometimes, `n1` will have still have verts attached to it, so it makes
sense to make those verts point to `n2` but keep their UV coordinates
since attempting to merge verts not joined by edges can lead to lot of
issues. So essentially, extra `v1`s becomes `v2`s.

===================================================================

M	source/blender/blenkernel/BKE_cloth_remesh.hh

===================================================================

diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh
index 8b74b8774ad..2beed8da79f 100644
--- a/source/blender/blenkernel/BKE_cloth_remesh.hh
+++ b/source/blender/blenkernel/BKE_cloth_remesh.hh
@@ -1541,6 +1541,7 @@ template<typename END, typename EVD, typename EED, typename EFD> class Mesh {
     auto &n1 = this->get_checked_node_of_vert(v1_a);
     auto &n2 = this->get_checked_node_of_vert(v2_a);
     auto n1_index = n1.self_index;
+    auto n2_index = n2.self_index;
 
     blender::Vector<EdgeIndex> edge_indices = {edge_index};
     if (across_seams) {
@@ -1628,11 +1629,20 @@ template<typename END, typename EVD, typename EED, typename EFD> class Mesh {
       }
     }
 
-    /* delete n1 if it doesn't have any `Vert`s */
+    /* if `n1` has any verts, make them point to `v2` and then delete `n1` */
     {
-      auto n1 = this->get_checked_node(n1_index);
-      if (n1.verts.is_empty()) {
+      auto &n1 = this->get_checked_node(n1_index);
+
+      auto n1_verts = n1.verts;
+      for (const auto &vert_index : n1_verts) {
+        auto &v1 = this->get_checked_vert(vert_index);
+        v1.node = n2_index;
+        n1.verts.remove_first_occurrence_and_reorder(v1.self_index);
+      }
+
+      {
         auto n1 = this->delete_node(n1_index);
+        BLI_assert(n1.verts.is_empty());
         deleted_nodes.append(std::move(n1));
       }
     }



More information about the Bf-blender-cvs mailing list