[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57843] trunk/blender/source/blender/ editors/object/object_hook.c: fix [#35901] Hooks on armature bones are calculated in wrong space

Campbell Barton ideasman42 at gmail.com
Fri Jun 28 08:00:38 CEST 2013


Revision: 57843
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57843
Author:   campbellbarton
Date:     2013-06-28 06:00:38 +0000 (Fri, 28 Jun 2013)
Log Message:
-----------
fix [#35901] Hooks on armature bones are calculated in wrong space

Modified Paths:
--------------
    trunk/blender/source/blender/editors/object/object_hook.c

Modified: trunk/blender/source/blender/editors/object/object_hook.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_hook.c	2013-06-28 05:39:05 UTC (rev 57842)
+++ trunk/blender/source/blender/editors/object/object_hook.c	2013-06-28 06:00:38 UTC (rev 57843)
@@ -460,6 +460,7 @@
 	ModifierData *md = NULL;
 	HookModifierData *hmd = NULL;
 	float cent[3];
+	float pose_mat[4][4];
 	int tot, ok, *indexar;
 	char name[MAX_NAME];
 	
@@ -494,11 +495,20 @@
 	hmd->totindex = tot;
 	BLI_strncpy(hmd->name, name, sizeof(hmd->name));
 	
+	unit_m4(pose_mat);
+
 	if (mode == OBJECT_ADDHOOK_SELOB_BONE) {
 		bArmature *arm = ob->data;
 		BLI_assert(ob->type == OB_ARMATURE);
 		if (arm->act_bone) {
+			bPoseChannel *pchan_act;
+
 			BLI_strncpy(hmd->subtarget, arm->act_bone->name, sizeof(hmd->subtarget));
+
+			pchan_act = BKE_pose_channel_active(ob);
+			if (LIKELY(pchan_act)) {
+				invert_m4_m4(pose_mat, pchan_act->pose_mat);
+			}
 		}
 		else {
 			BKE_report(reports, RPT_WARNING, "Armature has no active object bone");
@@ -512,7 +522,7 @@
 	
 	invert_m4_m4(ob->imat, ob->obmat);
 	/* apparently this call goes from right to left... */
-	mul_serie_m4(hmd->parentinv, ob->imat, obedit->obmat, NULL,
+	mul_serie_m4(hmd->parentinv, pose_mat, ob->imat, obedit->obmat,
 	             NULL, NULL, NULL, NULL, NULL);
 	
 	DAG_relations_tag_update(bmain);




More information about the Bf-blender-cvs mailing list