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/lattice.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/lattice.c')
-rw-r--r-- | source/blender/blenkernel/intern/lattice.c | 68 |
1 files changed, 30 insertions, 38 deletions
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 58c0a567116..67f49266efc 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -59,6 +59,8 @@ #include "BKE_key.h" #include "BKE_lattice.h" #include "BKE_library.h" +#include "BKE_library_query.h" +#include "BKE_library_remap.h" #include "BKE_main.h" #include "BKE_modifier.h" #include "BKE_object.h" @@ -275,15 +277,17 @@ Lattice *BKE_lattice_add(Main *bmain, const char *name) return lt; } -Lattice *BKE_lattice_copy(Lattice *lt) +Lattice *BKE_lattice_copy(Main *bmain, Lattice *lt) { Lattice *ltn; - ltn = BKE_libblock_copy(<->id); + ltn = BKE_libblock_copy(bmain, <->id); ltn->def = MEM_dupallocN(lt->def); - ltn->key = BKE_key_copy(ltn->key); - if (ltn->key) ltn->key->from = (ID *)ltn; + if (lt->key) { + ltn->key = BKE_key_copy(bmain, ltn->key); + ltn->key->from = (ID *)ltn; + } if (lt->dvert) { int tot = lt->pntsu * lt->pntsv * lt->pntsw; @@ -293,8 +297,9 @@ Lattice *BKE_lattice_copy(Lattice *lt) ltn->editlatt = NULL; - if (lt->id.lib) { - BKE_id_lib_local_paths(G.main, lt->id.lib, <n->id); + if (ID_IS_LINKED_DATABLOCK(lt)) { + BKE_id_expand_local(<n->id); + BKE_id_lib_local_paths(bmain, lt->id.lib, <n->id); } return ltn; @@ -325,48 +330,35 @@ void BKE_lattice_free(Lattice *lt) } -void BKE_lattice_make_local(Lattice *lt) +void BKE_lattice_make_local(Main *bmain, Lattice *lt) { - Main *bmain = G.main; - Object *ob; bool is_local = false, is_lib = false; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - - if (lt->id.lib == NULL) return; - if (lt->id.us == 1) { - id_clear_lib_data(bmain, <->id); + + if (!ID_IS_LINKED_DATABLOCK(lt)) { return; } - - for (ob = bmain->object.first; ob && ELEM(false, is_lib, is_local); ob = ob->id.next) { - if (ob->data == lt) { - if (ob->id.lib) is_lib = true; - else is_local = true; - } - } - - if (is_local && is_lib == false) { - id_clear_lib_data(bmain, <->id); - } - else if (is_local && is_lib) { - Lattice *lt_new = BKE_lattice_copy(lt); - lt_new->id.us = 0; - - /* Remap paths of new ID using old library as base. */ - BKE_id_lib_local_paths(bmain, lt->id.lib, <_new->id); - - for (ob = bmain->object.first; ob; ob = ob->id.next) { - if (ob->data == lt) { - if (ob->id.lib == NULL) { - ob->data = lt_new; - id_us_plus(<_new->id); - id_us_min(<->id); - } + + BKE_library_ID_test_usages(bmain, lt, &is_local, &is_lib); + + if (is_local) { + if (!is_lib) { + id_clear_lib_data(bmain, <->id); + if (lt->key) { + BKE_key_make_local(bmain, lt->key); } + BKE_id_expand_local(<->id); + } + else { + Lattice *lt_new = BKE_lattice_copy(bmain, lt); + + lt_new->id.us = 0; + + BKE_libblock_remap(bmain, lt, lt_new, ID_REMAP_SKIP_INDIRECT_USAGE); } } } |