[Bf-blender-cvs] [4b3539ec600] soc-2019-adaptive-cloth: Cloth: initial steps towards dynamic caching
ishbosamiya
noreply at git.blender.org
Fri Aug 2 19:27:01 CEST 2019
Commit: 4b3539ec6009afa9736b85a3b8229b873a7910a6
Author: ishbosamiya
Date: Fri Aug 2 18:31:52 2019 +0530
Branches: soc-2019-adaptive-cloth
https://developer.blender.org/rB4b3539ec6009afa9736b85a3b8229b873a7910a6
Cloth: initial steps towards dynamic caching
===================================================================
M source/blender/blenkernel/BKE_cloth_remeshing.h
M source/blender/blenkernel/BKE_pointcache.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
===================================================================
diff --git a/source/blender/blenkernel/BKE_cloth_remeshing.h b/source/blender/blenkernel/BKE_cloth_remeshing.h
index c3b1c5506bb..f65cd6d1c9e 100644
--- a/source/blender/blenkernel/BKE_cloth_remeshing.h
+++ b/source/blender/blenkernel/BKE_cloth_remeshing.h
@@ -37,7 +37,11 @@ struct ClothSizing;
extern "C" {
#endif
-Mesh *cloth_remeshing_step(Depsgraph *depsgraph, Object *ob, ClothModifierData *clmd, Mesh *mesh);
+struct Mesh *cloth_remeshing_step(struct Depsgraph *depsgraph,
+ struct Object *ob,
+ struct ClothModifierData *clmd,
+ struct Mesh *mesh);
+CustomData_MeshMasks cloth_remeshing_get_cd_mesh_masks(void);
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h
index 6ce60081f5b..df360403b94 100644
--- a/source/blender/blenkernel/BKE_pointcache.h
+++ b/source/blender/blenkernel/BKE_pointcache.h
@@ -86,6 +86,8 @@ struct Scene;
struct SmokeModifierData;
struct SoftBody;
struct ViewLayer;
+struct Mesh;
+struct Depsgraph;
struct OpenVDBReader;
struct OpenVDBWriter;
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index c624d286da8..d690a67d0e6 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -397,6 +397,8 @@ static Mesh *do_step_cloth(
Mesh *clothModifier_do(
ClothModifierData *clmd, Depsgraph *depsgraph, Scene *scene, Object *ob, Mesh *mesh)
{
+ clmd->depsgraph = depsgraph;
+ clmd->ob = ob;
Mesh *mesh_result = NULL;
BKE_id_copy_ex(NULL, (ID *)mesh, (ID **)&mesh_result, LIB_ID_COPY_LOCALIZE);
#if USE_CLOTH_CACHE
diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp
index e4c18c706b9..18fe975e3f9 100644
--- a/source/blender/blenkernel/intern/cloth_remeshing.cpp
+++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp
@@ -86,7 +86,7 @@ class ClothPlane {
};
#define REMESHING_DATA_DEBUG 0 /* split and collapse edge count */
-#define COLLAPSE_EDGES_DEBUG 1
+#define COLLAPSE_EDGES_DEBUG 0
#define FACE_SIZING_DEBUG 0
#define FACE_SIZING_DEBUG_COMP 0
#define FACE_SIZING_DEBUG_OBS 0
@@ -172,7 +172,7 @@ static void cloth_remeshing_edge_face_pair(BMEdge *e, BMFace **r_f1, BMFace **r_
static void cloth_remeshing_uv_of_vert_in_edge(BMesh *bm, BMEdge *e, BMVert *v, float r_uv[2]);
static bool cloth_remeshing_edge_label_test(BMEdge *e);
-static CustomData_MeshMasks cloth_remeshing_get_cd_mesh_masks(void)
+CustomData_MeshMasks cloth_remeshing_get_cd_mesh_masks(void)
{
CustomData_MeshMasks cddata_masks;
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 9f575c4726e..cd2caf3a837 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -54,6 +54,7 @@
#include "BKE_appdir.h"
#include "BKE_anim.h"
#include "BKE_cloth.h"
+#include "BKE_cloth_remeshing.h"
#include "BKE_collection.h"
#include "BKE_dynamicpaint.h"
#include "BKE_global.h"
@@ -66,6 +67,7 @@
#include "BKE_scene.h"
#include "BKE_smoke.h"
#include "BKE_softbody.h"
+#include "BKE_mesh.h"
#include "BIK_api.h"
@@ -536,6 +538,13 @@ static void ptcache_cloth_read(
PTCACHE_DATA_TO(data, BPHYS_DATA_VELOCITY, 0, vert->v);
PTCACHE_DATA_TO(data, BPHYS_DATA_XCONST, 0, vert->xconst);
}
+ /* TODO(Ish): add the remeshing step here, so that the mesh has been updated with the correct
+ * number of vertices for the next frame */
+ Object *ob = clmd->ob;
+ struct Depsgraph *depsgraph = clmd->depsgraph;
+ CustomData_MeshMasks cddata_masks = cloth_remeshing_get_cd_mesh_masks();
+ struct Mesh *mesh = BKE_mesh_from_bmesh_for_eval_nomain(clmd->clothObject->bm, &cddata_masks);
+ cloth_remeshing_step(depsgraph, ob, clmd, mesh);
}
static void ptcache_cloth_interpolate(
int index, void *cloth_v, void **data, float cfra, float cfra1, float cfra2, float *old_data)
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index a81bff60146..edff4bbae47 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -728,6 +728,8 @@ typedef struct ClothModifierData {
/** Definition is in DNA_object_force_types.h. */
struct PointCache *point_cache;
struct ListBase ptcaches;
+ struct Depsgraph *depsgraph;
+ struct Object *ob;
/* XXX nasty hack, remove once hair can be separated from cloth modifier data */
struct ClothHairData *hairdata;
More information about the Bf-blender-cvs
mailing list