[Bf-blender-cvs] [4dd125c] wiggly-widgets: Adjustments to bone face map handling

Julian Eisel noreply at git.blender.org
Tue Mar 8 18:30:45 CET 2016


Commit: 4dd125cd8ea9ae189c9d40bd9fccee8dd3f18ab9
Author: Julian Eisel
Date:   Tue Mar 8 18:28:57 2016 +0100
Branches: wiggly-widgets
https://developer.blender.org/rB4dd125cd8ea9ae189c9d40bd9fccee8dd3f18ab9

Adjustments to bone face map handling

Making it work for copying bones, proxies, correct id user handling, etc.

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

M	source/blender/blenkernel/intern/action.c
M	source/blender/blenkernel/intern/armature.c
M	source/blender/blenkernel/intern/library_query.c
M	source/blender/blenkernel/intern/object.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/makesrna/intern/rna_pose.c
M	source/gameengine/Converter/BL_ArmatureObject.cpp

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

diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index b77ae45..b680aaf 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -776,6 +776,14 @@ void BKE_pose_channels_remove(
  */
 void BKE_pose_channel_free_ex(bPoseChannel *pchan, bool do_id_user)
 {
+	if (pchan->fmap_object) {
+		if (do_id_user) {
+			id_us_min(&pchan->fmap_object->id);
+		}
+		pchan->fmap_object = NULL;
+	}
+	pchan->fmap = NULL;
+
 	if (pchan->custom) {
 		if (do_id_user) {
 			id_us_min(&pchan->custom->id);
@@ -917,6 +925,13 @@ void BKE_pose_channel_copy_data(bPoseChannel *pchan, const bPoseChannel *pchan_f
 		pchan->prop = IDP_CopyProperty(pchan_from->prop);
 	}
 
+	/* face map */
+	pchan->fmap_object = pchan_from->fmap_object;
+	pchan->fmap = pchan_from->fmap;
+	if (pchan->fmap_object) {
+		id_us_plus(&pchan->fmap_object->id);
+	}
+
 	/* custom shape */
 	pchan->custom = pchan_from->custom;
 	if (pchan->custom) {
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 54fe989..2f380de 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -1755,11 +1755,19 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected
 			
 			/* copy data in temp back over to the cleaned-out (but still allocated) original channel */
 			*pchan = pchanw;
+			if (pchan->fmap_object) {
+				id_us_plus(&pchan->fmap_object->id);
+			}
 			if (pchan->custom) {
 				id_us_plus(&pchan->custom->id);
 			}
 		}
 		else {
+			pchan->fmap_object = pchanp->fmap_object;
+			pchan->fmap = pchanp->fmap;
+			if (pchan->fmap_object) {
+				id_us_plus(&pchan->fmap_object->id);
+			}
 			/* always copy custom shape */
 			pchan->custom = pchanp->custom;
 			if (pchan->custom) {
diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index f5e17c0..6e9bdbf 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -346,6 +346,7 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
 			if (object->pose) {
 				bPoseChannel *pchan;
 				for (pchan = object->pose->chanbase.first; pchan; pchan = pchan->next) {
+					CALLBACK_INVOKE(pchan->fmap_object, IDWALK_USER);
 					CALLBACK_INVOKE(pchan->custom, IDWALK_USER);
 					BKE_constraints_id_loop(&pchan->constraints, library_foreach_constraintObjectLooper, &data);
 				}
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index b55af88..e481f49 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -577,6 +577,10 @@ void BKE_object_unlink(Main *bmain, Object *ob)
 							cti->flush_constraint_targets(con, &targets, 0);
 					}
 				}
+				if (pchan->fmap_object == ob) {
+					pchan->fmap_object = NULL;
+					pchan->fmap = NULL;
+				}
 				if (pchan->custom == ob)
 					pchan->custom = NULL;
 			}
@@ -1717,10 +1721,11 @@ static void armature_set_id_extern(Object *ob)
 	unsigned int lay = arm->layer_protected;
 	
 	for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
-		if (!(pchan->bone->layer & lay))
+		if (!(pchan->bone->layer & lay)) {
+			id_lib_extern((ID *)pchan->fmap_object);
 			id_lib_extern((ID *)pchan->custom);
+		}
 	}
-			
 }
 
 void BKE_object_copy_proxy_drivers(Object *ob, Object *target)
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 60565ec..2bfc49c 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -9061,6 +9061,7 @@ static void expand_pose(FileData *fd, Main *mainvar, bPose *pose)
 	
 	for (chan = pose->chanbase.first; chan; chan = chan->next) {
 		expand_constraints(fd, mainvar, &chan->constraints);
+		expand_doit(fd, mainvar, chan->fmap_object);
 		expand_doit(fd, mainvar, chan->custom);
 	}
 }
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index b8d76fc..f7f0acc 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -290,10 +290,16 @@ static void rna_PoseChannel_bone_fmap_object_set(PointerRNA *ptr, PointerRNA val
 {
 	bPoseChannel *pchan = (bPoseChannel *)ptr->data;
 
-	pchan->fmap_object = value.data;
-	if (!pchan->fmap_object) {
+	if (pchan->fmap_object) {
+		id_us_min(&pchan->fmap_object->id);
+		pchan->fmap_object = NULL;
+	}
+	else {
 		pchan->fmap = NULL;
 	}
+
+	pchan->fmap_object = value.data;
+	id_us_plus(&pchan->fmap_object->id);
 }
 
 static int rna_PoseChannel_has_ik_get(PointerRNA *ptr)
diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp
index a1819a8..df732fb 100644
--- a/source/gameengine/Converter/BL_ArmatureObject.cpp
+++ b/source/gameengine/Converter/BL_ArmatureObject.cpp
@@ -129,6 +129,9 @@ static void game_copy_pose(bPose **dst, bPose *src, int copy_constraint)
 			BLI_listbase_clear(&pchan->constraints);
 		}
 
+		if (pchan->fmap_object) {
+			id_us_plus(&pchan->fmap_object->id);
+		}
 		if (pchan->custom) {
 			id_us_plus(&pchan->custom->id);
 		}




More information about the Bf-blender-cvs mailing list