[Bf-blender-cvs] [5b5a8706858] soc-2019-adaptive-cloth: Cloth: fix cloth constantly being reset

ishbosamiya noreply at git.blender.org
Thu Jun 20 09:20:47 CEST 2019


Commit: 5b5a87068581643d42a17b82ebf2d3489ebb40ef
Author: ishbosamiya
Date:   Thu Jun 20 12:48:03 2019 +0530
Branches: soc-2019-adaptive-cloth
https://developer.blender.org/rB5b5a87068581643d42a17b82ebf2d3489ebb40ef

Cloth: fix cloth constantly being reset

Did this by adding a flag to enable or disable adaptive cloth simualtion. Need to add this to the UI at some point.

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

M	source/blender/blenkernel/BKE_cloth.h
M	source/blender/blenkernel/intern/cloth.c
M	source/blender/makesrna/intern/rna_cloth.c

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

diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h
index 5576f84836f..58c984bcc56 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -215,6 +215,7 @@ typedef enum {
   CLOTH_SIMSETTINGS_FLAG_SEW = (1 << 14), /* pull ends of loose edges together */
   CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH =
       (1 << 15), /* make simulation respect deformations in the base object */
+  CLOTH_SIMSETTINGS_FLAG_ADAPTIVE_REMESHING = (1 << 16), /* if true, use adaptive remeshing */
 } CLOTH_SIMSETTINGS_FLAGS;
 
 /* ClothSimSettings.bending_model. */
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index fff43461bb7..41a832129b0 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -113,6 +113,7 @@ void cloth_init(ClothModifierData *clmd)
   clmd->sim_parms->mass = 0.3f;
   clmd->sim_parms->stepsPerFrame = 5;
   clmd->sim_parms->flags = 0;
+  clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_ADAPTIVE_REMESHING;
   clmd->sim_parms->solver_type = 0;
   clmd->sim_parms->maxspringlen = 10;
   clmd->sim_parms->vgroup_mass = 0;
@@ -1142,15 +1143,15 @@ static void cloth_remeshing_static(ClothModifierData *clmd)
   /**
    * Split edges
    */
-  /* while (cloth_remeshing_split_edges(clmd, &sizing)) { */
-  /*   /\* empty while *\/ */
-  /* } */
-  cloth_remeshing_split_edges(clmd, &sizing);
-  static int file_no = 0;
-  file_no++;
-  char file_name[100];
-  sprintf(file_name, "/tmp/objs/%03d.obj", file_no);
-  cloth_remeshing_export_obj(clmd->clothObject->bm, file_name);
+  while (cloth_remeshing_split_edges(clmd, &sizing)) {
+    /* empty while */
+  }
+  /* cloth_remeshing_split_edges(clmd, &sizing); */
+  /* static int file_no = 0; */
+  /* file_no++; */
+  /* char file_name[100]; */
+  /* sprintf(file_name, "/tmp/objs/%03d.obj", file_no); */
+  /* cloth_remeshing_export_obj(clmd->clothObject->bm, file_name); */
 
   /**
    * Collapse edges
@@ -1204,7 +1205,9 @@ Mesh *clothModifier_do(
 #endif
 
   if (clmd->sim_parms->reset ||
-      (clmd->clothObject && mesh_result->totvert != clmd->clothObject->mvert_num)) {
+      (clmd->clothObject && mesh_result->totvert != clmd->clothObject->mvert_num &&
+       clmd->sim_parms->flags & ~CLOTH_SIMSETTINGS_FLAG_ADAPTIVE_REMESHING)) {
+    printf("this is called\n");
     clmd->sim_parms->reset = 0;
     clmd->sim_parms->remeshing_reset = 1;
 #if USE_CLOTH_CACHE
diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c
index dfa3b62ae80..5cfc26acdff 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -775,6 +775,12 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
 
   /* remeshing */
+  prop = RNA_def_property(srna, "use_adaptive_remeshing", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_SIMSETTINGS_FLAG_ADAPTIVE_REMESHING);
+  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");
+
   prop = RNA_def_property(srna, "refine_angle", PROP_FLOAT, PROP_NONE);
   RNA_def_property_float_sdna(prop, NULL, "refine_angle");
   RNA_def_property_range(prop, 0.0f, 10.0f);



More information about the Bf-blender-cvs mailing list