Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-04-26 11:17:21 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-04-26 11:17:21 +0400
commite4cc1c3f2c3e5a85fbf4f7f2757b09544dd556ee (patch)
tree1d134f4085ba2d90e854c47848c6fc82704667bb /source/blender/blenkernel/intern/particle.c
parent461a7c5c8185d0504c63ddc8de0b2c765e72be4b (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/particle.c')
-rw-r--r--source/blender/blenkernel/intern/particle.c47
1 files changed, 27 insertions, 20 deletions
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index e80289c75ae..5b583720905 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -3589,28 +3589,38 @@ ParticleSettings *psys_copy_settings(ParticleSettings *part)
return partn;
}
+static void expand_local_particlesettings(ParticleSettings *part)
+{
+ int i;
+ id_lib_extern((ID *)part->dup_group);
+
+ for(i=0; i<MAX_MTEX; i++) {
+ if(part->mtex[i]) id_lib_extern((ID *)part->mtex[i]->tex);
+ }
+}
+
void make_local_particlesettings(ParticleSettings *part)
{
+ Main *bmain= G.main;
Object *ob;
- ParticleSettings *par;
int local=0, lib=0;
/* - only lib users: do nothing
- * - only local users: set flag
- * - mixed: make copy
- */
+ * - only local users: set flag
+ * - mixed: make copy
+ */
if(part->id.lib==0) return;
if(part->id.us==1) {
part->id.lib= 0;
part->id.flag= LIB_LOCAL;
- new_id(0, (ID *)part, 0);
+ new_id(&bmain->particle, (ID *)part, 0);
+ expand_local_particlesettings(part);
return;
}
-
+
/* test objects */
- ob= G.main->object.first;
- while(ob) {
+ for(ob= bmain->object.first; ob && ELEM(0, lib, local); ob= ob->id.next) {
ParticleSystem *psys=ob->particlesystem.first;
for(; psys; psys=psys->next){
if(psys->part==part) {
@@ -3618,31 +3628,28 @@ void make_local_particlesettings(ParticleSettings *part)
else local= 1;
}
}
- ob= ob->id.next;
}
if(local && lib==0) {
part->id.lib= 0;
part->id.flag= LIB_LOCAL;
- new_id(0, (ID *)part, 0);
+ new_id(&bmain->particle, (ID *)part, 0);
+ expand_local_particlesettings(part);
}
else if(local && lib) {
-
- par= psys_copy_settings(part);
- par->id.us= 0;
+ ParticleSettings *partn= psys_copy_settings(part);
+ partn->id.us= 0;
/* do objects */
- ob= G.main->object.first;
- while(ob) {
- ParticleSystem *psys=ob->particlesystem.first;
- for(; psys; psys=psys->next){
+ for(ob= bmain->object.first; ob; ob= ob->id.next) {
+ ParticleSystem *psys;
+ for(psys= ob->particlesystem.first; psys; psys=psys->next){
if(psys->part==part && ob->id.lib==0) {
- psys->part= par;
- par->id.us++;
+ psys->part= partn;
+ partn->id.us++;
part->id.us--;
}
}
- ob= ob->id.next;
}
}
}