Reverting r33930 and r34202, which were related to bugs #21825 and
authorJoshua Leung <aligorith@gmail.com>
Thu, 13 Jan 2011 23:53:14 +0000 (23:53 +0000)
committerJoshua Leung <aligorith@gmail.com>
Thu, 13 Jan 2011 23:53:14 +0000 (23:53 +0000)
#25554. As found by Daniel Lara (Pepeland) in #25554, the original
problems in #21825 all stemmed from the ChildOf constraint there
having an incorrect inverse set, which was altering the final results.

Now Auto-IK works nicely for old rigs again (i.e. FK arms on BBB rigs)

source/blender/editors/transform/transform_conversions.c

index 8725e0ba5b93af9c0ffda9b8149608ff0efbf5c2..196b6af84fee208d7807ca5a710edb019da47a1a 100644 (file)
@@ -711,9 +711,8 @@ int count_set_pose_transflags(int *out_mode, short around, Object *ob)
        for(pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
                bone = pchan->bone;
                if(bone->flag & BONE_TRANSFORM) {
-
                        total++;
-
+                       
                        if(mode == TFM_TRANSLATION) {
                                if( has_targetless_ik(pchan)==NULL ) {
                                        if(pchan->parent && (pchan->bone->flag & BONE_CONNECTED)) {
@@ -754,7 +753,7 @@ static void pchan_autoik_adjust (bPoseChannel *pchan, short chainlen)
        for (con= pchan->constraints.first; con; con= con->next) {
                if (con->type == CONSTRAINT_TYPE_KINEMATIC && (con->enforce!=0.0)) {
                        bKinematicConstraint *data= con->data;
-
+                       
                        /* only accept if a temporary one (for auto-ik) */
                        if (data->flag & CONSTRAINT_IK_TEMP) {
                                /* chainlen is new chainlen, but is limited by maximum chainlen */
@@ -803,8 +802,9 @@ static void pose_grab_with_ik_clear(Object *ob)
        for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
                /* clear all temporary lock flags */
                pchan->ikflag &= ~(BONE_IK_NO_XDOF_TEMP|BONE_IK_NO_YDOF_TEMP|BONE_IK_NO_ZDOF_TEMP);
-
+               
                pchan->constflag &= ~(PCHAN_HAS_IK|PCHAN_HAS_TARGET);
+               
                /* remove all temporary IK-constraints added */
                for (con= pchan->constraints.first; con; con= next) {
                        next= con->next;
@@ -879,19 +879,6 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
                        pchan = pchan->parent;
                else
                        pchan = NULL;
-               
-               /* but, constrainted bones can't get auto-ik transform applied, exclude these */
-               if(pchan && pchan->constraints.first) {
-                       /* if constraint is disabled or has no influence, OK then we allow :) */
-                       for (con= pchan->constraints.first; con; con= con->next) {
-                               if ((con->enforce==0.0f) || (con->flag & (CONSTRAINT_DISABLE|CONSTRAINT_OFF)));
-                               else break;
-                       }
-                       if(con) {
-                               data->rootbone--;
-                               pchan= NULL;
-                       }
-               }
        }
 
        /* make a copy of maximum chain-length */
@@ -3585,13 +3572,13 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
 
 /* ------------------------ */
 
-/* struct for use in re-sorting BezTriples during IPO transform */
+/* struct for use in re-sorting BezTriples during Graph Editor transform */
 typedef struct BeztMap {
        BezTriple *bezt;
-       int oldIndex;           /* index of bezt in icu->bezt array before sorting */
-       int newIndex;           /* index of bezt in icu->bezt array after sorting */
-       short swapHs;           /* swap order of handles (-1=clear; 0=not checked, 1=swap) */
-       char pipo, cipo;        /* interpolation of current and next segments */
+       unsigned int oldIndex;          /* index of bezt in fcu->bezt array before sorting */
+       unsigned int newIndex;          /* index of bezt in fcu->bezt array after sorting */
+       short swapHs;                           /* swap order of handles (-1=clear; 0=not checked, 1=swap) */
+       char pipo, cipo;                        /* interpolation of current and next segments */
 } BeztMap;
 
 
@@ -3722,11 +3709,11 @@ static void beztmap_to_data (TransInfo *t, FCurve *fcu, BeztMap *bezms, int totv
                        if (bezm->bezt->f2 & SELECT) {
                                if (td->loc2d == bezm->bezt->vec[1]) {
                                        td->loc2d= (bezts + bezm->newIndex)->vec[1];
-
+                                       
                                        /* if only control point is selected, the handle pointers need to be updated as well */
                                        td->h1= (bezts + bezm->newIndex)->vec[0];
                                        td->h2= (bezts + bezm->newIndex)->vec[2];
-
+                                       
                                        adjusted[j] = 1;
                                }
                        }
@@ -3809,7 +3796,7 @@ void flushTransGraphData(TransInfo *t)
                                        break;
                        }
                }
-
+               
                /* we need to unapply the nla-mapping from the time in some situations */
                if (adt)
                        td2d->loc2d[0]= BKE_nla_tweakedit_remap(adt, td2d->loc[0], NLATIME_CONVERT_UNMAP);
@@ -3821,12 +3808,12 @@ void flushTransGraphData(TransInfo *t)
                        td2d->loc2d[1]= (float)((int)td2d->loc[1]);
                else
                        td2d->loc2d[1]= td2d->loc[1];
-
+               
                if ((td->flag & TD_MOVEHANDLE1) && td2d->h1) {
                        td2d->h1[0] = td2d->ih1[0] + td->loc[0] - td->iloc[0];
                        td2d->h1[1] = td2d->ih1[1] + td->loc[1] - td->iloc[1];
                }
-
+               
                if ((td->flag & TD_MOVEHANDLE2) && td2d->h2) {
                        td2d->h2[0] = td2d->ih2[0] + td->loc[0] - td->iloc[0];
                        td2d->h2[1] = td2d->ih2[1] + td->loc[1] - td->iloc[1];