[Bf-blender-cvs] [a78d0f7ac2a] soc-2019-adaptive-cloth: Cloth: pinned vertices now works with adaptive remeshing

ishbosamiya noreply at git.blender.org
Mon Aug 26 05:50:38 CEST 2019


Commit: a78d0f7ac2a3a19dbdd3917c813ee1ec0563d45e
Author: ishbosamiya
Date:   Fri Aug 23 19:39:35 2019 +0530
Branches: soc-2019-adaptive-cloth
https://developer.blender.org/rBa78d0f7ac2a3a19dbdd3917c813ee1ec0563d45e

Cloth: pinned vertices now works with adaptive remeshing

The customdata for newly created vertices is now modified to remove any weight for that vertex. Also the correct mesh is being passed to cloth_apply_vgroup().

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

M	source/blender/blenkernel/intern/cloth.c
M	source/blender/blenkernel/intern/cloth_remeshing.cpp

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

diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 04bffcc0fb4..93b57408ab9 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -365,7 +365,7 @@ static Mesh *do_step_cloth(
 
   /* Support for dynamic vertex groups, changing from frame to frame */
 
-#if 0
+#if 1
   if (clmd->mesh) {
     cloth_apply_vgroup(clmd, clmd->mesh);
   }
@@ -399,7 +399,7 @@ static Mesh *do_step_cloth(
     mesh_result = cloth_remeshing_step(depsgraph, ob, clmd, result);
   }
 
-#if 0
+#if 1
   BKE_id_copy_ex(NULL, (ID *)mesh_result, (ID **)&clmd->mesh, LIB_ID_COPY_LOCALIZE);
 #endif
 
diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp
index 35a067e8f1e..9703d663860 100644
--- a/source/blender/blenkernel/intern/cloth_remeshing.cpp
+++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp
@@ -282,9 +282,9 @@ static ClothVertex cloth_remeshing_mean_cloth_vert(ClothVertex *v1, ClothVertex
   ClothVertex new_vert;
 
   new_vert.flags = 0;
-  if ((v1->flags & CLOTH_VERT_FLAG_PINNED) && (v2->flags & CLOTH_VERT_FLAG_PINNED)) {
-    new_vert.flags |= CLOTH_VERT_FLAG_PINNED;
-  }
+  /* if ((v1->flags & CLOTH_VERT_FLAG_PINNED) && (v2->flags & CLOTH_VERT_FLAG_PINNED)) { */
+  /*   new_vert.flags |= CLOTH_VERT_FLAG_PINNED; */
+  /* } */
   if ((v1->flags & CLOTH_VERT_FLAG_NOSELFCOLL) && (v2->flags & CLOTH_VERT_FLAG_NOSELFCOLL)) {
     new_vert.flags |= CLOTH_VERT_FLAG_NOSELFCOLL;
   }
@@ -1042,6 +1042,14 @@ static void cloth_remeshing_add_vertex_to_cloth(BMVert *v1,
                                                         "New Vertex ClothSizing");
   *temp_sizing = cloth_remeshing_find_average_sizing(*cvm[v1].sizing, *cvm[v2].sizing);
   cvm[new_vert].sizing = temp_sizing;
+#if 1
+  if (new_vert->head.data) {
+    MDeformVert *dvert = (MDeformVert *)new_vert->head.data;
+    if (dvert) {
+      dvert->totweight = 0;
+    }
+  }
+#endif
 }
 
 static BMEdge *cloth_remeshing_find_next_loose_edge(BMVert *v)
@@ -1970,7 +1978,7 @@ static bool cloth_remeshing_collapse_edges(ClothModifierData *clmd,
       /* update active_faces */
       cloth_remeshing_update_active_faces(active_faces, clmd->clothObject->bm, temp_vert);
 
-#if 0
+#if 1
       /* run cloth_remeshing_fix_mesh on newly created faces by
        * cloth_remeshing_try_edge_collapse */
       vector<BMFace *> fix_active;



More information about the Bf-blender-cvs mailing list