Bugfix #14428: Constraints lost when object made single user
authorJoshua Leung <aligorith@gmail.com>
Mon, 22 Sep 2008 13:01:51 +0000 (13:01 +0000)
committerJoshua Leung <aligorith@gmail.com>
Mon, 22 Sep 2008 13:01:51 +0000 (13:01 +0000)
When there was a setup where an object was linked to more than one scene at once, and in one of those scenes some of the objects in that scene were related to it, the objects related to it were not correctly relinked to the new copy.

This was due to the 2nd check for selected objects
if( (base->flag & flag)==flag)
meaning that only selected objects would get corrected.

source/blender/src/editobject.c

index 67709357225c70d654914a83fa499a9faccac24c..a52882e60039a4240389d5586b1c124fd11c4650 100644 (file)
@@ -4381,18 +4381,17 @@ void single_object_users(int flag)
        
        clear_sca_new_poins();  /* sensor/contr/act */
 
-       /* duplicate */
+       /* duplicate (must set newid) */
        base= FIRSTBASE;
        while(base) {
                ob= base->object;
                
-               if( (base->flag & flag)==flag) {
-
+               if( (base->flag & flag)==flag ) {
                        if(ob->id.lib==NULL && ob->id.us>1) {
-                       
+                               /* base gets copy of object */
                                obn= copy_object(ob);
-                               ob->id.us--;
                                base->object= obn;
+                               ob->id.us--;
                        }
                }
                base= base->next;
@@ -4406,20 +4405,17 @@ void single_object_users(int flag)
        while(base) {
                ob= base->object;
                if(ob->id.lib==NULL) {
-                       if( (base->flag & flag)==flag) {
-                               
-                               relink_constraints(&base->object->constraints);
-                               if (base->object->pose){
-                                       bPoseChannel *chan;
-                                       for (chan = base->object->pose->chanbase.first; chan; chan=chan->next){
-                                               relink_constraints(&chan->constraints);
-                                       }
+                       relink_constraints(&base->object->constraints);
+                       if (base->object->pose){
+                               bPoseChannel *chan;
+                               for (chan = base->object->pose->chanbase.first; chan; chan=chan->next){
+                                       relink_constraints(&chan->constraints);
                                }
-                               modifiers_foreachObjectLink(base->object, single_object_users__forwardModifierLinks, NULL);
-                               
-                               ID_NEW(ob->parent);
-                               ID_NEW(ob->track);
                        }
+                       modifiers_foreachObjectLink(base->object, single_object_users__forwardModifierLinks, NULL);
+                       
+                       ID_NEW(ob->parent);
+                       ID_NEW(ob->track);
                }
                base= base->next;
        }