Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-06-28 10:00:38 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-06-28 10:00:38 +0400
commit3370b765ec192cd53421f3f0f8d59ec5765204e9 (patch)
treeac9236083951bccd4736acd889496542ceb857b3 /source/blender/editors/object/object_hook.c
parentaa9ffc0bc28d86eb91b69584903e52da67e86b28 (diff)
fix [#35901] Hooks on armature bones are calculated in wrong space
Diffstat (limited to 'source/blender/editors/object/object_hook.c')
-rw-r--r--source/blender/editors/object/object_hook.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index 04c67b8d3fa..1f0163bc391 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -460,6 +460,7 @@ static int add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *ob
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 @@ static int add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *ob
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 @@ static int add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *ob
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);