diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-02-03 23:08:30 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-02-03 23:16:20 +0300 |
commit | a66a54c06d414a7d70b8ad13f683b6f5e1874e68 (patch) | |
tree | c651f56b78c286d5da2c4395ae37238574ea1ce4 | |
parent | 37a08ae5c569fd6f946bcf7d999a33d0901e24eb (diff) |
New Hook's now use the objects center
When adding a hook to an existing selected object/bone,
Use the location for the hook (instead of the selected vertices).
-rw-r--r-- | source/blender/editors/object/object_hook.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 9f9a647c9f1..1d764ced524 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -503,6 +503,15 @@ static int add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *ob unit_m4(pose_mat); + invert_m4_m4(obedit->imat, obedit->obmat); + if (mode == OBJECT_ADDHOOK_NEWOB) { + /* pass */ + } + else { + /* may overwrite with pose-bone location, below */ + mul_v3_m4v3(cent, obedit->imat, ob->obmat[3]); + } + if (mode == OBJECT_ADDHOOK_SELOB_BONE) { bArmature *arm = ob->data; BLI_assert(ob->type == OB_ARMATURE); @@ -514,6 +523,8 @@ static int add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *ob pchan_act = BKE_pose_channel_active(ob); if (LIKELY(pchan_act)) { invert_m4_m4(pose_mat, pchan_act->pose_mat); + mul_v3_m4v3(cent, ob->obmat, pchan_act->pose_mat[3]); + mul_v3_m4v3(cent, obedit->imat, cent); } } else { @@ -521,6 +532,9 @@ static int add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *ob } } + copy_v3_v3(hmd->cent, cent); + + /* matrix calculus */ /* vert x (obmat x hook->imat) x hook->obmat x ob->imat */ /* (parentinv ) */ |