[Bf-blender-cvs] [85c125b4708] soc-2019-adaptive-cloth: Cloth: stop using bm_prev

ishbosamiya noreply at git.blender.org
Fri Jul 26 20:19:37 CEST 2019


Commit: 85c125b4708ce361fbb092ea3d7696b1573c62e4
Author: ishbosamiya
Date:   Fri Jul 26 02:29:24 2019 +0530
Branches: soc-2019-adaptive-cloth
https://developer.blender.org/rB85c125b4708ce361fbb092ea3d7696b1573c62e4

Cloth: stop using bm_prev

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

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

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

diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h
index 968e69ffa70..a581f7fc973 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -92,8 +92,7 @@ typedef struct Cloth {
   unsigned int mvert_num_prev;
   unsigned int tri_num;
   unsigned char old_solver_type; /* unused, only 1 solver here */
-  struct BMesh *bm;      /* Used for remeshing step, initialized and deleted then and there */
-  struct BMesh *bm_prev; /* Used for remeshing step, needed previous frame mesh data */
+  struct BMesh *bm; /* Used for remeshing step, initialized and deleted then and there */
   unsigned char pad2;
   short pad3;
   struct BVHTree *bvhtree;     /* collision tree for this cloth object */
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 430887e1c0e..40e060be376 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -563,10 +563,6 @@ void cloth_free_modifier(ClothModifierData *clmd)
       BM_mesh_free(cloth->bm);
       cloth->bm = NULL;
     }
-    if (cloth->bm_prev) {
-      BM_mesh_free(cloth->bm_prev);
-      cloth->bm_prev = NULL;
-    }
 
     // Free the verts.
     if (cloth->verts != NULL) {
@@ -653,10 +649,6 @@ void cloth_free_modifier_extern(ClothModifierData *clmd)
       BM_mesh_free(cloth->bm);
       cloth->bm = NULL;
     }
-    if (cloth->bm_prev) {
-      BM_mesh_free(cloth->bm_prev);
-      cloth->bm_prev = NULL;
-    }
 
     BPH_cloth_solver_free(clmd);
 
@@ -902,7 +894,6 @@ static int cloth_from_object(
     clmd->clothObject->old_solver_type = 255;
     clmd->clothObject->edgeset = NULL;
     clmd->clothObject->bm = NULL;
-    clmd->clothObject->bm_prev = NULL;
   }
   else if (!clmd->clothObject) {
     modifier_setError(&(clmd->modifier), "Out of memory on allocating clmd->clothObject");
diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp
index 4a2d7fc2ae5..d66ac911935 100644
--- a/source/blender/blenkernel/intern/cloth_remeshing.cpp
+++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp
@@ -142,34 +142,34 @@ static void cloth_remeshing_init_bmesh(Object *ob,
                                        Mesh *mesh,
                                        ClothVertMap &cvm)
 {
-  if (clmd->sim_parms->remeshing_reset || !clmd->clothObject->bm_prev) {
+  if (clmd->sim_parms->remeshing_reset || !clmd->clothObject->bm) {
     cloth_to_mesh(ob, clmd, mesh);
 
     CustomData_MeshMasks cddata_masks = cloth_remeshing_get_cd_mesh_masks();
-    if (clmd->clothObject->bm_prev) {
-      BM_mesh_free(clmd->clothObject->bm_prev);
-      clmd->clothObject->bm_prev = NULL;
+    if (clmd->clothObject->bm) {
+      BM_mesh_free(clmd->clothObject->bm);
+      clmd->clothObject->bm = NULL;
     }
     struct BMeshCreateParams bmesh_create_params;
     bmesh_create_params.use_toolflags = 0;
     struct BMeshFromMeshParams bmesh_from_mesh_params;
     bmesh_from_mesh_params.calc_face_normal = true;
     bmesh_from_mesh_params.cd_mask_extra = cddata_masks;
-    clmd->clothObject->bm_prev = BKE_mesh_to_bmesh_ex(
+    clmd->clothObject->bm = BKE_mesh_to_bmesh_ex(
         mesh, &bmesh_create_params, &bmesh_from_mesh_params);
     BMVert *v;
     BMIter viter;
     int i = 0;
-    BM_ITER_MESH_INDEX (v, &viter, clmd->clothObject->bm_prev, BM_VERTS_OF_MESH, i) {
+    BM_ITER_MESH_INDEX (v, &viter, clmd->clothObject->bm, BM_VERTS_OF_MESH, i) {
       copy_v3_v3(v->co, clmd->clothObject->verts[i].x);
       cvm[v] = clmd->clothObject->verts[i];
     }
     /* TODO(Ish): delete the existing clmd->clothObject->verts because
      * it is duplicated into cvm */
 
-    BM_mesh_normals_update(clmd->clothObject->bm_prev);
+    BM_mesh_normals_update(clmd->clothObject->bm);
 
-    BM_mesh_triangulate(clmd->clothObject->bm_prev,
+    BM_mesh_triangulate(clmd->clothObject->bm,
                         MOD_TRIANGULATE_QUAD_SHORTEDGE,
                         MOD_TRIANGULATE_NGON_BEAUTY,
                         4,
@@ -177,18 +177,18 @@ static void cloth_remeshing_init_bmesh(Object *ob,
                         NULL,
                         NULL,
                         NULL);
-    printf("remeshing_reset has been set to true or bm_prev does not exist\n");
+    printf("remeshing_reset has been set to true or bm does not exist\n");
   }
   else {
     BMVert *v;
     BMIter viter;
     int i = 0;
-    BM_ITER_MESH_INDEX (v, &viter, clmd->clothObject->bm_prev, BM_VERTS_OF_MESH, i) {
-      copy_v3_v3(v->co, cvm[v].x);
+    BM_ITER_MESH_INDEX (v, &viter, clmd->clothObject->bm, BM_VERTS_OF_MESH, i) {
+      copy_v3_v3(v->co, clmd->clothObject->verts[i].x);
+      cvm[v] = clmd->clothObject->verts[i];
     }
   }
   clmd->clothObject->mvert_num_prev = clmd->clothObject->mvert_num;
-  clmd->clothObject->bm = clmd->clothObject->bm_prev;
 
   if (clmd->clothObject->verts != NULL) {
     MEM_freeN(clmd->clothObject->verts);
@@ -280,9 +280,6 @@ static Mesh *cloth_remeshing_update_cloth_object_bmesh(Object *ob,
   }
 
   if (clmd->clothObject->mvert_num_prev == clmd->clothObject->mvert_num) {
-    clmd->clothObject->bm_prev = BM_mesh_copy(clmd->clothObject->bm);
-    BM_mesh_free(clmd->clothObject->bm);
-    clmd->clothObject->bm = NULL;
     return mesh_result;
   }
 
@@ -369,9 +366,6 @@ static Mesh *cloth_remeshing_update_cloth_object_bmesh(Object *ob,
   clmd->clothObject->bvhselftree = bvhtree_build_from_cloth(clmd, clmd->coll_parms->selfepsilon);
 
   /**/
-  clmd->clothObject->bm_prev = BM_mesh_copy(clmd->clothObject->bm);
-  BM_mesh_free(clmd->clothObject->bm);
-  clmd->clothObject->bm = NULL;
 
   clmd->clothObject->mvert_num_prev = clmd->clothObject->mvert_num;



More information about the Bf-blender-cvs mailing list