From 59f9a5e6ac6f5bff914204ef299cba27bb5016eb Mon Sep 17 00:00:00 2001 From: Robert Sheldon Date: Thu, 15 Jul 2021 15:58:34 +0200 Subject: Fix T88188: Allow keyframing vertex mass in cloth sim Update vertex weights between simulation steps if they have changed. This allows for animated vertex weights in the cloth sim. Reviewed By: Sebastian Parborg Differential Revision: http://developer.blender.org/D11640 --- source/blender/blenkernel/intern/cloth.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern/cloth.c') diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 8678a659c0a..0fa58a74f2b 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -262,17 +262,19 @@ static bool do_init_cloth(Object *ob, ClothModifierData *clmd, Mesh *result, int static int do_step_cloth( Depsgraph *depsgraph, Object *ob, ClothModifierData *clmd, Mesh *result, int framenr) { + /* simulate 1 frame forward */ ClothVertex *verts = NULL; Cloth *cloth; ListBase *effectors = NULL; MVert *mvert; unsigned int i = 0; int ret = 0; + bool vert_mass_changed = false; - /* simulate 1 frame forward */ cloth = clmd->clothObject; verts = cloth->verts; mvert = result->mvert; + vert_mass_changed = verts->mass != clmd->sim_parms->mass; /* force any pinned verts to their constrained location. */ for (i = 0; i < clmd->clothObject->mvert_num; i++, verts++) { @@ -283,6 +285,11 @@ static int do_step_cloth( /* Get the current position. */ copy_v3_v3(verts->xconst, mvert[i].co); mul_m4_v3(ob->obmat, verts->xconst); + + if (vert_mass_changed) { + verts->mass = clmd->sim_parms->mass; + SIM_mass_spring_set_implicit_vertex_mass(cloth->implicit, i, verts->mass); + } } effectors = BKE_effectors_create(depsgraph, ob, NULL, clmd->sim_parms->effector_weights, false); -- cgit v1.2.3