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/action.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/action.c')
-rw-r--r-- | source/blender/blenkernel/intern/action.c | 87 |
1 files changed, 28 insertions, 59 deletions
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 46ee8a4d888..f7ff1261c8a 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -59,6 +59,8 @@ #include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_library.h" +#include "BKE_library_query.h" +#include "BKE_library_remap.h" #include "BKE_main.h" #include "BKE_object.h" @@ -92,68 +94,34 @@ bAction *add_empty_action(Main *bmain, const char name[]) /* .................................. */ -/* temp data for BKE_action_make_local */ -typedef struct tMakeLocalActionContext { - bAction *act; /* original action */ - bAction *act_new; /* new action */ - - bool is_lib; /* some action users were libraries */ - bool is_local; /* some action users were not libraries */ -} tMakeLocalActionContext; - -/* helper function for BKE_action_make_local() - local/lib init step */ -static void make_localact_init_cb(ID *id, AnimData *adt, void *mlac_ptr) +// does copy_fcurve... +void BKE_action_make_local(Main *bmain, bAction *act) { - tMakeLocalActionContext *mlac = (tMakeLocalActionContext *)mlac_ptr; - - if (adt->action == mlac->act) { - if (id->lib) mlac->is_lib = true; - else mlac->is_local = true; - } -} + bool is_local = false, is_lib = false; -/* helper function for BKE_action_make_local() - change references */ -static void make_localact_apply_cb(ID *id, AnimData *adt, void *mlac_ptr) -{ - tMakeLocalActionContext *mlac = (tMakeLocalActionContext *)mlac_ptr; - - if (adt->action == mlac->act) { - if (id->lib == NULL) { - adt->action = mlac->act_new; - - id_us_plus(&mlac->act_new->id); - id_us_min(&mlac->act->id); - } - } -} + /* - only lib users: do nothing + * - only local users: set flag + * - mixed: make copy + */ -// does copy_fcurve... -void BKE_action_make_local(bAction *act) -{ - tMakeLocalActionContext mlac = {act, NULL, false, false}; - Main *bmain = G.main; - - if (act->id.lib == NULL) - return; - - /* XXX: double-check this; it used to be just single-user check, but that was when fake-users were still default */ - if ((act->id.flag & LIB_FAKEUSER) && (act->id.us <= 1)) { - id_clear_lib_data(bmain, &act->id); + if (!ID_IS_LINKED_DATABLOCK(act)) { return; } - - BKE_animdata_main_cb(bmain, make_localact_init_cb, &mlac); - - if (mlac.is_local && mlac.is_lib == false) { - id_clear_lib_data(bmain, &act->id); - } - else if (mlac.is_local && mlac.is_lib) { - mlac.act_new = BKE_action_copy(act); - mlac.act_new->id.us = 0; - BKE_id_lib_local_paths(bmain, act->id.lib, &mlac.act_new->id); + BKE_library_ID_test_usages(bmain, act, &is_local, &is_lib); + + if (is_local) { + if (!is_lib) { + id_clear_lib_data(bmain, &act->id); + BKE_id_expand_local(&act->id); + } + else { + bAction *act_new = BKE_action_copy(bmain, act); + + act_new->id.us = 0; - BKE_animdata_main_cb(bmain, make_localact_apply_cb, &mlac); + BKE_libblock_remap(bmain, act, act_new, ID_REMAP_SKIP_INDIRECT_USAGE); + } } } @@ -176,7 +144,7 @@ void BKE_action_free(bAction *act) /* .................................. */ -bAction *BKE_action_copy(bAction *src) +bAction *BKE_action_copy(Main *bmain, bAction *src) { bAction *dst = NULL; bActionGroup *dgrp, *sgrp; @@ -184,7 +152,7 @@ bAction *BKE_action_copy(bAction *src) if (src == NULL) return NULL; - dst = BKE_libblock_copy(&src->id); + dst = BKE_libblock_copy(bmain, &src->id); /* duplicate the lists of groups and markers */ BLI_duplicatelist(&dst->groups, &src->groups); @@ -213,8 +181,9 @@ bAction *BKE_action_copy(bAction *src) } } - if (src->id.lib) { - BKE_id_lib_local_paths(G.main, src->id.lib, &dst->id); + if (ID_IS_LINKED_DATABLOCK(src)) { + BKE_id_expand_local(&dst->id); + BKE_id_lib_local_paths(bmain, src->id.lib, &dst->id); } return dst; |