Bugfix #6201
authorTon Roosendaal <ton@blender.org>
Sun, 11 Mar 2007 12:14:50 +0000 (12:14 +0000)
committerTon Roosendaal <ton@blender.org>
Sun, 11 Mar 2007 12:14:50 +0000 (12:14 +0000)
Shape key drivers were not copied correctly, when choosing the option
"ADD NEW Scene -> Full copy".

source/blender/blenkernel/BKE_ipo.h
source/blender/blenkernel/intern/ipo.c
source/blender/src/editobject.c

index 7c8c018639745fb86f97052386a7132b8a1b03f8..2a6065eb4f169a70551656491874133dd78a25ed 100644 (file)
@@ -60,6 +60,7 @@ void free_ipo(struct Ipo *ipo);
 void ipo_default_v2d_cur(int blocktype, struct rctf *cur);
 struct Ipo *add_ipo(char *name, int idcode);
 struct Ipo *copy_ipo(struct Ipo *ipo);
+void ipo_idnew(struct Ipo *ipo);
 void make_local_obipo(struct Ipo *ipo);
 void make_local_matipo(struct Ipo *ipo);
 void make_local_keyipo(struct Ipo *ipo);
index b84410b12e78618fad553eb1afb1a93749d38af9..1757317b84967776deef68e0322150414dddc875 100644 (file)
@@ -287,6 +287,20 @@ Ipo *copy_ipo(Ipo *ipo)
        return ipon;
 }
 
+/* uses id->newid to match pointers with other copied data */
+void ipo_idnew(Ipo *ipo)
+{
+       if(ipo) {
+               IpoCurve *icu;
+               
+               for(icu= ipo->curve.first; icu; icu= icu->next) {
+                       if(icu->driver) {
+                               ID_NEW(icu->driver->ob);
+                       }
+               }
+       }
+}
+
 void make_local_obipo(Ipo *ipo)
 {
        Object *ob;
index 04a6b037ba0482df94c36b9a59cfcb56757e83c3..1152d880c5a59e5d73f92b154d5be9dddd1ab413 100644 (file)
@@ -4079,7 +4079,7 @@ void single_obdata_users(int flag)
                                
                                switch(ob->type) {
                                case OB_LAMP:
-                                       if(id && id->us>1 && id->lib==0) {
+                                       if(id && id->us>1 && id->lib==NULL) {
                                                ob->data= la= copy_lamp(ob->data);
                                                for(a=0; a<MAX_MTEX; a++) {
                                                        if(la->mtex[a]) {
@@ -4092,7 +4092,9 @@ void single_obdata_users(int flag)
                                        ob->data= copy_camera(ob->data);
                                        break;
                                case OB_MESH:
-                                       ob->data= copy_mesh(ob->data);
+                                       me= ob->data= copy_mesh(ob->data);
+                                       if(me && me->key)
+                                               ipo_idnew(me->key->ipo);        /* drivers */
                                        break;
                                case OB_MBALL:
                                        ob->data= copy_mball(ob->data);
@@ -4124,7 +4126,7 @@ void single_obdata_users(int flag)
                        }
                        
                        id= (ID *)ob->action;
-                       if (id && id->us>1 && id->lib==0){
+                       if (id && id->us>1 && id->lib==NULL){
                                if(id->newid){
                                        ob->action= (bAction *)id->newid;
                                        id_us_plus(id->newid);
@@ -4136,7 +4138,7 @@ void single_obdata_users(int flag)
                                }
                        }
                        id= (ID *)ob->ipo;
-                       if(id && id->us>1 && id->lib==0) {
+                       if(id && id->us>1 && id->lib==NULL) {
                                if(id->newid) {
                                        ob->ipo= (Ipo *)id->newid;
                                        id_us_plus(id->newid);
@@ -4146,6 +4148,7 @@ void single_obdata_users(int flag)
                                        id->us--;
                                        id->newid= (ID *)ob->ipo;
                                }
+                               ipo_idnew(ob->ipo);     /* drivers */
                        }
                        /* other ipos */
                        switch(ob->type) {
@@ -4154,6 +4157,7 @@ void single_obdata_users(int flag)
                                if(la->ipo && la->ipo->id.us>1) {
                                        la->ipo->id.us--;
                                        la->ipo= copy_ipo(la->ipo);
+                                       ipo_idnew(la->ipo);     /* drivers */
                                }
                                break;
                        case OB_CAMERA:
@@ -4161,6 +4165,7 @@ void single_obdata_users(int flag)
                                if(cam->ipo && cam->ipo->id.us>1) {
                                        cam->ipo->id.us--;
                                        cam->ipo= copy_ipo(cam->ipo);
+                                       ipo_idnew(cam->ipo);    /* drivers */
                                }
                                break;
                        }
@@ -4205,6 +4210,7 @@ void single_mat_users(int flag)
                                                if(ma->ipo) {
                                                        man->ipo= copy_ipo(ma->ipo);
                                                        ma->ipo->id.us--;
+                                                       ipo_idnew(ma->ipo);     /* drivers */
                                                }
                                                
                                                for(b=0; b<MAX_MTEX; b++) {