[Bf-blender-cvs] [7088c211a50] greasepencil-object: Rename bone if Armature modifier

Antonioya noreply at git.blender.org
Thu Aug 23 10:34:22 CEST 2018


Commit: 7088c211a50a16760763452227d439e86fb8bcd9
Author: Antonioya
Date:   Mon Aug 20 17:28:11 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rB7088c211a50a16760763452227d439e86fb8bcd9

Rename bone if Armature modifier

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

M	source/blender/editors/armature/armature_naming.c

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

diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c
index 350dee07a2c..3ea20e6fde3 100644
--- a/source/blender/editors/armature/armature_naming.c
+++ b/source/blender/editors/armature/armature_naming.c
@@ -34,6 +34,7 @@
 #include "DNA_armature_types.h"
 #include "DNA_constraint_types.h"
 #include "DNA_object_types.h"
+#include "DNA_gpencil_modifier_types.h"
 
 #include "BLI_blenlib.h"
 #include "BLI_ghash.h"
@@ -51,6 +52,7 @@
 #include "BKE_global.h"
 #include "BKE_main.h"
 #include "BKE_modifier.h"
+#include "BKE_gpencil_modifier.h"
 
 #include "DEG_depsgraph.h"
 
@@ -265,6 +267,37 @@ void ED_armature_bone_rename(Main *bmain, bArmature *arm, const char *oldnamep,
 						break;
 				}
 			}
+
+			/* fix grease pencil modifiers and vertex groups */
+			if (ob->type == OB_GPENCIL) {
+				GpencilModifierData *gp_md = BKE_gpencil_modifiers_findByType(ob, eGpencilModifierType_Armature);
+				if (gp_md) {
+					ArmatureGpencilModifierData *mmd = (ArmatureGpencilModifierData *)gp_md;
+					if (mmd->object && mmd->object->data == arm) {
+						bDeformGroup *dg = defgroup_find_name(ob, oldname);
+						if (dg) {
+							BLI_strncpy(dg->name, newname, MAXBONENAME);
+						}
+					}
+				}
+
+				for (gp_md = ob->greasepencil_modifiers.first; gp_md; gp_md = gp_md->next) {
+					switch (gp_md->type) {
+						case eGpencilModifierType_Hook:
+						{
+							HookGpencilModifierData *hgp_md = (HookGpencilModifierData *)gp_md;
+							if (hgp_md->object && (hgp_md->object->data == arm)) {
+								if (STREQ(hgp_md->subtarget, oldname))
+									BLI_strncpy(hgp_md->subtarget, newname, MAXBONENAME);
+							}
+							break;
+						}
+						default:
+							break;
+					}
+				}
+			}
+			DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
 		}
 
 		/* Fix all animdata that may refer to this bone - we can't just do the ones attached to objects, since



More information about the Bf-blender-cvs mailing list