[Bf-blender-cvs] [6748f5cfbbf] soc-2021-adaptive-cloth: adaptive_cloth: face sizing: change_in_vertex_normal_max as a param

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


Commit: 6748f5cfbbfa75303b114f3dfa0268eff14d338d
Author: ishbosamiya
Date:   Mon Sep 6 00:26:41 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rB6748f5cfbbfa75303b114f3dfa0268eff14d338d

adaptive_cloth: face sizing: change_in_vertex_normal_max as a param

Create GUI and use `change_in_vertex_normal_max` for dynamic face
sizing calculation instead of the hard coded value.

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

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 8a252b0bac4..07f652cf3d3 100644
--- a/release/scripts/startup/bl_ui/properties_physics_cloth.py
+++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py
@@ -338,6 +338,7 @@ class PHYSICS_PT_cloth_remesh(PhysicButtonsPanel, Panel):
         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")
+        col.prop(cloth, "remeshing_change_in_vertex_normal_max", text="Remeshing Maximum Change in Vertex Normal")
 
 
 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 0f8c49f2ac9..9bf2dac6792 100644
--- a/source/blender/blenkernel/BKE_cloth_remesh.hh
+++ b/source/blender/blenkernel/BKE_cloth_remesh.hh
@@ -117,6 +117,7 @@ template<typename END, typename ExtraData> struct AdaptiveRemeshParams {
   float edge_length_min;
   float edge_length_max;
   float aspect_ratio_min;
+  float change_in_vertex_normal_max;
   /* AdaptiveRemeshParamsFlags */
   uint32_t flags;
   /* AdaptiveRemeshParamsType */
@@ -3581,6 +3582,7 @@ struct TempEmptyAdaptiveRemeshParams {
   float edge_length_min;
   float edge_length_max;
   float aspect_ratio_min;
+  float change_in_vertex_normal_max;
   /* AdaptiveRemeshParamsFlags */
   uint32_t flags;
   /* AdaptiveRemeshParamsType */
diff --git a/source/blender/blenkernel/intern/cloth_remesh.cc b/source/blender/blenkernel/intern/cloth_remesh.cc
index f872b65a579..90c373ec11b 100644
--- a/source/blender/blenkernel/intern/cloth_remesh.cc
+++ b/source/blender/blenkernel/intern/cloth_remesh.cc
@@ -782,7 +782,7 @@ class AdaptiveMesh : public Mesh<NodeData<END>, VertData, EdgeData, FaceData> {
     const float edge_length_min = params.edge_length_min;
     const float edge_length_max = params.edge_length_max;
     const float aspect_ratio_min = params.aspect_ratio_min;
-    const float change_in_vertex_normal_max = 0.01;
+    const float change_in_vertex_normal_max = params.change_in_vertex_normal_max;
 
     BLI_assert(face.get_verts().size() == 3);
     const auto &n1 = this->get_checked_node_of_vert(this->get_checked_vert(face.get_verts()[0]));
@@ -2042,6 +2042,7 @@ void BKE_cloth_serialize_adaptive_mesh(Object *ob,
   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.change_in_vertex_normal_max = clmd->sim_parms->remeshing_change_in_vertex_normal_max;
   params.extra_data_to_end = [](const Cloth &cloth, size_t index) {
     BLI_assert(index < cloth.mvert_num);
     BLI_assert(cloth.verts);
@@ -2118,6 +2119,7 @@ Mesh *BKE_cloth_remesh(Object *ob, ClothModifierData *clmd, Mesh *mesh)
   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.change_in_vertex_normal_max = clmd->sim_parms->remeshing_change_in_vertex_normal_max;
   params.flags = 0;
   if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW) {
     params.flags |= ADAPTIVE_REMESH_PARAMS_SEWING;
@@ -2186,6 +2188,7 @@ Mesh *__temp_empty_adaptive_remesh(const TempEmptyAdaptiveRemeshParams &input_pa
   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.change_in_vertex_normal_max = input_params.change_in_vertex_normal_max;
   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 1f9c7dec6ba..2009b740ab8 100644
--- a/source/blender/makesdna/DNA_cloth_types.h
+++ b/source/blender/makesdna/DNA_cloth_types.h
@@ -189,8 +189,7 @@ typedef struct ClothSimSettings {
   float remeshing_edge_length_min;
   float remeshing_edge_length_max;
   float remeshing_aspect_ratio_min;
-  char _pad2[4];
-
+  float remeshing_change_in_vertex_normal_max;
 } ClothSimSettings;
 
 /* SIMULATION FLAGS: goal flags,.. */
diff --git a/source/blender/makesdna/DNA_modifier_defaults.h b/source/blender/makesdna/DNA_modifier_defaults.h
index b8af689a4c2..35eefe50b7e 100644
--- a/source/blender/makesdna/DNA_modifier_defaults.h
+++ b/source/blender/makesdna/DNA_modifier_defaults.h
@@ -31,6 +31,7 @@
     .edge_length_min = 0.05f, \
     .edge_length_max = 0.5f, \
     .aspect_ratio_min = 0.2f, \
+    .change_in_vertex_normal_max = 0.01f, \
   }
 
 #define _DNA_DEFAULT_ArmatureModifierData \
@@ -180,6 +181,7 @@
     .remeshing_edge_length_min = 0.05f, \
     .remeshing_edge_length_max = 0.5f, \
     .remeshing_aspect_ratio_min = 0.2f, \
+    .remeshing_change_in_vertex_normal_max = 0.01f, \
   }
 
 #define _DNA_DEFAULT_ClothCollSettings \
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index d502620c80c..fc255dfcb35 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -2360,6 +2360,9 @@ typedef struct AdaptiveRemeshModifierData {
   float edge_length_min;
   float edge_length_max;
   float aspect_ratio_min;
+  float change_in_vertex_normal_max;
+
+  char _pad1[4];
 } AdaptiveRemeshModifierData;
 
 typedef enum AdaptiveRemeshFlag {
diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c
index 8024cb0ef92..83bbca1c7f8 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -1092,6 +1092,12 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Remeshing Minimum Aspect Ratio", "");
   RNA_def_property_update(prop, 0, "rna_cloth_update");
 
+  prop = RNA_def_property(srna, "remeshing_change_in_vertex_normal_max", PROP_FLOAT, PROP_NONE);
+  RNA_def_property_float_sdna(prop, NULL, "remeshing_change_in_vertex_normal_max");
+  RNA_def_property_ui_range(prop, 0.0001f, 2.0f, 0.005f, 4);
+  RNA_def_property_ui_text(prop, "Remeshing Maximum Change in Vertex Normal", "");
+  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 2391bfc3210..9e7c56c645f 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -7309,6 +7309,12 @@ static void rna_def_modifier_adaptive_remesh(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Remeshing Minimum Aspect Ratio", "");
   RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
+  prop = RNA_def_property(srna, "change_in_vertex_normal_max", PROP_FLOAT, PROP_NONE);
+  RNA_def_property_float_sdna(prop, NULL, "change_in_vertex_normal_max");
+  RNA_def_property_ui_range(prop, 0.0001f, 2.0f, 0.005f, 4);
+  RNA_def_property_ui_text(prop, "Remeshing Maximum Change in Vertex Normal", "");
+  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 47f1179c3dd..1c34d2da3f0 100644
--- a/source/blender/modifiers/intern/MOD_adaptive_remesh.cc
+++ b/source/blender/modifiers/intern/MOD_adaptive_remesh.cc
@@ -65,6 +65,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx)
     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.change_in_vertex_normal_max = armd->change_in_vertex_normal_max;
     params.flags = 0;
     if (armd->flag & ADAPTIVE_REMESH_SEWING) {
       params.flags |= ADAPTIVE_REMESH_PARAMS_SEWING;
@@ -197,6 +198,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
     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, "change_in_vertex_normal_max", 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