Commit: 725b088979b3f34b377a95080b6c02beb4f4379c
Author: ishbosamiya
Date: Mon Aug 5 23:51:08 2019 +0530
Branches: soc-2019-adaptive-cloth
https://developer.blender.org/rB725b088979b3f34b377a95080b6c02beb4f4379c
Cloth: switch cloth flag to be part of clmd directly
This is important so that the flag is not reset every frame rather the
information is actually stored.
===================================================================
M source/blender/blenkernel/BKE_cloth.h
M source/blender/blenkernel/intern/cloth.c
M source/blender/blenkernel/intern/cloth_remeshing.cpp
M source/blender/blenkernel/intern/pointcache.c
M source/blender/makesdna/DNA_modifier_types.h
M source/blender/modifiers/intern/MOD_cloth.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_cloth.h
b/source/blender/blenkernel/BKE_cloth.h
index e9cf041bc74..d5dff1d119b 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -48,11 +48,6 @@ struct ClothSizing;
/* Toggle Cloth Cache */
#define USE_CLOTH_CACHE 1
-typedef enum eClothFlag {
- /* Flag to check if previous frame was read from cache */
- CLOTH_FLAG_PREV_FRAME_READ_CACHE = (1 << 0),
-} eClothFlag;
-
/* Bits to or into the ClothVertex.flags. */
typedef enum eClothVertexFlag {
CLOTH_VERT_FLAG_PINNED = 1,
@@ -103,7 +98,6 @@ typedef struct Cloth {
struct Implicit_Data *implicit; /* our implicit solver connects to this
pointer */
struct EdgeSet *edgeset; /* used for selfcollisions */
int last_frame;
- int flags;
} Cloth;
/**
diff --git a/source/blender/blenkernel/intern/cloth.c
b/source/blender/blenkernel/intern/cloth.c
index a823988f9d3..4e0d969a492 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -473,9 +473,11 @@ Mesh *clothModifier_do(
/* TODO(Ish): clmd->mesh = mesh_result should be done only on the first
frame of reading the
* cache */
- if (clmd->clothObject->flags & CLOTH_FLAG_PREV_FRAME_READ_CACHE) {
+ if (clmd->flags & MOD_CLOTH_FLAG_PREV_FRAME_READ_CACHE) {
+ printf("\nPrevious read from cache\n");
}
else {
+ printf("\nPrevious frame was simulated\n");
clmd->mesh = mesh_result;
}
cache_result = BKE_ptcache_read(&pid, (float)framenr + scene->r.subframe,
can_simulate);
@@ -484,11 +486,12 @@ Mesh *clothModifier_do(
(!can_simulate && cache_result == PTCACHE_READ_OLD)) {
/* TODO(Ish): Need to update mesh_result to be the new mesh that was
generated while reading
* the cache */
+ printf("cache_result: %d\n", cache_result);
mesh_result = clmd->mesh;
BKE_cloth_solver_set_positions(clmd);
cloth_to_mesh(ob, clmd, mesh_result);
- clmd->clothObject->flags |= CLOTH_FLAG_PREV_FRAME_READ_CACHE;
+ clmd->flags |= MOD_CLOTH_FLAG_PREV_FRAME_READ_CACHE;
BKE_ptcache_validate(cache, framenr);
@@ -513,6 +516,8 @@ Mesh *clothModifier_do(
return mesh_result;
}
+ clmd->flags &= ~MOD_CLOTH_FLAG_PREV_FRAME_READ_CACHE;
+
#if USE_CLOTH_CACHE
/* if on second frame, write cache for first frame */
if (cache->simframe == startframe &&
@@ -924,7 +929,6 @@ static int cloth_from_object(
clmd->clothObject->edgeset = NULL;
clmd->clothObject->bm = NULL;
clmd->clothObject->bm_prev = NULL;
- clmd->clothObject->flags = 0;
}
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 18fe975e3f9..0a2eb944eb6 100644
--- a/source/blender/blenkernel/intern/cloth_remeshing.cpp
+++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp
@@ -2568,17 +2568,17 @@ Mesh *cloth_remeshing_step(Depsgraph *depsgraph, Object
*ob, ClothModifierData *
cloth_remeshing_dynamic(depsgraph, ob, clmd, cvm, cd_loop_uv_offset);
}
- printf("totvert: %d totedge: %d totface: %d\n",
- clmd->clothObject->bm->totvert,
- clmd->clothObject->bm->totedge,
- clmd->clothObject->bm->totface);
+ /* printf("totvert: %d totedge: %d totface: %d\n", */
+ /* clmd->clothObject->bm->totvert, */
+ /* clmd->clothObject->bm->totedge, */
+ /* clmd->clothObject->bm->totface); */
Mesh *mesh_result = cloth_remeshing_update_cloth_object_bmesh(ob, clmd);
- printf("mesh: totvert: %d totedge: %d totface: %d\n",
- mesh_result->totvert,
- mesh_result->totedge,
- mesh_result->totpoly);
+ /* printf("mesh: totvert: %d totedge: %d totface: %d\n", */
+ /* mesh_result->totvert, */
+ /* mesh_result->totedge, */
+ /* mesh_result->totpoly); */
cvm.clear();
return mesh_result;
diff --git a/source/blender/blenkernel/intern/pointcache.c
b/source/blender/blenkernel/intern/pointcache.c
index 8c89cfc4de2..4e4cc61ee19 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -2959,15 +2959,23 @@ static int ptcache_read(PTCacheID *pid, int cfra)
mesh->totvert,
mesh->totedge,
mesh->totpoly);
- if (clmd->clothObject->flags & CLOTH_FLAG_PREV_FRAME_READ_CACHE) {
+#if 0
+ 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;
+#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\n",
+ printf("mesh in %s has totvert: %d totedge: %d totface %d\n",
__func__,
mesh->totvert,
mesh->totedge,
@@ -2976,14 +2984,17 @@ static int ptcache_read(PTCacheID *pid, int cfra)
}
int pid_totpoint = pid->totpoint(pid->calldata, cfra);
if (totpoint != pid_totpoint) {
- /* TODO(Ish): need to run the remeshing step before this check */
- char *em;
+#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);
+#else
+ pid->error(pid->calldata, "Number of points in cache does not match
mesh");
+#endif
totpoint = MIN2(totpoint, pid_totpoint);
}
}
diff --git a/source/blender/makesdna/DNA_modifier_types.h
b/source/blender/makesdna/DNA_modifier_types.h
index fd3c3c44497..6aea61a8970 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -732,6 +732,9 @@ typedef struct ClothModifierData {
struct Object *ob;
struct Mesh *mesh;
+ int flags;
+ char _pad[4];
+
/* XXX nasty hack, remove once hair can be separated from cloth modifier
data */
struct ClothHairData *hairdata;
/* grid geometry values of hair continuum */
@@ -743,6 +746,11 @@ typedef struct ClothModifierData {
struct ClothSolverResult *solver_result;
} ClothModifierData;
+enum {
+ /* Flag to check if previous frame was read from cache */
+ MOD_CLOTH_FLAG_PREV_FRAME_READ_CACHE = (1 << 0),
+};
+
typedef struct CollisionModifierData {
ModifierData modifier;
diff --git a/source/blender/modifiers/intern/MOD_cloth.c
b/source/blender/modifiers/intern/MOD_cloth.c
index 948dd0b9f4a..d0a32f58d08 100644
--- a/source/blender/modifiers/intern/MOD_cloth.c
+++ b/source/blender/modifiers/intern/MOD_cloth.c
@@ -67,6 +67,7 @@ static void initData(ModifierData *md)
clmd->coll_parms = MEM_callocN(sizeof(ClothCollSettings), "cloth coll
parms");
#if USE_CLOTH_CACHE
clmd->point_cache = BKE_ptcache_add(&clmd->ptcaches);
+ clmd->flags = 0;
#endif
/* check for alloc failing */
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs