Revision: 14807
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14807
Author:   aligorith
Date:     2008-05-12 06:25:53 +0200 (Mon, 12 May 2008)

Log Message:
-----------
Bugfix for Separate Armatures:

Constraint relinking now works correctly for this tool, so it should be safe to 
be used by users now.

Modified Paths:
--------------
    trunk/blender/source/blender/src/editarmature.c

Modified: trunk/blender/source/blender/src/editarmature.c
===================================================================
--- trunk/blender/source/blender/src/editarmature.c     2008-05-12 01:32:17 UTC 
(rev 14806)
+++ trunk/blender/source/blender/src/editarmature.c     2008-05-12 04:25:53 UTC 
(rev 14807)
@@ -661,9 +661,10 @@
        Object *ob;
        bPoseChannel *pchan, *pcha, *pchb;
        bConstraint *con;
-       ListBase *npchans;
+       ListBase *opchans, *npchans;
        
-       /* get reference to list of bones in new armature  */
+       /* get reference to list of bones in original and new armatures  */
+       opchans= &origArm->pose->chanbase;
        npchans= &newArm->pose->chanbase;
        
        /* let's go through all objects in database */
@@ -682,8 +683,8 @@
                                                
                                                for (ct= targets.first; ct; ct= 
ct->next) {
                                                        /* any targets which 
point to original armature are redirected to the new one only if:
-                                                        *      - the target 
isn't the original armature itself
-                                                        *      - the target is 
one that can be found in newArm
+                                                        *      - the target 
isn't origArm/newArm itself
+                                                        *      - the target is 
one that can be found in newArm/origArm
                                                         */
                                                        if ((ct->tar == 
origArm) && (ct->subtarget[0] != 0)) {
                                                                for 
(pcha=npchans->first, pchb=npchans->last; pcha && pchb; pcha=pcha->next, 
pchb=pchb->prev) {
@@ -699,6 +700,20 @@
                                                                        if 
(pcha == pchb) break;
                                                                }               
                                                
                                                        }
+                                                       else if ((ct->tar == 
newArm) && (ct->subtarget[0] != 0)) {
+                                                               for 
(pcha=opchans->first, pchb=opchans->last; pcha && pchb; pcha=pcha->next, 
pchb=pchb->prev) {
+                                                                       /* 
check if either one matches */
+                                                                       if ( 
(strcmp(pcha->name, ct->subtarget)==0) ||
+                                                                               
 (strcmp(pchb->name, ct->subtarget)==0) )
+                                                                       {
+                                                                               
ct->tar= origArm;
+                                                                               
break;
+                                                                       }
+                                                                       
+                                                                       /* 
check if both ends have met (to stop checking) */
+                                                                       if 
(pcha == pchb) break;
+                                                               }               
                                                
+                                                       }
                                                }
                                                
                                                if 
(cti->flush_constraint_targets)
@@ -721,8 +736,8 @@
                                        
                                        for (ct= targets.first; ct; ct= 
ct->next) {
                                                /* any targets which point to 
original armature are redirected to the new one only if:
-                                                *      - the target isn't the 
original armature itself
-                                                *      - the target is one of 
the bones which were moved into newArm
+                                                *      - the target isn't 
origArm/newArm itself
+                                                *      - the target is one 
that can be found in newArm/origArm
                                                 */
                                                if ((ct->tar == origArm) && 
(ct->subtarget[0] != 0)) {
                                                        for 
(pcha=npchans->first, pchb=npchans->last; pcha && pchb; pcha=pcha->next, 
pchb=pchb->prev) {
@@ -736,8 +751,22 @@
                                                                
                                                                /* check if 
both ends have met (to stop checking) */
                                                                if (pcha == 
pchb) break;
-                                                       }
+                                                       }                       
                                        
                                                }
+                                               else if ((ct->tar == newArm) && 
(ct->subtarget[0] != 0)) {
+                                                       for 
(pcha=opchans->first, pchb=opchans->last; pcha && pchb; pcha=pcha->next, 
pchb=pchb->prev) {
+                                                               /* check if 
either one matches */
+                                                               if ( 
(strcmp(pcha->name, ct->subtarget)==0) ||
+                                                                        
(strcmp(pchb->name, ct->subtarget)==0) )
+                                                               {
+                                                                       
ct->tar= origArm;
+                                                                       break;
+                                                               }
+                                                               
+                                                               /* check if 
both ends have met (to stop checking) */
+                                                               if (pcha == 
pchb) break;
+                                                       }                       
                                        
+                                               }
                                        }
                                        
                                        if (cti->flush_constraint_targets)
@@ -829,12 +858,6 @@
        Base *base, *oldbase, *newbase;
        bArmature *arm;
        
-       // 31 Mar 08 \ 11 May 08 - Aligorith:
-       // currently, this is still too unstable to be enabled for general 
consumption.
-       // remove the following two lines to test this tool... you have been 
warned!
-       //      okee("Not implemented (WIP)");
-       //      return;
-       
        if ( G.vd==0 || (G.vd->lay & G.obedit->lay)==0 ) return;
        if ( okee("Separate")==0 ) return;
 


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to