[Bf-blender-cvs] [6bb7f27f324] soc-2019-adaptive-cloth: Cloth: attempt at fixing caching

ishbosamiya noreply at git.blender.org
Fri Aug 9 12:42:29 CEST 2019


Commit: 6bb7f27f324c3a234793aaa8ef04cdbc8533a8f0
Author: ishbosamiya
Date:   Wed Aug 7 18:22:39 2019 +0530
Branches: soc-2019-adaptive-cloth
https://developer.blender.org/rB6bb7f27f324c3a234793aaa8ef04cdbc8533a8f0

Cloth: attempt at fixing caching

clmd->mesh was being changed when it was returned as mesh_result, so now we are creating a local copy of the same.
This is introduced another problem of the mesh not being correct when the playback is stopped. Need to look into this.

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

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 5685259d9d3..a69b8d49dc4 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -490,13 +490,6 @@ Mesh *clothModifier_do(
     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 ||
@@ -505,6 +498,7 @@ Mesh *clothModifier_do(
      * the cache */
     printf("cache_result: %d\n", cache_result);
     mesh_result = clmd->mesh;
+    BKE_id_copy_ex(NULL, (ID *)clmd->mesh, (ID **)&mesh_result, LIB_ID_COPY_LOCALIZE);
     BKE_cloth_solver_set_positions(clmd);
     cloth_to_mesh(ob, clmd, mesh_result);
 
@@ -518,6 +512,13 @@ Mesh *clothModifier_do(
 
 #endif
     clmd->clothObject->last_frame = framenr;
+    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);
+    }
 #if USE_CLOTH_CACHE
     return mesh_result;
   }
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index eda73f19cd4..3d8c6a924e4 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -2959,7 +2959,7 @@ static int ptcache_read(PTCacheID *pid, int cfra)
                mesh->totvert,
                mesh->totedge,
                mesh->totpoly);
-#if 0
+#if 1
         if (clmd->flags & MOD_CLOTH_FLAG_PREV_FRAME_READ_CACHE) {
         }
         else {



More information about the Bf-blender-cvs mailing list