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:
Diffstat (limited to 'source/blender/blenkernel/intern/texture.c')
-rw-r--r--source/blender/blenkernel/intern/texture.c60
1 files changed, 29 insertions, 31 deletions
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 7d720aed62c..e3713b1e177 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -1,6 +1,4 @@
/*
- * $Id$
- *
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -44,6 +42,7 @@
#include "BLI_math.h"
#include "BLI_kdopbvh.h"
#include "BLI_utildefines.h"
+#include "BLI_bpath.h"
#include "DNA_key_types.h"
#include "DNA_object_types.h"
@@ -816,16 +815,20 @@ Tex *localize_texture(Tex *tex)
/* ------------------------------------------------------------------------- */
+static void extern_local_texture(Tex *tex)
+{
+ id_lib_extern((ID *)tex->ima);
+}
+
void make_local_texture(Tex *tex)
{
Main *bmain= G.main;
- Tex *texn;
Material *ma;
World *wrld;
Lamp *la;
Brush *br;
ParticleSettings *pa;
- int a, local=0, lib=0;
+ int a, is_local= FALSE, is_lib= FALSE;
/* - only lib users: do nothing
* - only local users: set flag
@@ -834,18 +837,9 @@ void make_local_texture(Tex *tex)
if(tex->id.lib==NULL) return;
- /* special case: ima always local immediately */
- if(tex->ima) {
- tex->ima->id.lib= NULL;
- tex->ima->id.flag= LIB_LOCAL;
- new_id(&bmain->image, (ID *)tex->ima, NULL);
- }
-
if(tex->id.us==1) {
- tex->id.lib= NULL;
- tex->id.flag= LIB_LOCAL;
- new_id(&bmain->tex, (ID *)tex, NULL);
-
+ id_clear_lib_data(bmain, &tex->id);
+ extern_local_texture(tex);
return;
}
@@ -853,8 +847,8 @@ void make_local_texture(Tex *tex)
while(ma) {
for(a=0; a<MAX_MTEX; a++) {
if(ma->mtex[a] && ma->mtex[a]->tex==tex) {
- if(ma->id.lib) lib= 1;
- else local= 1;
+ if(ma->id.lib) is_lib= TRUE;
+ else is_local= TRUE;
}
}
ma= ma->id.next;
@@ -863,8 +857,8 @@ void make_local_texture(Tex *tex)
while(la) {
for(a=0; a<MAX_MTEX; a++) {
if(la->mtex[a] && la->mtex[a]->tex==tex) {
- if(la->id.lib) lib= 1;
- else local= 1;
+ if(la->id.lib) is_lib= TRUE;
+ else is_local= TRUE;
}
}
la= la->id.next;
@@ -873,8 +867,8 @@ void make_local_texture(Tex *tex)
while(wrld) {
for(a=0; a<MAX_MTEX; a++) {
if(wrld->mtex[a] && wrld->mtex[a]->tex==tex) {
- if(wrld->id.lib) lib= 1;
- else local= 1;
+ if(wrld->id.lib) is_lib= TRUE;
+ else is_local= TRUE;
}
}
wrld= wrld->id.next;
@@ -882,8 +876,8 @@ void make_local_texture(Tex *tex)
br= bmain->brush.first;
while(br) {
if(br->mtex.tex==tex) {
- if(br->id.lib) lib= 1;
- else local= 1;
+ if(br->id.lib) is_lib= TRUE;
+ else is_local= TRUE;
}
br= br->id.next;
}
@@ -891,21 +885,25 @@ void make_local_texture(Tex *tex)
while(pa) {
for(a=0; a<MAX_MTEX; a++) {
if(pa->mtex[a] && pa->mtex[a]->tex==tex) {
- if(pa->id.lib) lib= 1;
- else local= 1;
+ if(pa->id.lib) is_lib= TRUE;
+ else is_local= TRUE;
}
}
pa= pa->id.next;
}
- if(local && lib==0) {
- tex->id.lib= NULL;
- tex->id.flag= LIB_LOCAL;
- new_id(&bmain->tex, (ID *)tex, NULL);
+ if(is_local && is_lib == FALSE) {
+ id_clear_lib_data(bmain, &tex->id);
+ extern_local_texture(tex);
}
- else if(local && lib) {
- texn= copy_texture(tex);
+ else if(is_local && is_lib) {
+ char *bpath_user_data[2]= {bmain->name, tex->id.lib->filepath};
+ Tex *texn= copy_texture(tex);
+
texn->id.us= 0;
+
+ /* Remap paths of new ID using old library as base. */
+ bpath_traverse_id(bmain, &texn->id, bpath_relocate_visitor, 0, bpath_user_data);
ma= bmain->mat.first;
while(ma) {