diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-04-26 11:17:21 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-04-26 11:17:21 +0400 |
commit | e4cc1c3f2c3e5a85fbf4f7f2757b09544dd556ee (patch) | |
tree | 1d134f4085ba2d90e854c47848c6fc82704667bb /source/blender/blenkernel/intern/curve.c | |
parent | 461a7c5c8185d0504c63ddc8de0b2c765e72be4b (diff) |
fix [#27178] Material links lost when making mesh data local
- making local object data - Curve/Mesh/MBall lost references to linked materials.
- joining a linked mesh object into a local one lost the link.
As well as these reported bugs, checked all local functions for consistency/correctness and found other cases which would also fail.
- making local metaball didn't ensure unique ID name.
- make_local_armature() was missing check for object users - main body of code would never run.
- local particles didn't set the dupli-group or textures to extern.
checked all local functions for consistency/correctness.
Diffstat (limited to 'source/blender/blenkernel/intern/curve.c')
-rw-r--r-- | source/blender/blenkernel/intern/curve.c | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 34e5fef8074..b104c6c9b30 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -63,7 +63,8 @@ #include "BKE_key.h" #include "BKE_library.h" #include "BKE_main.h" -#include "BKE_object.h" +#include "BKE_object.h" +#include "BKE_material.h" #include "ED_curve.h" @@ -216,10 +217,22 @@ Curve *copy_curve(Curve *cu) return cun; } +static void extern_local_curve(Curve *cu) +{ + id_lib_extern((ID *)cu->vfont); + id_lib_extern((ID *)cu->vfontb); + id_lib_extern((ID *)cu->vfonti); + id_lib_extern((ID *)cu->vfontbi); + + if(cu->mat) { + extern_local_matarar(cu->mat, cu->totcol); + } +} + void make_local_curve(Curve *cu) { - Object *ob = NULL; - Curve *cun; + Main *bmain= G.main; + Object *ob; int local=0, lib=0; /* - when there are only lib users: don't do @@ -229,47 +242,41 @@ void make_local_curve(Curve *cu) if(cu->id.lib==NULL) return; - if(cu->vfont) cu->vfont->id.lib= NULL; - if(cu->vfontb) cu->vfontb->id.lib= NULL; - if(cu->vfonti) cu->vfonti->id.lib= NULL; - if(cu->vfontbi) cu->vfontbi->id.lib= NULL; - if(cu->id.us==1) { cu->id.lib= NULL; cu->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)cu, NULL); + + new_id(&bmain->curve, (ID *)cu, NULL); + extern_local_curve(cu); return; } - - ob= G.main->object.first; - while(ob) { - if(ob->data==cu) { + + for(ob= bmain->object.first; ob && ELEM(0, lib, local); ob= ob->id.next) { + if(ob->data == cu) { if(ob->id.lib) lib= 1; else local= 1; } - ob= ob->id.next; } - + if(local && lib==0) { cu->id.lib= NULL; cu->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)cu, NULL); + + new_id(&bmain->curve, (ID *)cu, NULL); + extern_local_curve(cu); } else if(local && lib) { - cun= copy_curve(cu); + Curve *cun= copy_curve(cu); cun->id.us= 0; - - ob= G.main->object.first; - while(ob) { + + for(ob= bmain->object.first; ob; ob= ob->id.next) { if(ob->data==cu) { - if(ob->id.lib==NULL) { ob->data= cun; cun->id.us++; cu->id.us--; } } - ob= ob->id.next; } } } |