[Bf-blender-cvs] [dffa1972afa] soc-2019-adaptive-cloth: Cloth: try storing localized mesh

ishbosamiya noreply at git.blender.org
Tue Aug 6 20:32:52 CEST 2019


Commit: dffa1972afa20c803dde97426b0e18c6c242c5da
Author: ishbosamiya
Date:   Tue Aug 6 17:00:16 2019 +0530
Branches: soc-2019-adaptive-cloth
https://developer.blender.org/rBdffa1972afa20c803dde97426b0e18c6c242c5da

Cloth: try storing localized mesh

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

M	source/blender/blenkernel/intern/cloth.c
M	source/blender/blenkernel/intern/pointcache.c

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

diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 4e0d969a492..5685259d9d3 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -473,13 +473,30 @@ Mesh *clothModifier_do(
 
   /* TODO(Ish): clmd->mesh = mesh_result should be done only on the first frame of reading the
    * cache */
+  if (clmd->mesh) {
+    printf("\nclmd->mesh in %s before has totvert: %d totedge: %d totface: %d\n",
+           __func__,
+           clmd->mesh->totvert,
+           clmd->mesh->totedge,
+           clmd->mesh->totpoly);
+  }
+  else {
+    printf("\n");
+  }
   if (clmd->flags & MOD_CLOTH_FLAG_PREV_FRAME_READ_CACHE) {
-    printf("\nPrevious read from cache\n");
+    printf("Previous read from cache\n");
   }
   else {
-    printf("\nPrevious frame was simulated\n");
+    printf("Previous frame was simulated\n");
     clmd->mesh = mesh_result;
   }
+  if (clmd->mesh) {
+    printf("clmd->mesh in %s after has totvert: %d totedge: %d totface: %d\n",
+           __func__,
+           clmd->mesh->totvert,
+           clmd->mesh->totedge,
+           clmd->mesh->totpoly);
+  }
   cache_result = BKE_ptcache_read(&pid, (float)framenr + scene->r.subframe, can_simulate);
 
   if (cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED ||
@@ -572,9 +589,9 @@ void cloth_free_modifier(ClothModifierData *clmd)
   if (!clmd) {
     return;
   }
-  clmd->depsgraph = NULL;
-  clmd->ob = NULL;
-  clmd->mesh = NULL;
+  /* clmd->depsgraph = NULL; */
+  /* clmd->ob = NULL; */
+  /* clmd->mesh = NULL; */
 
   cloth = clmd->clothObject;
 
@@ -664,9 +681,9 @@ void cloth_free_modifier_extern(ClothModifierData *clmd)
     return;
   }
 
-  clmd->depsgraph = NULL;
-  clmd->ob = NULL;
-  clmd->mesh = NULL;
+  /* clmd->depsgraph = NULL; */
+  /* clmd->ob = NULL; */
+  /* clmd->mesh = NULL; */
 
   cloth = clmd->clothObject;
 
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 4e4cc61ee19..eda73f19cd4 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -2954,7 +2954,7 @@ static int ptcache_read(PTCacheID *pid, int cfra)
         Object *ob = clmd->ob;
         Depsgraph *depsgraph = clmd->depsgraph;
         Mesh *mesh = clmd->mesh;
-        printf("mesh in %s has totvert: %d totedge: %d totface %d\n",
+        printf("mesh in %s before remeshing has totvert: %d totedge: %d totface %d\n",
                __func__,
                mesh->totvert,
                mesh->totedge,
@@ -2972,14 +2972,13 @@ static int ptcache_read(PTCacheID *pid, int cfra)
 #endif
         Mesh *mesh_result = cloth_remeshing_step(depsgraph, ob, clmd, mesh);
         if (clmd->mesh && mesh_result) {
-          BKE_mesh_free(clmd->mesh);
-          clmd->mesh = mesh_result;
-          mesh = clmd->mesh;
-          printf("mesh in %s has totvert: %d totedge: %d totface %d\n",
+          /* BKE_mesh_free(clmd->mesh); */
+          BKE_id_copy_ex(NULL, (ID *)mesh_result, (ID **)&clmd->mesh, LIB_ID_COPY_LOCALIZE);
+          printf("mesh in %s after remeshing has totvert: %d totedge: %d totface %d\n",
                  __func__,
-                 mesh->totvert,
-                 mesh->totedge,
-                 mesh->totpoly);
+                 clmd->mesh->totvert,
+                 clmd->mesh->totedge,
+                 clmd->mesh->totpoly);
         }
       }
       int pid_totpoint = pid->totpoint(pid->calldata, cfra);



More information about the Bf-blender-cvs mailing list