[Bf-blender-cvs] [4376bb64054] blender2.8: Multi-Object Pose: Apply Visual Transforms operator

Joshua Leung noreply at git.blender.org
Tue Apr 24 14:32:04 CEST 2018


Commit: 4376bb64054cb8de0b71f85d4faa832d4ec736cd
Author: Joshua Leung
Date:   Mon Apr 23 15:28:03 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB4376bb64054cb8de0b71f85d4faa832d4ec736cd

Multi-Object Pose: Apply Visual Transforms operator

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

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

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

diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c
index d0faa3dd4f9..030a5b398bb 100644
--- a/source/blender/editors/armature/pose_transform.c
+++ b/source/blender/editors/armature/pose_transform.c
@@ -223,38 +223,38 @@ void POSE_OT_armature_apply(wmOperatorType *ot)
 /* set the current pose as the restpose */
 static int pose_visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op))
 {
-	Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object
-
-	/* don't check if editmode (should be done by caller) */
-	if (ob->type != OB_ARMATURE)
-		return OPERATOR_CANCELLED;
+	ViewLayer *view_layer = CTX_data_view_layer(C);
 
-	/* loop over all selected pchans
-	 *
-	 * TODO, loop over children before parents if multiple bones
-	 * at once are to be predictable*/
-	CTX_DATA_BEGIN(C, bPoseChannel *, pchan, selected_pose_bones)
+	FOREACH_OBJECT_IN_MODE_BEGIN(view_layer, OB_MODE_POSE, ob)
 	{
-		float delta_mat[4][4];
-		
-		/* chan_mat already contains the delta transform from rest pose to pose-mode pose
-		 * as that is baked into there so that B-Bones will work. Once we've set this as the
-		 * new raw-transform components, don't recalc the poses yet, otherwise IK result will 
-		 * change, thus changing the result we may be trying to record.
-		 */
-		/* XXX For some reason, we can't use pchan->chan_mat here, gives odd rotation/offset (see T38251).
-		 *     Using pchan->pose_mat and bringing it back in bone space seems to work as expected!
-		 */
-		BKE_armature_mat_pose_to_bone(pchan, pchan->pose_mat, delta_mat);
+		/* loop over all selected pchans
+		 *
+		 * TODO, loop over children before parents if multiple bones
+		 * at once are to be predictable*/
+		CTX_DATA_BEGIN(C, bPoseChannel *, pchan, selected_pose_bones)
+		{
+			float delta_mat[4][4];
+			
+			/* chan_mat already contains the delta transform from rest pose to pose-mode pose
+			 * as that is baked into there so that B-Bones will work. Once we've set this as the
+			 * new raw-transform components, don't recalc the poses yet, otherwise IK result will 
+			 * change, thus changing the result we may be trying to record.
+			 */
+			/* XXX For some reason, we can't use pchan->chan_mat here, gives odd rotation/offset (see T38251).
+			 *     Using pchan->pose_mat and bringing it back in bone space seems to work as expected!
+			 */
+			BKE_armature_mat_pose_to_bone(pchan, pchan->pose_mat, delta_mat);
+			
+			BKE_pchan_apply_mat4(pchan, delta_mat, true);
+		}
+		CTX_DATA_END;
 		
-		BKE_pchan_apply_mat4(pchan, delta_mat, true);
-	}
-	CTX_DATA_END;
-	
-	DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+		DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
 
-	/* note, notifier might evolve */
-	WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
+		/* note, notifier might evolve */
+		WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
+	}
+	FOREACH_OBJECT_IN_MODE_END;
 
 	return OPERATOR_FINISHED;
 }



More information about the Bf-blender-cvs mailing list