[Bf-blender-cvs] [973bd8c4801] soc-2021-adaptive-cloth: adaptive_cloth: AdaptiveMesh: use params for collapsible test

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


Commit: 973bd8c480191e1c91e5f8e4e2b82b047108ce6f
Author: ishbosamiya
Date:   Mon Sep 6 00:40:19 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rB973bd8c480191e1c91e5f8e4e2b82b047108ce6f

adaptive_cloth: AdaptiveMesh: use params for collapsible test

Use the `aspect_ratio_min` available in the params for the edge
collapsible test instead of the hard coded value.

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

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

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

diff --git a/source/blender/blenkernel/intern/cloth_remesh.cc b/source/blender/blenkernel/intern/cloth_remesh.cc
index 90c373ec11b..546729de1fc 100644
--- a/source/blender/blenkernel/intern/cloth_remesh.cc
+++ b/source/blender/blenkernel/intern/cloth_remesh.cc
@@ -594,7 +594,8 @@ class AdaptiveMesh : public Mesh<NodeData<END>, VertData, EdgeData, FaceData> {
    * Here "size" is determined by `Sizing` stores in `Vert`s of the
    * `Edge`, using the function `Sizing::get_edge_size_sq()`.
    */
-  void collapse_edges()
+  template<typename ExtraData>
+  void collapse_edges(const AdaptiveRemeshParams<END, ExtraData> &params)
   {
     blender::Set<FaceIndex> active_faces;
     for (const auto &face : this->get_faces()) {
@@ -625,10 +626,10 @@ class AdaptiveMesh : public Mesh<NodeData<END>, VertData, EdgeData, FaceData> {
           const auto &edge = this->get_checked_edge(edge_index);
 
           std::optional<AdaptiveMeshDiff<END>> op_mesh_diff = std::nullopt;
-          if (this->is_edge_collapseable_adaptivemesh(edge, false)) {
+          if (this->is_edge_collapseable_adaptivemesh(params, edge, false)) {
             op_mesh_diff = this->collapse_edge_triangulate(edge.get_self_index(), false, true);
           }
-          else if (this->is_edge_collapseable_adaptivemesh(edge, true)) {
+          else if (this->is_edge_collapseable_adaptivemesh(params, edge, true)) {
             op_mesh_diff = this->collapse_edge_triangulate(edge.get_self_index(), true, true);
           }
 
@@ -700,7 +701,7 @@ class AdaptiveMesh : public Mesh<NodeData<END>, VertData, EdgeData, FaceData> {
     this->split_edges(sewing_enabled, force_split_for_sewing);
 
     /* Collapse the edges */
-    this->collapse_edges();
+    this->collapse_edges(params);
 
 #if SHOULD_REMESH_DUMP_FILE
     auto static_remesh_end_msgpack = this->serialize();
@@ -746,7 +747,7 @@ class AdaptiveMesh : public Mesh<NodeData<END>, VertData, EdgeData, FaceData> {
     this->split_edges(sewing_enabled, force_split_for_sewing);
 
     /* Collapse the edges */
-    this->collapse_edges();
+    this->collapse_edges(params);
 
 #if SHOULD_REMESH_DUMP_FILE
     auto dynamic_remesh_end_msgpack = this->serialize();
@@ -1434,11 +1435,14 @@ class AdaptiveMesh : public Mesh<NodeData<END>, VertData, EdgeData, FaceData> {
         face.get_verts()[0], face.get_verts()[1], face.get_verts()[2]);
   }
 
-  bool is_edge_collapseable_adaptivemesh(const AdaptiveEdge &edge, bool verts_swapped) const
+  template<typename ExtraData>
+  bool is_edge_collapseable_adaptivemesh(const AdaptiveRemeshParams<END, ExtraData> &params,
+                                         const AdaptiveEdge &edge,
+                                         bool verts_swapped) const
   {
-    /* TODO(ish): expose small_value, aspect_ratio_min to gui */
+    /* TODO(ish): expose small_value to gui */
     const auto small_value = 0.2;
-    const auto aspect_ratio_min = 0.1;
+    const auto aspect_ratio_min = params.aspect_ratio_min;
 
     if (this->is_edge_collapseable(edge.get_self_index(), verts_swapped, true) == false) {
       return false;
diff --git a/source/blender/modifiers/intern/MOD_adaptive_remesh.cc b/source/blender/modifiers/intern/MOD_adaptive_remesh.cc
index 1c34d2da3f0..abd1935d0c1 100644
--- a/source/blender/modifiers/intern/MOD_adaptive_remesh.cc
+++ b/source/blender/modifiers/intern/MOD_adaptive_remesh.cc
@@ -191,6 +191,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
   }
   else if (armd->mode == ADAPTIVE_REMESH_STATIC_REMESHING) {
     uiItemR(layout, ptr, "edge_length_min", 0, nullptr, ICON_NONE);
+    uiItemR(layout, ptr, "aspect_ratio_min", 0, nullptr, ICON_NONE);
     uiItemR(layout, ptr, "enable_sewing", 0, nullptr, ICON_NONE);
     uiItemR(layout, ptr, "force_split_for_sewing", 0, nullptr, ICON_NONE);
   }



More information about the Bf-blender-cvs mailing list