[Bf-blender-cvs] [1600f3de96c] soc-2021-adaptive-cloth: adaptive_cloth: AdaptiveMesh: ensure edge between sewing edges

ishbosamiya noreply at git.blender.org
Mon Sep 6 11:47:39 CEST 2021


Commit: 1600f3de96c6a05df2291d900153f354787eca33
Author: ishbosamiya
Date:   Tue Aug 31 19:11:38 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rB1600f3de96c6a05df2291d900153f354787eca33

adaptive_cloth: AdaptiveMesh: ensure edge between sewing edges

While trying to create the sewing edges, ensure that the vert in
question is between 2 or more edges that are between sewing edges.

Also ensure that the opposite is between sewing edges.

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

M	source/blender/blenkernel/intern/cloth_remesh.cc

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

diff --git a/source/blender/blenkernel/intern/cloth_remesh.cc b/source/blender/blenkernel/intern/cloth_remesh.cc
index bfc94a6ef77..61b4bd9736e 100644
--- a/source/blender/blenkernel/intern/cloth_remesh.cc
+++ b/source/blender/blenkernel/intern/cloth_remesh.cc
@@ -776,6 +776,18 @@ class AdaptiveMesh : public Mesh<NodeData<END>, VertData, EdgeData, internal::Em
     return {mesh_diff, added_verts};
   }
 
+  /**
+   * Checks for the extra data flags of the edge to see if the edge is
+   * flagged for `EDGE_BETWEEN_SEWING_EDGES`.
+   *
+   * Note: Caller must ensure edge has `extra_data`.
+   */
+  bool is_edge_between_sewing_edges(const AdaptiveEdge &edge) const
+  {
+    const auto &extra_data = edge.get_checked_extra_data();
+    return extra_data.get_flags() & EDGE_BETWEEN_SEWING_EDGES;
+  }
+
   /**
    * Tries to add a sewing edge to `vert_index` if it is possible.
    *
@@ -825,6 +837,21 @@ class AdaptiveMesh : public Mesh<NodeData<END>, VertData, EdgeData, internal::Em
      */
     const auto &vert = this->get_checked_vert(vert_index);
 
+    /* Need to ensure that the vert in question is in between 2 or
+     * more edges that are between sewing edges. In case it is not, no
+     * sewing edge from this vert should be created. */
+    auto num_edges_between_sewing_edges = 0;
+    for (const auto &e1_index : vert.get_edges()) {
+      const auto &e1 = this->get_checked_edge(e1_index);
+
+      if (this->is_edge_between_sewing_edges(e1)) {
+        num_edges_between_sewing_edges++;
+      }
+    }
+    if (num_edges_between_sewing_edges < 2) {
+      return AdaptiveMeshDiff<END>();
+    }
+
     blender::Vector<EdgeIndex> opposite_edges;
 
     /* Get the list of all opposite edges */
@@ -895,6 +922,10 @@ class AdaptiveMesh : public Mesh<NodeData<END>, VertData, EdgeData, internal::Em
         if (this->is_edge_splittable_adaptivemesh(opposite_edge) == false) {
           continue;
         }
+
+        if (this->is_edge_between_sewing_edges(opposite_edge) == false) {
+          continue;
+        }
       }
 
       const auto [mesh_diff, added_verts] = this->split_edge_adaptivemesh(opposite_edge_index,



More information about the Bf-blender-cvs mailing list