[Bf-blender-cvs] [acaf87d88c7] soc-2021-adaptive-cloth: adaptive_cloth: AdaptiveMesh: flip edges: set edge size

ishbosamiya noreply at git.blender.org
Mon Aug 9 11:13:28 CEST 2021


Commit: acaf87d88c71c0b385cc03a92552fad014f1f01a
Author: ishbosamiya
Date:   Fri Aug 6 10:35:20 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rBacaf87d88c71c0b385cc03a92552fad014f1f01a

adaptive_cloth: AdaptiveMesh: flip edges: set edge size

It is important to set the edge size for all the newly created edges.

Limit the number of loops, it can easily become an infinite
loop. There should be a better solution for this but cannot think of
one as of right now.

Always check if the edge is still flippable or not. Again, this
couldn't be solved with a different flip edge algorithm where the new
edge is always added, but right now, that isn't possible.

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

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 348bd31b3b5..ce798583dda 100644
--- a/source/blender/blenkernel/intern/cloth_remesh.cc
+++ b/source/blender/blenkernel/intern/cloth_remesh.cc
@@ -332,13 +332,25 @@ class AdaptiveMesh : public Mesh<NodeData<END>, VertData, EdgeData, internal::Em
    */
   void flip_edges(blender::Vector<FaceIndex> active_faces)
   {
+    auto max_loop_cycles = active_faces.size() * 3;
+    auto loop_cycles_until_now = 0;
     auto flippable_edge_indices_set = this->get_flippable_edge_indices_set(active_faces);
     do {
       for (const auto &edge_index : flippable_edge_indices_set) {
         auto &edge = this->get_checked_edge(edge_index);
 
+        if (!this->is_edge_flippable_anisotropic_aware(edge)) {
+          continue;
+        }
+
         auto mesh_diff = this->flip_edge_triangulate(edge.get_self_index(), false);
 
+        /* For each new edge added, set it's sizing */
+        for (const auto &edge_index : mesh_diff.get_added_edges()) {
+          auto &edge = this->get_checked_edge(edge_index);
+          this->edge_set_size(edge);
+        }
+
         auto after_flip_msgpack = this->serialize();
         auto after_flip_filename = static_remesh_name_gen.get_curr("after_flip");
         static_remesh_name_gen.gen_next();
@@ -362,7 +374,8 @@ class AdaptiveMesh : public Mesh<NodeData<END>, VertData, EdgeData, internal::Em
       }
 
       flippable_edge_indices_set = this->get_flippable_edge_indices_set(active_faces);
-    } while (flippable_edge_indices_set.size() != 0);
+      loop_cycles_until_now++;
+    } while (flippable_edge_indices_set.size() != 0 && loop_cycles_until_now != max_loop_cycles);
   }
 
   /**



More information about the Bf-blender-cvs mailing list