From 933ac8db12729327ccd313dea0575ad2eb631fa0 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Mon, 24 Nov 2008 17:48:40 +0000 Subject: [PATCH] Link pole controls to the parent of the bone with the IK constraint. Presumably, this should give better result, but tests where not conclusive. --- source/blender/src/editarmature_retarget.c | 30 +++++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/source/blender/src/editarmature_retarget.c b/source/blender/src/editarmature_retarget.c index 062ca95031f..00cfafad0f5 100644 --- a/source/blender/src/editarmature_retarget.c +++ b/source/blender/src/editarmature_retarget.c @@ -805,15 +805,26 @@ static void RIG_reconnectControlBones(RigGraph *rg) /* constraint targets */ if (cti && cti->get_constraint_targets) { + int target_index; + cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) + for (target_index = 0, ct= targets.first; ct; target_index++, ct= ct->next) { if ((ct->tar == rg->ob) && strcmp(ct->subtarget, ctrl->bone->name) == 0) { /* SET bone link to bone corresponding to pchan */ EditBone *link = BLI_ghash_lookup(rg->bones_map, pchan->name); + /* for pole targets, link to parent bone instead, if possible */ + if (con->type == CONSTRAINT_TYPE_KINEMATIC && target_index == 1) + { + if (link->parent && BLI_ghash_haskey(rg->bones_map, link->parent->name)) + { + link = link->parent; + } + } + found = RIG_parentControl(ctrl, link); } } @@ -1011,14 +1022,12 @@ static void RIG_reconnectControlBones(RigGraph *rg) { if (VecLenf(ctrl->bone->tail, bone->head) < 0.01) { - printf("%s -> %s: TL_HEAD\n", ctrl->bone->name, bone->name); ctrl->tail_mode = TL_HEAD; ctrl->link_tail = bone; break; } else if (VecLenf(ctrl->bone->tail, bone->tail) < 0.01) { - printf("%s -> %s: TL_TAIL\n", ctrl->bone->name, bone->name); ctrl->tail_mode = TL_TAIL; ctrl->link_tail = bone; break; @@ -1031,10 +1040,6 @@ static void RIG_reconnectControlBones(RigGraph *rg) { } } - else - { - printf("%s FIT\n", ctrl->bone->name); - } } } @@ -1808,6 +1813,17 @@ static void finalizeControl(RigGraph *rigg, RigControl *ctrl, float resize) if ((ctrl->flag & RIG_CTRL_DONE) == RIG_CTRL_DONE) { RigControl *ctrl_child; + +#if 0 + printf("CTRL: %s LINK: %s", ctrl->bone->name, ctrl->link->name); + + if (ctrl->link_tail) + { + printf(" TAIL: %s", ctrl->link_tail->name); + } + + printf("\n"); +#endif /* if there was a tail link: apply link, recalc resize factor and qrot */ if (ctrl->tail_mode != TL_NONE)