[Bf-blender-cvs] [ee7425dab76] soc-2021-adaptive-cloth: adaptive_cloth: AdaptiveMesh: flag for sewing with gui where needed

ishbosamiya noreply at git.blender.org
Mon Aug 30 09:15:07 CEST 2021


Commit: ee7425dab76e9b9da25054026d891981531bd00f
Author: ishbosamiya
Date:   Fri Aug 27 18:06:25 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rBee7425dab76e9b9da25054026d891981531bd00f

adaptive_cloth: AdaptiveMesh: flag for sewing with gui where needed

Added a new flag to have sewing enabled. The flag doesn't do anything
yet (no functionality).

Added the required code to pass this sewing option to
adaptive_remesh().

Created the GUI for this flag in the AdaptiveRemesh modifier.

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

M	source/blender/blenkernel/BKE_cloth_remesh.hh
M	source/blender/blenkernel/intern/cloth_remesh.cc
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_modifier.c
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 f9d977660db..cd5356f8f1c 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 size_min;
+  /* AdaptiveRemeshParamsFlags */
+  uint32_t flags;
 
   /* For handling Extra Node Data */
   /**
@@ -149,6 +151,14 @@ template<typename END, typename ExtraData> struct AdaptiveRemeshParams {
   std::function<void(ExtraData &, size_t)> pre_end_to_extra_data;
 };
 
+/**
+ * AdaptiveRemeshParams->flags
+ */
+enum AdaptiveRemeshParamsFlags {
+  /** Sewing is enabled */
+  ADAPTIVE_REMESH_PARAMS_SEWING = 1 << 0,
+};
+
 /* `mesh` cannot be made const because function defined on `struct
  * Mesh` do not take `struct Mesh` as const even when they can be const */
 template<typename END, typename ExtraData>
@@ -3366,6 +3376,8 @@ namespace blender::bke {
 
 struct TempEmptyAdaptiveRemeshParams {
   float size_min;
+  /* AdaptiveRemeshParamsFlags */
+  uint32_t flags;
 };
 
 Mesh *__temp_empty_adaptive_remesh(const TempEmptyAdaptiveRemeshParams &params, Mesh *mesh);
diff --git a/source/blender/blenkernel/intern/cloth_remesh.cc b/source/blender/blenkernel/intern/cloth_remesh.cc
index 9c63dbd27f4..3e739151b32 100644
--- a/source/blender/blenkernel/intern/cloth_remesh.cc
+++ b/source/blender/blenkernel/intern/cloth_remesh.cc
@@ -1452,6 +1452,10 @@ Mesh *BKE_cloth_remesh(Object *ob, ClothModifierData *clmd, Mesh *mesh)
 
   AdaptiveRemeshParams<internal::ClothNodeData, Cloth> params;
   params.size_min = clmd->sim_parms->remeshing_size_min;
+  params.flags = 0;
+  if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW) {
+    params.flags |= ADAPTIVE_REMESH_PARAMS_SEWING;
+  }
   params.extra_data_to_end = [](const Cloth &cloth, size_t index) {
     BLI_assert(index < cloth.mvert_num);
     BLI_assert(cloth.verts);
@@ -1504,6 +1508,10 @@ Mesh *__temp_empty_adaptive_remesh(const TempEmptyAdaptiveRemeshParams &input_pa
 
   AdaptiveRemeshParams<EmptyData, EmptyData> params;
   params.size_min = input_params.size_min;
+  params.flags = 0;
+  if (input_params.flags & ADAPTIVE_REMESH_PARAMS_SEWING) {
+    params.flags |= ADAPTIVE_REMESH_PARAMS_SEWING;
+  }
   params.extra_data_to_end = [](const EmptyData &UNUSED(data), size_t UNUSED(index)) {
     return internal::EmptyExtraData();
   };
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 632f3c3d69c..30a4a77be66 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -2364,6 +2364,7 @@ typedef struct AdaptiveRemeshModifierData {
 typedef enum AdaptiveRemeshFlag {
   ADAPTIVE_REMESH_ACROSS_SEAMS = 1 << 0,
   ADAPTIVE_REMESH_VERTS_SWAPPED = 1 << 1,
+  ADAPTIVE_REMESH_SEWING = 1 << 2,
 } AdaptiveRemeshFlag;
 
 typedef enum AdaptiveRemeshMode {
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index a958fed53d4..5bb25d85e9c 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -7276,6 +7276,11 @@ static void rna_def_modifier_adaptive_remesh(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Verts Swapped", "Swap verts during the operation");
   RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
+  prop = RNA_def_property(srna, "enable_sewing", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "flag", ADAPTIVE_REMESH_SEWING);
+  RNA_def_property_ui_text(prop, "Enable Sewing", "Enable sewing during remeshing");
+  RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
   prop = RNA_def_property(srna, "size_min", PROP_FLOAT, PROP_NONE);
   RNA_def_property_float_sdna(prop, NULL, "size_min");
   RNA_def_property_ui_range(prop, 0.0001f, 2.0f, 0.005f, 4);
diff --git a/source/blender/modifiers/intern/MOD_adaptive_remesh.cc b/source/blender/modifiers/intern/MOD_adaptive_remesh.cc
index f9b1c09e1bd..836c133abd0 100644
--- a/source/blender/modifiers/intern/MOD_adaptive_remesh.cc
+++ b/source/blender/modifiers/intern/MOD_adaptive_remesh.cc
@@ -65,6 +65,10 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx)
 
     TempEmptyAdaptiveRemeshParams params;
     params.size_min = size_min;
+    params.flags = 0;
+    if (armd->flag & ADAPTIVE_REMESH_SEWING) {
+      params.flags |= ADAPTIVE_REMESH_PARAMS_SEWING;
+    }
 
     return __temp_empty_adaptive_remesh(params, mesh);
   }
@@ -174,6 +178,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
   }
   else if (armd->mode == ADAPTIVE_REMESH_STATIC_REMESHING) {
     uiItemR(layout, ptr, "size_min", 0, nullptr, ICON_NONE);
+    uiItemR(layout, ptr, "enable_sewing", 0, nullptr, ICON_NONE);
   }
   else {
     BLI_assert_unreachable();



More information about the Bf-blender-cvs mailing list