[Bf-blender-cvs] [e4284d06ada] blender2.8: Fix T56899: mesh deform bind does not work.

Brecht Van Lommel noreply at git.blender.org
Wed Sep 26 14:51:34 CEST 2018


Commit: e4284d06ada4f3eeac9c19f987e8b2d8eff47e62
Author: Brecht Van Lommel
Date:   Wed Sep 26 12:46:34 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBe4284d06ada4f3eeac9c19f987e8b2d8eff47e62

Fix T56899: mesh deform bind does not work.

===================================================================

M	source/blender/editors/object/object_modifier.c
M	source/blender/modifiers/intern/MOD_meshdeform.c

===================================================================

diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 43fb3e43e55..4b155642b0e 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -56,6 +56,7 @@
 #include "BKE_context.h"
 #include "BKE_displist.h"
 #include "BKE_DerivedMesh.h"
+#include "BKE_editmesh.h"
 #include "BKE_effect.h"
 #include "BKE_global.h"
 #include "BKE_key.h"
@@ -72,8 +73,8 @@
 #include "BKE_ocean.h"
 #include "BKE_paint.h"
 #include "BKE_particle.h"
+#include "BKE_scene.h"
 #include "BKE_softbody.h"
-#include "BKE_editmesh.h"
 
 #include "DEG_depsgraph.h"
 #include "DEG_depsgraph_build.h"
@@ -1922,9 +1923,9 @@ static bool meshdeform_poll(bContext *C)
 
 static int meshdeform_bind_exec(bContext *C, wmOperator *op)
 {
-	Scene *scene = CTX_data_scene(C);
-	Object *ob = ED_object_active_context(C);
+	Main *bmain = CTX_data_main(C);
 	Depsgraph *depsgraph = CTX_data_depsgraph(C);
+	Object *ob = ED_object_active_context(C);
 	MeshDeformModifierData *mmd = (MeshDeformModifierData *)edit_modifier_property_get(op, ob, eModifierType_MeshDeform);
 
 	if (!mmd)
@@ -1951,36 +1952,23 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op)
 		mmd->totvert = 0;
 		mmd->totcagevert = 0;
 		mmd->totinfluence = 0;
-
-		DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
-		WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
 	}
 	else {
-		DerivedMesh *dm;
 		int mode = mmd->modifier.mode;
-
-		/* force modifier to run, it will call binding routine */
 		mmd->bindfunc = ED_mesh_deform_bind_callback;
 		mmd->modifier.mode |= eModifierMode_Realtime;
 
-		if (ob->type == OB_MESH) {
-			dm = mesh_create_derived_view(depsgraph, scene, ob, 0);
-			dm->release(dm);
-		}
-		else if (ob->type == OB_LATTICE) {
-			BKE_lattice_modifiers_calc(depsgraph, scene, ob);
-		}
-		else if (ob->type == OB_MBALL) {
-			BKE_displist_make_mball(depsgraph, scene, ob);
-		}
-		else if (ELEM(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
-			BKE_displist_make_curveTypes(depsgraph, scene, ob, 0);
-		}
+		/* Force depsgraph update, this will do binding. */
+		DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+		BKE_scene_graph_update_tagged(depsgraph, bmain);
 
 		mmd->bindfunc = NULL;
 		mmd->modifier.mode = mode;
 	}
 
+	DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+	WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
+
 	return OPERATOR_FINISHED;
 }
 
diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c
index 9bfbbc4e44e..aac191bc511 100644
--- a/source/blender/modifiers/intern/MOD_meshdeform.c
+++ b/source/blender/modifiers/intern/MOD_meshdeform.c
@@ -325,11 +325,17 @@ static void meshdeformModifier_do(
 
 		/* progress bar redraw can make this recursive .. */
 		if (!recursive) {
+			/* Write binding data to original modifier. */
 			Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
+			Object *ob_orig = DEG_get_original_object(ob);
+			MeshDeformModifierData *mmd_orig = (MeshDeformModifierData*)modifiers_findByName(ob_orig, mmd->modifier.name);
+
 			recursive = 1;
-			mmd->bindfunc(scene, mmd, cagemesh, (float *)vertexCos, numVerts, cagemat);
+			mmd->bindfunc(scene, mmd_orig, cagemesh, (float *)vertexCos, numVerts, cagemat);
 			recursive = 0;
 		}
+
+		return;
 	}
 
 	/* verify we have compatible weights */



More information about the Bf-blender-cvs mailing list