[Bf-blender-cvs] [832201400fb] soc-2019-adaptive-cloth: Cloth: fix bug in collapse edges

ishbosamiya noreply at git.blender.org
Thu Jul 25 11:35:00 CEST 2019


Commit: 832201400fb5f8a2bef31e89456cfbffb0c2015a
Author: ishbosamiya
Date:   Mon Jul 22 23:53:27 2019 +0530
Branches: soc-2019-adaptive-cloth
https://developer.blender.org/rB832201400fb5f8a2bef31e89456cfbffb0c2015a

Cloth: fix bug in collapse edges

When the face is not collapsed, it needs to be removed from the active faces. To prevent a crash, doing a double i-- helps it only get faces which are within the size() and not capacity().

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

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

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

diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp
index 2a30088fe1b..ae480227a44 100644
--- a/source/blender/blenkernel/intern/cloth_remeshing.cpp
+++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp
@@ -1400,8 +1400,8 @@ static void cloth_remeshing_update_active_faces(vector<BMFace *> &active_faces,
 /* Assumed that active_faces and fix_active have been updated before
  * using either of the other 2 update_active_faces function so that
  * there is no face that is not part of bm */
-static void cloth_remeshing_update_active_faces(vector<BMFace *> active_faces,
-                                                vector<BMFace *> fix_active)
+static void cloth_remeshing_update_active_faces(vector<BMFace *> &active_faces,
+                                                vector<BMFace *> &fix_active)
 {
   for (int i = 0; i < fix_active.size(); i++) {
     bool already_exists = false;
@@ -1458,7 +1458,12 @@ static bool cloth_remeshing_collapse_edges(ClothModifierData *clmd,
       count++;
       return true;
     }
+    /* printf("Skipped previous part! size: %d i: %d ", (int)active_faces.size(), i); */
     cloth_remeshing_remove_face(active_faces, i--);
+    /* TODO(Ish): a double i-- is a hacky way to ensure there is no
+     * crash when removing a face */
+    i--;
+    /* printf("new size: %d new i: %d\n", (int)active_faces.size(), i); */
   }
   return false;
 }
@@ -1516,12 +1521,6 @@ static void cloth_remeshing_static(ClothModifierData *clmd)
   BM_ITER_MESH (f, &fiter, clmd->clothObject->bm, BM_FACES_OF_MESH) {
     active_faces.push_back(f);
   }
-  for (int i = 0; i < active_faces.size(); i++) {
-    BMFace *temp_f = active_faces[i];
-    if (!(temp_f->head.htype == BM_FACE)) {
-      printf("htype didn't match: %d\n", i);
-    }
-  }
   int prev_mvert_num = clmd->clothObject->mvert_num;
   int count = 0;
   while (cloth_remeshing_collapse_edges(clmd, sizing, active_faces, count)) {
@@ -1596,12 +1595,6 @@ static void cloth_remeshing_dynamic(Depsgraph *depsgraph, Object *ob, ClothModif
   BM_ITER_MESH (f, &fiter, clmd->clothObject->bm, BM_FACES_OF_MESH) {
     active_faces.push_back(f);
   }
-  for (int i = 0; i < active_faces.size(); i++) {
-    BMFace *temp_f = active_faces[i];
-    if (!(temp_f->head.htype == BM_FACE)) {
-      printf("htype didn't match: %d\n", i);
-    }
-  }
   int prev_mvert_num = clmd->clothObject->mvert_num;
   int count = 0;
   while (cloth_remeshing_collapse_edges(clmd, sizing, active_faces, count)) {



More information about the Bf-blender-cvs mailing list