Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorishbosamiya <ishbosamiya@gmail.com>2019-08-06 14:30:16 +0300
committerishbosamiya <ishbosamiya@gmail.com>2019-08-06 14:30:16 +0300
commitdffa1972afa20c803dde97426b0e18c6c242c5da (patch)
tree9f2f72022fec3c38c6a4a6a65fb1c66c2bdaaf22
parent725b088979b3f34b377a95080b6c02beb4f4379c (diff)
Cloth: try storing localized mesh
-rw-r--r--source/blender/blenkernel/intern/cloth.c33
-rw-r--r--source/blender/blenkernel/intern/pointcache.c15
2 files changed, 32 insertions, 16 deletions
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);