[Bf-blender-cvs] [dcbd6f42577] soc-2021-adaptive-cloth: adaptive_cloth: gui for `edge_length_max` and `aspect_ratio_min`

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


Commit: dcbd6f42577774c3d516c1695eac012f664ee686
Author: ishbosamiya
Date:   Sun Sep 5 21:47:00 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rBdcbd6f42577774c3d516c1695eac012f664ee686

adaptive_cloth: gui for `edge_length_max` and `aspect_ratio_min`

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

M	release/scripts/startup/bl_ui/properties_physics_cloth.py
M	source/blender/blenkernel/BKE_cloth_remesh.hh
M	source/blender/blenkernel/intern/cloth_remesh.cc
M	source/blender/makesdna/DNA_cloth_types.h
M	source/blender/makesdna/DNA_modifier_defaults.h
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_cloth.c
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/intern/MOD_adaptive_remesh.cc

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

diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py
index 192e22527a4..8a252b0bac4 100644
--- a/release/scripts/startup/bl_ui/properties_physics_cloth.py
+++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py
@@ -336,6 +336,8 @@ class PHYSICS_PT_cloth_remesh(PhysicButtonsPanel, Panel):
         # TODO(ish): setup better ui
         col = flow.column(align=True)
         col.prop(cloth, "remeshing_edge_length_min", text="Remeshing Minimum Edge Length")
+        col.prop(cloth, "remeshing_edge_length_max", text="Remeshing Maximum Edge Length")
+        col.prop(cloth, "remeshing_aspect_ratio_min", text="Remeshing Minimum Aspect Ratio")
 
 
 class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, Panel):
diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh
index 772f3286dbf..0f8c49f2ac9 100644
--- a/source/blender/blenkernel/BKE_cloth_remesh.hh
+++ b/source/blender/blenkernel/BKE_cloth_remesh.hh
@@ -115,6 +115,8 @@ namespace blender::bke {
  */
 template<typename END, typename ExtraData> struct AdaptiveRemeshParams {
   float edge_length_min;
+  float edge_length_max;
+  float aspect_ratio_min;
   /* AdaptiveRemeshParamsFlags */
   uint32_t flags;
   /* AdaptiveRemeshParamsType */
@@ -3577,6 +3579,8 @@ namespace blender::bke {
 
 struct TempEmptyAdaptiveRemeshParams {
   float edge_length_min;
+  float edge_length_max;
+  float aspect_ratio_min;
   /* AdaptiveRemeshParamsFlags */
   uint32_t flags;
   /* AdaptiveRemeshParamsType */
diff --git a/source/blender/blenkernel/intern/cloth_remesh.cc b/source/blender/blenkernel/intern/cloth_remesh.cc
index d09c8c4c639..66f78389067 100644
--- a/source/blender/blenkernel/intern/cloth_remesh.cc
+++ b/source/blender/blenkernel/intern/cloth_remesh.cc
@@ -2035,6 +2035,8 @@ void BKE_cloth_serialize_adaptive_mesh(Object *ob,
 {
   AdaptiveRemeshParams<internal::ClothNodeData, Cloth> params;
   params.edge_length_min = clmd->sim_parms->remeshing_edge_length_min;
+  params.edge_length_max = clmd->sim_parms->remeshing_edge_length_max;
+  params.aspect_ratio_min = clmd->sim_parms->remeshing_aspect_ratio_min;
   params.extra_data_to_end = [](const Cloth &cloth, size_t index) {
     BLI_assert(index < cloth.mvert_num);
     BLI_assert(cloth.verts);
@@ -2109,6 +2111,8 @@ Mesh *BKE_cloth_remesh(Object *ob, ClothModifierData *clmd, Mesh *mesh)
 
   AdaptiveRemeshParams<internal::ClothNodeData, Cloth> params;
   params.edge_length_min = clmd->sim_parms->remeshing_edge_length_min;
+  params.edge_length_max = clmd->sim_parms->remeshing_edge_length_max;
+  params.aspect_ratio_min = clmd->sim_parms->remeshing_aspect_ratio_min;
   params.flags = 0;
   if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW) {
     params.flags |= ADAPTIVE_REMESH_PARAMS_SEWING;
@@ -2175,6 +2179,8 @@ Mesh *__temp_empty_adaptive_remesh(const TempEmptyAdaptiveRemeshParams &input_pa
 
   AdaptiveRemeshParams<EmptyData, EmptyData> params;
   params.edge_length_min = input_params.edge_length_min;
+  params.edge_length_max = input_params.edge_length_max;
+  params.aspect_ratio_min = input_params.aspect_ratio_min;
   params.flags = input_params.flags;
   params.type = input_params.type;
   params.extra_data_to_end = [](const EmptyData &UNUSED(data), size_t UNUSED(index)) {
diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h
index cc6178d05b6..1f9c7dec6ba 100644
--- a/source/blender/makesdna/DNA_cloth_types.h
+++ b/source/blender/makesdna/DNA_cloth_types.h
@@ -185,8 +185,10 @@ typedef struct ClothSimSettings {
   /* Remeshing parameters */
   /** ClothRemeshingType */
   uint32_t remeshing_type;
-  /* TODO(ish): need to write docs for this */
+  /* TODO(ish): need to write docs for remeshing params */
   float remeshing_edge_length_min;
+  float remeshing_edge_length_max;
+  float remeshing_aspect_ratio_min;
   char _pad2[4];
 
 } ClothSimSettings;
diff --git a/source/blender/makesdna/DNA_modifier_defaults.h b/source/blender/makesdna/DNA_modifier_defaults.h
index a36a366756e..b8af689a4c2 100644
--- a/source/blender/makesdna/DNA_modifier_defaults.h
+++ b/source/blender/makesdna/DNA_modifier_defaults.h
@@ -28,7 +28,9 @@
     .edge_index = 0, \
     .flag = 0, \
     .mode = 0, \
-    .edge_length_min = 0.05 \
+    .edge_length_min = 0.05f, \
+    .edge_length_max = 0.5f, \
+    .aspect_ratio_min = 0.2f, \
   }
 
 #define _DNA_DEFAULT_ArmatureModifierData \
@@ -175,7 +177,9 @@
     .max_internal_compression = 15.0f, \
     /* TODO(ish): setup better remeshing defaults */ \
     .remeshing_type = CLOTH_REMESHING_STATIC, \
-    .remeshing_edge_length_min = 0.01f, \
+    .remeshing_edge_length_min = 0.05f, \
+    .remeshing_edge_length_max = 0.5f, \
+    .remeshing_aspect_ratio_min = 0.2f, \
   }
 
 #define _DNA_DEFAULT_ClothCollSettings \
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index b85229b3944..d502620c80c 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -2356,9 +2356,10 @@ typedef struct AdaptiveRemeshModifierData {
   /* AdaptiveRemeshMode */
   uint32_t mode;
 
-  /* Needed for static remeshing and in the future dynamic remeshing
-   * as well */
+  /* Parameters for static and dynamic remeshing */
   float edge_length_min;
+  float edge_length_max;
+  float aspect_ratio_min;
 } AdaptiveRemeshModifierData;
 
 typedef enum AdaptiveRemeshFlag {
diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c
index 9a4643a3a6c..8024cb0ef92 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -1076,10 +1076,22 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
   /* TODO(ish): remeshing paramters need proper text and doc */
   prop = RNA_def_property(srna, "remeshing_edge_length_min", PROP_FLOAT, PROP_NONE);
   RNA_def_property_float_sdna(prop, NULL, "remeshing_edge_length_min");
-  RNA_def_property_ui_range(prop, 0.0f, 2.0f, 0.005f, 4);
+  RNA_def_property_ui_range(prop, 0.0001f, 2.0f, 0.005f, 4);
   RNA_def_property_ui_text(prop, "Remeshing Minimum Edge Length", "");
   RNA_def_property_update(prop, 0, "rna_cloth_update");
 
+  prop = RNA_def_property(srna, "remeshing_edge_length_max", PROP_FLOAT, PROP_NONE);
+  RNA_def_property_float_sdna(prop, NULL, "remeshing_edge_length_max");
+  RNA_def_property_ui_range(prop, 0.0001f, 2.0f, 0.005f, 4);
+  RNA_def_property_ui_text(prop, "Remeshing Maximum Edge Length", "");
+  RNA_def_property_update(prop, 0, "rna_cloth_update");
+
+  prop = RNA_def_property(srna, "remeshing_aspect_ratio_min", PROP_FLOAT, PROP_NONE);
+  RNA_def_property_float_sdna(prop, NULL, "remeshing_aspect_ratio_min");
+  RNA_def_property_range(prop, 0.0f, 1.0f);
+  RNA_def_property_ui_text(prop, "Remeshing Minimum Aspect Ratio", "");
+  RNA_def_property_update(prop, 0, "rna_cloth_update");
+
   /* unused */
 
   /* unused still */
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 8b7455f1308..2391bfc3210 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -7297,6 +7297,18 @@ static void rna_def_modifier_adaptive_remesh(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Remeshing Minimum Edge Length", "");
   RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
+  prop = RNA_def_property(srna, "edge_length_max", PROP_FLOAT, PROP_NONE);
+  RNA_def_property_float_sdna(prop, NULL, "edge_length_max");
+  RNA_def_property_ui_range(prop, 0.0001f, 2.0f, 0.005f, 4);
+  RNA_def_property_ui_text(prop, "Remeshing Maximum Edge Length", "");
+  RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+  prop = RNA_def_property(srna, "aspect_ratio_min", PROP_FLOAT, PROP_NONE);
+  RNA_def_property_float_sdna(prop, NULL, "aspect_ratio_min");
+  RNA_def_property_range(prop, 0.0f, 1.0f);
+  RNA_def_property_ui_text(prop, "Remeshing Minimum Aspect Ratio", "");
+  RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
   RNA_define_lib_overridable(false);
 }
 
diff --git a/source/blender/modifiers/intern/MOD_adaptive_remesh.cc b/source/blender/modifiers/intern/MOD_adaptive_remesh.cc
index 6cf37291743..47f1179c3dd 100644
--- a/source/blender/modifiers/intern/MOD_adaptive_remesh.cc
+++ b/source/blender/modifiers/intern/MOD_adaptive_remesh.cc
@@ -61,10 +61,10 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx)
   auto mode = armd->mode;
 
   if (mode == ADAPTIVE_REMESH_STATIC_REMESHING || mode == ADAPTIVE_REMESH_DYNAMIC_REMESHING) {
-    auto size_min = armd->edge_length_min;
-
     TempEmptyAdaptiveRemeshParams params;
-    params.edge_length_min = size_min;
+    params.edge_length_min = armd->edge_length_min;
+    params.edge_length_max = armd->edge_length_max;
+    params.aspect_ratio_min = armd->aspect_ratio_min;
     params.flags = 0;
     if (armd->flag & ADAPTIVE_REMESH_SEWING) {
       params.flags |= ADAPTIVE_REMESH_PARAMS_SEWING;
@@ -188,9 +188,15 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
     uiItemR(layout, ptr, "use_across_seams", 0, nullptr, ICON_NONE);
     uiItemR(layout, ptr, "is_verts_swapped", 0, nullptr, ICON_NONE);
   }
-  else if (armd->mode == ADAPTIVE_REMESH_STATIC_REMESHING ||
-           armd->mode == ADAPTIVE_REMESH_DYNAMIC_REMESHING) {
+  else if (armd->mode == ADAPTIVE_REMESH_STATIC_REMESHING) {
+    uiItemR(layout, ptr, "edge_length_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);
+  }
+  else if (armd->mode == ADAPTIVE_REMESH_DYNAMIC_REMESHING) {
     uiItemR(layout, ptr, "edge_length_min", 0, nullptr, ICON_NONE);
+    uiItemR(layout, ptr, "edge_length_max", 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