[Bf-blender-cvs] [f1c057006b7] soc-2021-adaptive-cloth: adaptive_cloth: MeshDiff: remove elements that don't exist in mesh

ishbosamiya noreply at git.blender.org
Mon Aug 30 09:15:08 CEST 2021


Commit: f1c057006b774a276a238e92d1f8afc8baeba1b0
Author: ishbosamiya
Date:   Sat Aug 28 16:07:17 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rBf1c057006b774a276a238e92d1f8afc8baeba1b0

adaptive_cloth: MeshDiff: remove elements that don't exist in mesh

It is possible to create a MeshDiff which is updated to remove a
certain element that was initially added. So the added element index
is no longer valid and should be removed.

This function removes elements from the `added_elements` lists that no
longer exist in the mesh.

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

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 dc459431a51..ada7cb6808d 100644
--- a/source/blender/blenkernel/BKE_cloth_remesh.hh
+++ b/source/blender/blenkernel/BKE_cloth_remesh.hh
@@ -3455,6 +3455,44 @@ template<typename END, typename EVD, typename EED, typename EFD> class MeshDiff
     return this->deleted_faces;
   }
 
+  /**
+   * Removes elements from added elements that no longer exist in the
+   * mesh.
+   */
+  void remove_non_existing_elements(const Mesh<END, EVD, EED, EFD> &mesh)
+  {
+    blender::Vector<NodeIndex> added_nodes;
+    blender::Vector<VertIndex> added_verts;
+    blender::Vector<EdgeIndex> added_edges;
+    blender::Vector<FaceIndex> added_faces;
+
+    for (const auto &node_index : this->added_nodes) {
+      if (mesh.has_node(node_index)) {
+        added_nodes.append(node_index);
+      }
+    }
+    for (const auto &vert_index : this->added_verts) {
+      if (mesh.has_vert(vert_index)) {
+        added_verts.append(vert_index);
+      }
+    }
+    for (const auto &edge_index : this->added_edges) {
+      if (mesh.has_edge(edge_index)) {
+        added_edges.append(edge_index);
+      }
+    }
+    for (const auto &face_index : this->added_faces) {
+      if (mesh.has_face(face_index)) {
+        added_faces.append(face_index);
+      }
+    }
+
+    this->added_nodes = added_nodes;
+    this->added_verts = added_verts;
+    this->added_edges = added_edges;
+    this->added_faces = added_faces;
+  }
+
   friend std::ostream &operator<<(std::ostream &stream,
                                   const MeshDiff<END, EVD, EED, EFD> &mesh_diff)
   {



More information about the Bf-blender-cvs mailing list