diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-12 01:01:38 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-12 01:07:44 +0300 |
commit | cfbd605567f48229a923df382baf6db98fbafc61 (patch) | |
tree | d4218c49672047d6c3b37517034660b3b5dcd966 /source/blender/blenkernel/intern/speaker.c | |
parent | 71a57a37b2eebbed53b5335019287b4df9c30519 (diff) | |
parent | 7212ebd09f9720883581221be923ae5e97ff5d76 (diff) |
Merge branch 'master' into blender2.8
Conflicts:
intern/cycles/blender/addon/ui.py
source/blender/blenkernel/BKE_particle.h
source/blender/blenkernel/intern/dynamicpaint.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/particle_distribute.c
source/blender/blenkernel/intern/texture.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_relations.c
source/blender/editors/physics/particle_edit.c
source/blender/editors/physics/particle_object.c
source/blender/editors/transform/transform_snap_object.c
Diffstat (limited to 'source/blender/blenkernel/intern/speaker.c')
-rw-r--r-- | source/blender/blenkernel/intern/speaker.c | 64 |
1 files changed, 20 insertions, 44 deletions
diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c index e5075a2d382..a91d8657179 100644 --- a/source/blender/blenkernel/intern/speaker.c +++ b/source/blender/blenkernel/intern/speaker.c @@ -34,6 +34,8 @@ #include "BKE_animsys.h" #include "BKE_global.h" #include "BKE_library.h" +#include "BKE_library_query.h" +#include "BKE_library_remap.h" #include "BKE_main.h" #include "BKE_speaker.h" @@ -66,30 +68,25 @@ void *BKE_speaker_add(Main *bmain, const char *name) return spk; } -Speaker *BKE_speaker_copy(Speaker *spk) +Speaker *BKE_speaker_copy(Main *bmain, Speaker *spk) { Speaker *spkn; - spkn = BKE_libblock_copy(&spk->id); + spkn = BKE_libblock_copy(bmain, &spk->id); + if (spkn->sound) id_us_plus(&spkn->sound->id); - if (spk->id.lib) { + if (ID_IS_LINKED_DATABLOCK(spk)) { + BKE_id_expand_local(&spkn->id); BKE_id_lib_local_paths(G.main, spk->id.lib, &spkn->id); } return spkn; } -static void extern_local_speaker(Speaker *spk) -{ - id_lib_extern((ID *)spk->sound); -} - -void BKE_speaker_make_local(Speaker *spk) +void BKE_speaker_make_local(Main *bmain, Speaker *spk) { - Main *bmain = G.main; - Object *ob; bool is_local = false, is_lib = false; /* - only lib users: do nothing @@ -97,44 +94,23 @@ void BKE_speaker_make_local(Speaker *spk) * - mixed: make copy */ - if (spk->id.lib == NULL) return; - if (spk->id.us == 1) { - id_clear_lib_data(bmain, &spk->id); - extern_local_speaker(spk); + if (!ID_IS_LINKED_DATABLOCK(spk)) { return; } - ob = bmain->object.first; - while (ob) { - if (ob->data == spk) { - if (ob->id.lib) is_lib = true; - else is_local = true; + BKE_library_ID_test_usages(bmain, spk, &is_local, &is_lib); + + if (is_local) { + if (!is_lib) { + id_clear_lib_data(bmain, &spk->id); + BKE_id_expand_local(&spk->id); } - ob = ob->id.next; - } + else { + Speaker *spk_new = BKE_speaker_copy(bmain, spk); - if (is_local && is_lib == false) { - id_clear_lib_data(bmain, &spk->id); - extern_local_speaker(spk); - } - else if (is_local && is_lib) { - Speaker *spk_new = BKE_speaker_copy(spk); - spk_new->id.us = 0; - - /* Remap paths of new ID using old library as base. */ - BKE_id_lib_local_paths(bmain, spk->id.lib, &spk_new->id); - - ob = bmain->object.first; - while (ob) { - if (ob->data == spk) { - - if (ob->id.lib == NULL) { - ob->data = spk_new; - id_us_plus(&spk_new->id); - id_us_min(&spk->id); - } - } - ob = ob->id.next; + spk_new->id.us = 0; + + BKE_libblock_remap(bmain, spk, spk_new, ID_REMAP_SKIP_INDIRECT_USAGE); } } } |