From 64bdb89abab57c1696accd1989f3213b5e47e841 Mon Sep 17 00:00:00 2001 From: ishbosamiya Date: Sat, 17 Aug 2019 12:04:41 +0530 Subject: Cloth: cache read check for adaptive cloth --- source/blender/blenkernel/intern/cloth.c | 9 +++- source/blender/blenkernel/intern/pointcache.c | 63 +++++++++++++-------------- 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 09e16ffe0fe..50b591949c0 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -425,9 +425,16 @@ Mesh *clothModifier_do( clmd->sim_parms->timescale = 1.0f; #endif + if (!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_ADAPTIVE_REMESHING)) { + printf("Currently no remeshing\n"); + } + else { + printf("Currently remeshing\n"); + } + if (clmd->sim_parms->reset || (clmd->clothObject && mesh_result->totvert != clmd->clothObject->mvert_num && - clmd->sim_parms->flags & ~CLOTH_SIMSETTINGS_FLAG_ADAPTIVE_REMESHING)) { + !(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_ADAPTIVE_REMESHING))) { printf("this is called\n"); clmd->sim_parms->reset = 0; clmd->sim_parms->remeshing_reset = 1; diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 3d8c6a924e4..c8887b2b5bd 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2951,46 +2951,43 @@ static int ptcache_read(PTCacheID *pid, int cfra) if ((pid->data_types & (1 << BPHYS_DATA_INDEX)) == 0) { if (pid->type == PTCACHE_TYPE_CLOTH) { ClothModifierData *clmd = pid->calldata; - Object *ob = clmd->ob; - Depsgraph *depsgraph = clmd->depsgraph; - Mesh *mesh = clmd->mesh; - printf("mesh in %s before remeshing has totvert: %d totedge: %d totface %d\n", - __func__, - mesh->totvert, - mesh->totedge, - mesh->totpoly); + if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_ADAPTIVE_REMESHING) { + Object *ob = clmd->ob; + Depsgraph *depsgraph = clmd->depsgraph; + Mesh *mesh = clmd->mesh; + printf("mesh in %s before remeshing has totvert: %d totedge: %d totface %d\n", + __func__, + mesh->totvert, + mesh->totedge, + mesh->totpoly); #if 1 - if (clmd->flags & MOD_CLOTH_FLAG_PREV_FRAME_READ_CACHE) { - } - else { - clmd->sim_parms->remeshing_reset = 1; - } + if (clmd->flags & MOD_CLOTH_FLAG_PREV_FRAME_READ_CACHE) { + } + else { + clmd->sim_parms->remeshing_reset = 1; + } #else - printf("reset: %d\n", clmd->sim_parms->reset); - printf("remeshing_reset: %d\n", clmd->sim_parms->remeshing_reset); - clmd->sim_parms->remeshing_reset = 1; + printf("reset: %d\n", clmd->sim_parms->reset); + printf("remeshing_reset: %d\n", clmd->sim_parms->remeshing_reset); + clmd->sim_parms->remeshing_reset = 1; #endif - Mesh *mesh_result = cloth_remeshing_step(depsgraph, ob, clmd, mesh); - if (clmd->mesh && mesh_result) { - /* 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__, - clmd->mesh->totvert, - clmd->mesh->totedge, - clmd->mesh->totpoly); + Mesh *mesh_result = cloth_remeshing_step(depsgraph, ob, clmd, mesh); + if (clmd->mesh && mesh_result) { + /* 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__, + clmd->mesh->totvert, + clmd->mesh->totedge, + clmd->mesh->totpoly); + } } } int pid_totpoint = pid->totpoint(pid->calldata, cfra); if (totpoint != pid_totpoint) { -#if 0 - char *em = NULL; - sprintf(em, - "%s memory_cache_totpoint: %d pid_totpoint: %d", - "Number of points in cache does not match mesh", - totpoint, - pid_totpoint); - pid->error(pid->calldata, em); +#if 1 + printf("memory_cache_totpoint: %d pid_totpoint: %d\n", totpoint, pid_totpoint); + pid->error(pid->calldata, "Number of points in cache does not match mesh"); #else pid->error(pid->calldata, "Number of points in cache does not match mesh"); #endif -- cgit v1.2.3