[Bf-blender-cvs] [04708184111] master: Fix T59848: precisely represent the dependencies of Armature modifier.

Alexander Gavrilov noreply at git.blender.org
Mon Apr 29 19:57:39 CEST 2019


Commit: 047081841113da73d7a13886218f5a56cfc62de6
Author: Alexander Gavrilov
Date:   Wed Apr 24 16:24:53 2019 +0300
Branches: master
https://developer.blender.org/rB047081841113da73d7a13886218f5a56cfc62de6

Fix T59848: precisely represent the dependencies of Armature modifier.

When the modifier uses vertex groups, the set of the bones it actually
needs is precisely defined by the set of the group names. If envelopes
are enabled, this refinement is not available, because any bone can
potentially be used.

This can be used in the dependency graph construction to allow objects
deformed by a part of the armature to be used in constraints on other
bones, e.g. for placing cartoon-style face elements on top of the body
mesh via Shrinkwrap constraints.

Since the list of vertex group names is now used as an input by
the dependency graph, adding/removing/renaming groups should now
be triggering a graph rebuild.

Differential Revision: https://developer.blender.org/D4715

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

M	source/blender/editors/gpencil/gpencil_armature.c
M	source/blender/editors/gpencil/gpencil_brush.c
M	source/blender/editors/object/object_data_transfer.c
M	source/blender/editors/object/object_vgroup.c
M	source/blender/editors/physics/dynamicpaint_ops.c
M	source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
M	source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/makesrna/intern/rna_object.c
M	source/blender/modifiers/intern/MOD_armature.c

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

diff --git a/source/blender/editors/gpencil/gpencil_armature.c b/source/blender/editors/gpencil/gpencil_armature.c
index c433b374d4c..6ad89d2e38d 100644
--- a/source/blender/editors/gpencil/gpencil_armature.c
+++ b/source/blender/editors/gpencil/gpencil_armature.c
@@ -480,6 +480,8 @@ static void gpencil_object_vgroup_calc_from_armature(const bContext *C,
      */
     gpencil_add_verts_to_dgroups(C, ob, ob_arm, ratio, decay);
   }
+
+  DEG_relations_tag_update(CTX_data_main(C));
 }
 
 bool ED_gpencil_add_armature_weights(
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index 1af01850707..8225e9bae78 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -88,6 +88,7 @@ typedef struct tGP_BrushEditData {
   /* Current editor/region/etc. */
   /* NOTE: This stuff is mainly needed to handle 3D view projection stuff... */
   Depsgraph *depsgraph;
+  struct Main *bmain;
   Scene *scene;
   Object *object;
 
@@ -907,6 +908,7 @@ static bool gp_brush_weight_apply(
   if (gso->vrgroup == -1) {
     if (gso->object) {
       BKE_object_defgroup_add(gso->object);
+      DEG_relations_tag_update(gso->bmain);
       gso->vrgroup = 0;
     }
   }
@@ -1220,6 +1222,7 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op)
   op->customdata = gso;
 
   gso->depsgraph = CTX_data_depsgraph(C);
+  gso->bmain = CTX_data_main(C);
   /* store state */
   gso->settings = gpsculpt_get_settings(scene);
   gso->gp_brush = gpsculpt_get_brush(scene, is_weight_mode);
diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c
index 313ff130e25..690bc270605 100644
--- a/source/blender/editors/object/object_data_transfer.c
+++ b/source/blender/editors/object/object_data_transfer.c
@@ -842,6 +842,7 @@ static int datalayout_transfer_exec(bContext *C, wmOperator *op)
     BLI_freelistN(&ctx_objects);
   }
 
+  DEG_relations_tag_update(CTX_data_main(C));
   WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL);
 
   return OPERATOR_FINISHED;
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index 3f3932e5041..d43ec578478 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -58,6 +58,7 @@
 #include "BKE_lattice.h"
 
 #include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
 
 #include "DNA_armature_types.h"
 #include "RNA_access.h"
@@ -2702,6 +2703,7 @@ static int vertex_group_add_exec(bContext *C, wmOperator *UNUSED(op))
   Object *ob = ED_object_context(C);
 
   BKE_object_defgroup_add(ob);
+  DEG_relations_tag_update(CTX_data_main(C));
   DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
   WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data);
   WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -2739,6 +2741,7 @@ static int vertex_group_remove_exec(bContext *C, wmOperator *op)
   }
 
   DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+  DEG_relations_tag_update(CTX_data_main(C));
   WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data);
   WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
 
@@ -2942,6 +2945,7 @@ static int vertex_group_copy_exec(bContext *C, wmOperator *UNUSED(op))
 
   vgroup_duplicate(ob);
   DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+  DEG_relations_tag_update(CTX_data_main(C));
   WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
   WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data);
 
@@ -3472,6 +3476,7 @@ static int vertex_group_mirror_exec(bContext *C, wmOperator *op)
   ED_mesh_report_mirror(op, totmirr, totfail);
 
   DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+  DEG_relations_tag_update(CTX_data_main(C));
   WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
   WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
 
