diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-11-15 06:58:06 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-11-15 06:58:06 +0400 |
commit | e6e265b2b59e02cc7816a2ed43471eca8bca0a62 (patch) | |
tree | e312d2c2f6cb1aaf79148648e5725902ab23d34e /source/blender/ikplugin/intern/iksolver_plugin.c | |
parent | e59ab6486f9e7285815671044b785c28365d5165 (diff) | |
parent | 3442c16c09b31a23f45b23be72e6eb5ba02c7bbf (diff) |
svn merge -r41779:41847 ^/trunk/blender
Diffstat (limited to 'source/blender/ikplugin/intern/iksolver_plugin.c')
-rw-r--r-- | source/blender/ikplugin/intern/iksolver_plugin.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c index 7159c09d703..eb3695ea217 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.c +++ b/source/blender/ikplugin/intern/iksolver_plugin.c @@ -62,8 +62,8 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t PoseTarget *target; bConstraint *con; bKinematicConstraint *data; - int a, segcount= 0, size, newsize, *oldparent, parent; - + int a, t, segcount= 0, size, newsize, *oldparent, parent; + /* find IK constraint, and validate it */ for(con= pchan_tip->constraints.first; con; con= con->next) { if(con->type==CONSTRAINT_TYPE_KINEMATIC) { @@ -114,7 +114,7 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t if(tree==NULL) { /* make new tree */ tree= MEM_callocN(sizeof(PoseTree), "posetree"); - + tree->type= CONSTRAINT_TYPE_KINEMATIC; tree->iterations= data->iterations; @@ -138,13 +138,27 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t /* skip common pose channels and add remaining*/ size= MIN2(segcount, tree->totchannel); - for(a=0; a<size && tree->pchan[a]==chanlist[segcount-a-1]; a++); - parent= a-1; + a = t = 0; + while (a<size && t<tree->totchannel) { + // locate first matching channel + for (;t<tree->totchannel && tree->pchan[t]!=chanlist[segcount-a-1];t++); + if (t>=tree->totchannel) + break; + for(; a<size && t<tree->totchannel && tree->pchan[t]==chanlist[segcount-a-1]; a++, t++); + } segcount= segcount-a; target->tip= tree->totchannel + segcount - 1; if (segcount > 0) { + for(parent = a - 1; parent < tree->totchannel; parent++) + if(tree->pchan[parent] == chanlist[segcount-1]->parent) + break; + + /* shouldn't happen, but could with dependency cycles */ + if(parent == tree->totchannel) + parent = a - 1; + /* resize array */ newsize= tree->totchannel + segcount; oldchan= tree->pchan; |