[Bf-blender-cvs] [7043f8b815f] blender-v2.83-release: Fix T76416: Armature Deform parenting option doesn't work with Grease Pencil objects

Philipp Oeser noreply at git.blender.org
Wed May 6 12:39:45 CEST 2020


Commit: 7043f8b815f3da10e56668230dee1a438af7e49d
Author: Philipp Oeser
Date:   Tue May 5 13:53:47 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB7043f8b815f3da10e56668230dee1a438af7e49d

Fix T76416: Armature Deform parenting option doesn't work with Grease Pencil objects

If we parent with type `PAR_ARMATURE` (where vertexgroups are already
set up and named correctly according to the corresponding bones), we
still need an armature modifier. This just wasnt added.

In contrast to meshes [which add their armature modifier early in
`ED_object_parent_set`], grease pencil used to do this (adding the
armature modifier) in `ED_gpencil_add_armature_weights`.

Now split ED_gpencil_add_armature_weights in two:
- ED_gpencil_add_armature
- ED_gpencil_add_armature_weights (which calls ED_gpencil_add_armature)
- use ED_gpencil_add_armature for the PAR_ARMATURE case

Maniphest Tasks: T76416

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

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

M	source/blender/editors/gpencil/gpencil_armature.c
M	source/blender/editors/include/ED_gpencil.h
M	source/blender/editors/object/object_relations.c

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

diff --git a/source/blender/editors/gpencil/gpencil_armature.c b/source/blender/editors/gpencil/gpencil_armature.c
index 1528c448c0b..ab8b1a9719b 100644
--- a/source/blender/editors/gpencil/gpencil_armature.c
+++ b/source/blender/editors/gpencil/gpencil_armature.c
@@ -481,8 +481,7 @@ static void gpencil_object_vgroup_calc_from_armature(const bContext *C,
   DEG_relations_tag_update(CTX_data_main(C));
 }
 
-bool ED_gpencil_add_armature_weights(
-    const bContext *C, ReportList *reports, Object *ob, Object *ob_arm, int mode)
+bool ED_gpencil_add_armature(const bContext *C, ReportList *reports, Object *ob, Object *ob_arm)
 {
   Main *bmain = CTX_data_main(C);
   Scene *scene = CTX_data_scene(C);
@@ -516,11 +515,24 @@ bool ED_gpencil_add_armature_weights(
       return false;
     }
   }
+  return true;
+}
+
+bool ED_gpencil_add_armature_weights(
+    const bContext *C, ReportList *reports, Object *ob, Object *ob_arm, int mode)
+{
+  if (ob == NULL) {
+    return false;
+  }
+
+  bool success = ED_gpencil_add_armature(C, reports, ob, ob_arm);
 
   /* add weights */
-  gpencil_object_vgroup_calc_from_armature(C, ob, ob_arm, mode, DEFAULT_RATIO, DEFAULT_DECAY);
+  if (success) {
+    gpencil_object_vgroup_calc_from_armature(C, ob, ob_arm, mode, DEFAULT_RATIO, DEFAULT_DECAY);
+  }
 
-  return true;
+  return success;
 }
 /* ***************** Generate armature weights ************************** */
 static bool gpencil_generate_weights_poll(bContext *C)
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index d63353d3886..1403ae1f3cc 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -178,7 +178,11 @@ bool ED_gpencil_anim_copybuf_paste(struct bAnimContext *ac, const short copy_mod
 int ED_gpencil_session_active(void);
 int ED_undo_gpencil_step(struct bContext *C, int step, const char *name);
 
-/* ------------ Grease-Pencil Armature weights ------------------ */
+/* ------------ Grease-Pencil Armature ------------------ */
+bool ED_gpencil_add_armature(const struct bContext *C,
+                             struct ReportList *reports,
+                             struct Object *ob,
+                             struct Object *ob_arm);
 bool ED_gpencil_add_armature_weights(const struct bContext *C,
                                      struct ReportList *reports,
                                      struct Object *ob,
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 256e32c7bfc..759af18ed2b 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -899,7 +899,10 @@ bool ED_object_parent_set(ReportList *reports,
         invert_m4_m4(ob->parentinv, workob.obmat);
       }
       else if (pararm && (ob->type == OB_GPENCIL) && (par->type == OB_ARMATURE)) {
-        if (partype == PAR_ARMATURE_NAME) {
+        if (partype == PAR_ARMATURE) {
+          ED_gpencil_add_armature(C, reports, ob, par);
+        }
+        else if (partype == PAR_ARMATURE_NAME) {
           ED_gpencil_add_armature_weights(C, reports, ob, par, GP_PAR_ARMATURE_NAME);
         }
         else if ((partype == PAR_ARMATURE_AUTO) || (partype == PAR_ARMATURE_ENVELOPE)) {



More information about the Bf-blender-cvs mailing list