[Bf-blender-cvs] [d1b89d1a71d] soc-2021-adaptive-cloth: adaptive_cloth: Mesh: split edge: option to copy extra data

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


Commit: d1b89d1a71d60b3c8136faa6b7d86e7b537cde9b
Author: ishbosamiya
Date:   Mon Aug 30 18:06:35 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rBd1b89d1a71d60b3c8136faa6b7d86e7b537cde9b

adaptive_cloth: Mesh: split edge: option to copy extra data

An extra option to copy to the extra data from the edge that is split
to the edges that are formed due to the split. This does not include
the other edges added for triangulation purposes.

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

M	source/blender/blenkernel/BKE_cloth_remesh.hh
M	source/blender/blenkernel/intern/cloth_remesh.cc
M	source/blender/modifiers/intern/MOD_adaptive_remesh.cc

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

diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh
index eb106c2511d..65a86d16441 100644
--- a/source/blender/blenkernel/BKE_cloth_remesh.hh
+++ b/source/blender/blenkernel/BKE_cloth_remesh.hh
@@ -1725,13 +1725,20 @@ template<typename END, typename EVD, typename EED, typename EFD> class Mesh {
    * formed between the nodes of the given edge are also split and
    * triangulated regardless if it on a seam or not.
    *
+   * @param copy_extra_data_for_split_edge If true, the extra data
+   * from the edge that is split to form 2 new edges is copied into
+   * the 2 new edges. The extra data is not copied to the edges that
+   * are added to ensure triangulation.
+   *
    * Returns the `MeshDiff` that lead to the operation.
    *
    * Note, the caller must ensure the adjacent faces to the edge are
    * triangulated. In debug mode, it will assert, in release mode, it
    * is undefined behaviour.
    **/
-  MeshDiff<END, EVD, EED, EFD> split_edge_triangulate(EdgeIndex edge_index, bool across_seams)
+  MeshDiff<END, EVD, EED, EFD> split_edge_triangulate(EdgeIndex edge_index,
+                                                      bool across_seams,
+                                                      bool copy_extra_data_for_split_edge)
   {
     /* This operation will delete the following-
      * the edge specified, faces incident to the edge.
@@ -1767,6 +1774,7 @@ template<typename END, typename EVD, typename EED, typename EFD> class Mesh {
     for (const auto &edge_index : edge_indices) {
       auto &edge_a = this->get_checked_edge(edge_index);
       auto [edge_vert_1_a, edge_vert_2_a] = this->get_checked_verts_of_edge(edge_a, false);
+      const auto orig_edge_extra_data = edge_a.get_extra_data();
 
       /* Create the new vert by interpolating the verts of the edge */
       auto &new_vert = this->add_empty_interp_vert(edge_vert_1_a, edge_vert_2_a);
@@ -1784,12 +1792,20 @@ template<typename END, typename EVD, typename EED, typename EFD> class Mesh {
       added_edges.append(new_edge_1.self_index);
       auto new_edge_1_index = new_edge_1.self_index;
       this->add_edge_ref_to_verts(new_edge_1);
+      if (copy_extra_data_for_split_edge) {
+        auto &extra_data = new_edge_1.get_extra_data_mut();
+        extra_data = orig_edge_extra_data;
+      }
 
       auto &new_edge_2 = this->add_empty_edge();
       new_edge_2.verts = {new_vert.self_index, edge_vert_2_b.self_index};
       added_edges.append(new_edge_2.self_index);
       auto new_edge_2_index = new_edge_2.self_index;
       this->add_edge_ref_to_verts(new_edge_2);
+      if (copy_extra_data_for_split_edge) {
+        auto &extra_data = new_edge_2.get_extra_data_mut();
+        extra_data = orig_edge_extra_data;
+      }
 
       /* Need to reinitialize edge because `add_empty_edge()` may have
        * reallocated `this->edges` */
diff --git a/source/blender/blenkernel/intern/cloth_remesh.cc b/source/blender/blenkernel/intern/cloth_remesh.cc
index 2f041cb3691..c41f86a428e 100644
--- a/source/blender/blenkernel/intern/cloth_remesh.cc
+++ b/source/blender/blenkernel/intern/cloth_remesh.cc
@@ -737,7 +737,7 @@ class AdaptiveMesh : public Mesh<NodeData<END>, VertData, EdgeData, internal::Em
       const EdgeIndex &edge_index, bool sewing_enabled)
   {
     auto &edge = this->get_checked_edge(edge_index);
-    auto mesh_diff = this->split_edge_triangulate(edge.get_self_index(), true);
+    auto mesh_diff = this->split_edge_triangulate(edge.get_self_index(), true, true);
 
 #if SHOULD_REMESH_DUMP_FILE
     auto after_split_msgpack = this->serialize();
diff --git a/source/blender/modifiers/intern/MOD_adaptive_remesh.cc b/source/blender/modifiers/intern/MOD_adaptive_remesh.cc
index 836c133abd0..2d383dfca99 100644
--- a/source/blender/modifiers/intern/MOD_adaptive_remesh.cc
+++ b/source/blender/modifiers/intern/MOD_adaptive_remesh.cc
@@ -107,7 +107,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx)
       auto pre_split_msgpack = internal_mesh.serialize();
       auto pre_split_filename = split_edge_name_gen.get_curr(filename_pre_suffix + "_pre");
 
-      internal_mesh.split_edge_triangulate(edge_index, across_seams);
+      internal_mesh.split_edge_triangulate(edge_index, across_seams, true);
 
       auto post_split_msgpack = internal_mesh.serialize();
       auto post_split_filename = split_edge_name_gen.get_curr(filename_pre_suffix + "_post");



More information about the Bf-blender-cvs mailing list