@@ -3560,6 +3565,7 @@ static int vertex_group_copy_to_selected_exec(bContext *C, wmOperator *op)
     if (obact != ob) {
       if (ED_vgroup_array_copy(ob, obact)) {
         DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+        DEG_relations_tag_update(CTX_data_main(C));
         WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob);
         changed_tot++;
       }
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c
index 63036e158bc..cb8fe262730 100644
--- a/source/blender/editors/physics/dynamicpaint_ops.c
+++ b/source/blender/editors/physics/dynamicpaint_ops.c
@@ -255,11 +255,13 @@ static int output_toggle_exec(bContext *C, wmOperator *op)
     else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) {
       if (!exists) {
         BKE_object_defgroup_add_name(ob, name);
+        DEG_relations_tag_update(CTX_data_main(C));
       }
       else {
         bDeformGroup *defgroup = defgroup_find_name(ob, name);
         if (defgroup) {
           BKE_object_defgroup_remove(ob, defgroup);
+          DEG_relations_tag_update(CTX_data_main(C));
         }
       }
     }
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
index 29d150c44fe..c1c2964156f 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
@@ -130,6 +130,7 @@ static int weight_from_bones_exec(bContext *C, wmOperator *op)
       op->reports, depsgraph, scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X));
 
   DEG_id_tag_update(&me->id, 0);
+  DEG_relations_tag_update(CTX_data_main(C));
   WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
 
   return OPERATOR_FINISHED;
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
index 88aed201b48..c71315872f6 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
@@ -41,6 +41,8 @@
 #include "BKE_report.h"
 #include "BKE_object.h"
 
+#include "DEG_depsgraph_build.h"
+
 /* Only for blend modes. */
 #include "IMB_imbuf.h"
 
@@ -93,6 +95,7 @@ bool ED_wpaint_ensure_data(bContext *C,
           bDeformGroup *dg = defgroup_find_name(ob, pchan->name);
           if (dg == NULL) {
             dg = BKE_object_defgroup_add_name(ob, pchan->name); /* sets actdef */
+            DEG_relations_tag_update(CTX_data_main(C));
           }
           else {
             int actdef = 1 + BLI_findindex(&ob->defbase, dg);
@@ -105,6 +108,7 @@ bool ED_wpaint_ensure_data(bContext *C,
   }
   if (BLI_listbase_is_empty(&ob->defbase)) {
     BKE_object_defgroup_add(ob);
+    DEG_relations_tag_update(CTX_data_main(C));
   }
 
   /* ensure we don't try paint onto an invalid group */
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 204f2b051ed..8a63bf1a619 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -2119,13 +2119,15 @@ static void rna_def_modifier_armature(BlenderRNA *brna)
 
   prop = RNA_def_property(srna, "use_bone_envelopes", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_ENVELOPE);
+  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
   RNA_def_property_ui_text(prop, "Use Bone Envelopes", "Bind Bone envelopes to armature modifier");
-  RNA_def_property_update(prop, 0, "rna_Modifier_update");
+  RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
 
   prop = RNA_def_property(srna, "use_vertex_groups", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_VGROUP);
+  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
   RNA_def_property_ui_text(prop, "Use Vertex Groups", "Bind vertex groups to armature modifier");
-  RNA_def_property_update(prop, 0, "rna_Modifier_update");
+  RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
 
   prop = RNA_def_property(srna, "use_deform_preserve_volume", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_QUATERNION);
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index aed7b83e34f..219445f629f 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -381,6 +381,12 @@ void rna_Object_internal_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene),
   WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->id.data);
 }
 
+void rna_Object_internal_update_data_dependency(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+  DEG_relations_tag_update(bmain);
+  rna_Object_internal_update_data(bmain, scene, ptr);
+}
+
 static void rna_Object_active_shape_update(bContext *C, PointerRNA *ptr)
 {
   Object *ob = ptr->id.data;
@@ -1539,16 +1545,20 @@ static void rna_Object_boundbox_get(PointerRNA *ptr, float *values)
   }
 }
 
-static bDeformGroup *rna_Object_vgroup_new(Object *ob, const char *name)
+static bDeformGroup *rna_Object_vgroup_new(Object *ob, Main *bmain, const char *name)
 {
   bDeformGroup *defgroup = BKE_object_defgroup_add_name(ob, name);
 
+  DEG_relations_tag_update(bmain);
   WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
 
   return defgroup;
 }
 
-static void rna_Object_vgroup_remove(Object *ob, ReportList *reports, PointerRNA *defgroup_ptr)
+static void rna_Object_vgroup_remove(Object *ob,
+                                     Main *bmain,
+                                     ReportList *reports,
+                                     PointerRNA *defgroup_ptr)
 {
   bDeformGroup *defgroup = defgroup_ptr->data;
   if (BLI_findindex(&ob->defbase, defgroup) == -1) {
@@ -1563,13 +1573,15 @@ static void rna_Object_vgroup_remove(Object *ob, ReportList *reports, PointerRNA
   BKE_object_defgroup_remove(ob, defgroup);
   RNA_POINTER_INVALIDATE(defgroup_ptr);
 
+  DEG_relations_tag_update(bmain);
   WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
 }
 
-static void rna_Object_vgroup_clear(Object *ob)
+static void rna_Object_vgroup_clear(Object *ob, Main *bmain)
 {
   B

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list