[Bf-blender-cvs] [5f6fad8f751] soc-2019-adaptive-cloth: Cloth: UI to choose static or dynamic remeshing

ishbosamiya noreply at git.blender.org
Fri Aug 9 12:42:36 CEST 2019


Commit: 5f6fad8f751ee6bf3f5a2bea987544738b856abd
Author: ishbosamiya
Date:   Fri Aug 9 15:14:39 2019 +0530
Branches: soc-2019-adaptive-cloth
https://developer.blender.org/rB5f6fad8f751ee6bf3f5a2bea987544738b856abd

Cloth: UI to choose static or dynamic remeshing

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

M	release/scripts/startup/bl_ui/properties_physics_cloth.py
M	source/blender/blenkernel/BKE_cloth.h
M	source/blender/blenkernel/intern/cloth.c
M	source/blender/blenkernel/intern/cloth_remeshing.cpp
M	source/blender/makesdna/DNA_cloth_types.h
M	source/blender/makesrna/intern/rna_cloth.c

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

diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py
index a9a14b608ad..a4c942071fa 100644
--- a/release/scripts/startup/bl_ui/properties_physics_cloth.py
+++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py
@@ -334,19 +334,22 @@ class PHYSICS_PT_cloth_remeshing(PhysicButtonsPanel, Panel):
         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True)
 
         col = flow.column()
-        col.prop(cloth, "refine_angle", text="Refine Angle")
+        col.prop(cloth, "remeshing_model")
         col = flow.column()
-        col.prop(cloth, "refine_compression", text="Refine Compression")
-        col = flow.column()
-        col.prop(cloth, "refine_velocity", text="Refine Velocity")
-        col = flow.column()
-        col.prop(cloth, "refine_obstacle", text="Refine Obstacle")
+        col.prop(cloth, "aspect_min", text="Aspect Minimum")
         col = flow.column()
         col.prop(cloth, "size_min", text="Size Minimum")
-        col = flow.column()
-        col.prop(cloth, "size_max", text="Size Maximum")
-        col = flow.column()
-        col.prop(cloth, "aspect_min", text="Aspect Minimum")
+        if cloth.remeshing_model == 'REMESHING_DYNAMIC':
+            col = flow.column()
+            col.prop(cloth, "size_max", text="Size Maximum")
+            col = flow.column()
+            col.prop(cloth, "refine_angle", text="Refine Angle")
+            col = flow.column()
+            col.prop(cloth, "refine_compression", text="Refine Compression")
+            col = flow.column()
+            col.prop(cloth, "refine_velocity", text="Refine Velocity")
+            col = flow.column()
+            col.prop(cloth, "refine_obstacle", text="Refine Obstacle")
 
 
 class PHYSICS_PT_cloth_property_weights(PhysicButtonsPanel, Panel):
diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h
index d8a636832d4..d657414f59d 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -223,6 +223,12 @@ typedef enum {
   CLOTH_BENDING_ANGULAR = 1,
 } CLOTH_BENDING_MODEL;
 
+/* ClothSimSettings.remeshing_model. */
+typedef enum {
+  CLOTH_REMESHING_STATIC = 0,
+  CLOTH_REMESHING_DYNAMIC = 1,
+} CLOTH_REMESHING_MODEL;
+
 /* COLLISION FLAGS */
 typedef enum {
   CLOTH_COLLSETTINGS_FLAG_ENABLED = (1 << 1), /* enables cloth - object collisions */
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 2672e675988..92124504f1e 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -156,6 +156,7 @@ void cloth_init(ClothModifierData *clmd)
   /**
    *remeshing parameters
    */
+  clmd->sim_parms->remeshing_model = CLOTH_REMESHING_DYNAMIC;
   clmd->sim_parms->refine_angle = 0.3f;
   clmd->sim_parms->refine_compression = 0.005f;
   clmd->sim_parms->refine_velocity = 0.5f;
diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp
index 1aa79b3f932..a3dbaf6e916 100644
--- a/source/blender/blenkernel/intern/cloth_remeshing.cpp
+++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp
@@ -2606,12 +2606,15 @@ Mesh *cloth_remeshing_step(Depsgraph *depsgraph, Object *ob, ClothModifierData *
 
   const int cd_loop_uv_offset = CustomData_get_offset(&clmd->clothObject->bm->ldata, CD_MLOOPUV);
 
-  if (true) {
+  if (clmd->sim_parms->remeshing_model == CLOTH_REMESHING_STATIC) {
     cloth_remeshing_static(clmd, cvm, cd_loop_uv_offset);
   }
-  else {
+  else if (clmd->sim_parms->remeshing_model == CLOTH_REMESHING_DYNAMIC) {
     cloth_remeshing_dynamic(depsgraph, ob, clmd, cvm, cd_loop_uv_offset);
   }
+  else {
+    /* TODO(Ish): give error */
+  }
 
   /* printf("totvert: %d totedge: %d totface: %d\n", */
   /*        clmd->clothObject->bm->totvert, */
diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h
index e7af83005f6..30131b27c8f 100644
--- a/source/blender/makesdna/DNA_cloth_types.h
+++ b/source/blender/makesdna/DNA_cloth_types.h
@@ -150,6 +150,8 @@ typedef struct ClothSimSettings {
   float shear_damp;
 
   /** Remeshing parameters **/
+  short remeshing_model;
+  char _pad1[2];
   float refine_angle;
   float refine_compression;
   float refine_velocity;
@@ -157,7 +159,6 @@ typedef struct ClothSimSettings {
   float size_min;
   float size_max;
   float aspect_min;
-  char _pad1[4];
 } ClothSimSettings;
 
 typedef struct ClothCollSettings {
diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c
index 05425010f3f..16d787eea64 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -461,6 +461,19 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
        "Cloth model with linear bending springs (legacy)"},
       {0, NULL, 0, NULL, NULL},
   };
+  static const EnumPropertyItem prop_remeshing_model_items[] = {
+      {CLOTH_REMESHING_STATIC,
+       "REMESHING_STATIC",
+       0,
+       "Static",
+       "Cloth remeshing model with statically determined vertices"},
+      {CLOTH_REMESHING_DYNAMIC,
+       "REMESHING_DYNAMIC",
+       0,
+       "Dynamic",
+       "Cloth remeshing model with dynamically changing vertices"},
+      {0, NULL, 0, NULL, NULL},
+  };
 
   srna = RNA_def_struct(brna, "ClothSettings", NULL);
   RNA_def_struct_ui_text(srna, "Cloth Settings", "Cloth simulation settings for an object");
@@ -780,6 +793,15 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Adaptive Remeshing", "Enables adaptive remeshing");
   RNA_def_property_clear_flag(prop, PROP_NONE);
   RNA_def_property_update(prop, 0, "rna_cloth_update");
+  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+
+  prop = RNA_def_property(srna, "remeshing_model", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_sdna(prop, NULL, "remeshing_model");
+  RNA_def_property_enum_items(prop, prop_remeshing_model_items);
+  RNA_def_property_ui_text(
+      prop, "Remeshing Model", "Remeshing model for determining how vertices are created/removed");
+  RNA_def_property_update(prop, 0, "rna_cloth_update");
+  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
 
   prop = RNA_def_property(srna, "refine_angle", PROP_FLOAT, PROP_NONE);
   RNA_def_property_float_sdna(prop, NULL, "refine_angle");



More information about the Bf-blender-cvs mailing list