diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_animsys.h | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_library.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/anim_sys.c | 35 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 4 |
6 files changed, 43 insertions, 17 deletions
diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index af5e31b1efa..07ab0e7ec2c 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -56,10 +56,13 @@ struct AnimData *BKE_id_add_animdata(struct ID *id); void BKE_free_animdata(struct ID *id); /* Copy AnimData */ -struct AnimData *BKE_copy_animdata(struct AnimData *adt); +struct AnimData *BKE_copy_animdata(struct AnimData *adt, const short do_action); /* Copy AnimData */ -int BKE_copy_animdata_id(struct ID *id_to, struct ID *id_from); +int BKE_copy_animdata_id(struct ID *id_to, struct ID *id_from, const short do_action); + +/* Copy AnimData Actions */ +void BKE_copy_animdata_id_action(struct ID *id); /* Make Local */ void BKE_animdata_make_local(struct AnimData *adt); diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index d98fb082aa9..4f0238854ef 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -46,7 +46,7 @@ struct bContext; void *alloc_libblock(struct ListBase *lb, short type, const char *name); void *copy_libblock(void *rt); -void copy_libblock_data(struct ID *id, const struct ID *id_from); +void copy_libblock_data(struct ID *id, const struct ID *id_from, const short do_action); void id_lib_extern(struct ID *id); void id_us_plus(struct ID *id); diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index febe8005317..e50d4880fbe 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -36,8 +36,10 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BKE_library.h" #include "BLI_dynstr.h" + #include "DNA_anim_types.h" #include "DNA_scene_types.h" @@ -175,7 +177,7 @@ void BKE_free_animdata (ID *id) /* Freeing -------------------------------------------- */ /* Make a copy of the given AnimData - to be used when copying datablocks */ -AnimData *BKE_copy_animdata (AnimData *adt) +AnimData *BKE_copy_animdata (AnimData *adt, const short do_action) { AnimData *dadt; @@ -185,9 +187,15 @@ AnimData *BKE_copy_animdata (AnimData *adt) dadt= MEM_dupallocN(adt); /* make a copy of action - at worst, user has to delete copies... */ - dadt->action= copy_action(adt->action); - dadt->tmpact= copy_action(adt->tmpact); - + if(do_action) { + dadt->action= copy_action(adt->action); + dadt->tmpact= copy_action(adt->tmpact); + } + else { + id_us_plus((ID *)dadt->action); + id_us_plus((ID *)dadt->tmpact); + } + /* duplicate NLA data */ copy_nladata(&dadt->nla_tracks, &adt->nla_tracks); @@ -201,7 +209,7 @@ AnimData *BKE_copy_animdata (AnimData *adt) return dadt; } -int BKE_copy_animdata_id(struct ID *id_to, struct ID *id_from) +int BKE_copy_animdata_id(struct ID *id_to, struct ID *id_from, const short do_action) { AnimData *adt; @@ -213,13 +221,26 @@ int BKE_copy_animdata_id(struct ID *id_to, struct ID *id_from) adt = BKE_animdata_from_id(id_from); if (adt) { IdAdtTemplate *iat = (IdAdtTemplate *)id_to; - iat->adt= BKE_copy_animdata(adt); + iat->adt= BKE_copy_animdata(adt, do_action); } return 1; } - +void BKE_copy_animdata_id_action(struct ID *id) +{ + AnimData *adt= BKE_animdata_from_id(id); + if(adt) { + if(adt->action) { + ((ID *)adt->action)->us--; + adt->action= copy_action(adt->action); + } + if(adt->tmpact) { + ((ID *)adt->tmpact)->us--; + adt->tmpact= copy_action(adt->tmpact); + } + } +} /* Make Local -------------------------------------------- */ diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 34351f9b113..c3bcb3dc69a 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -620,24 +620,24 @@ void *alloc_libblock(ListBase *lb, short type, const char *name) /* by spec, animdata is first item after ID */ /* and, trust that BKE_animdata_from_id() will only find AnimData for valid ID-types */ -static void id_copy_animdata(ID *id) +static void id_copy_animdata(ID *id, const short do_action) { AnimData *adt= BKE_animdata_from_id(id); if (adt) { IdAdtTemplate *iat = (IdAdtTemplate *)id; - iat->adt= BKE_copy_animdata(iat->adt); + iat->adt= BKE_copy_animdata(iat->adt, do_action); /* could be set to FALSE, need to investigate */ } } /* material nodes use this since they are not treated as libdata */ -void copy_libblock_data(ID *id, const ID *id_from) +void copy_libblock_data(ID *id, const ID *id_from, const short do_action) { if (id_from->properties) id->properties = IDP_CopyProperty(id_from->properties); /* the duplicate should get a copy of the animdata */ - id_copy_animdata(id); + id_copy_animdata(id, do_action); } /* used everywhere in blenkernel */ @@ -665,7 +665,7 @@ void *copy_libblock(void *rt) id->newid= idn; idn->flag |= LIB_NEW; - copy_libblock_data(idn, id); + copy_libblock_data(idn, id, FALSE); return idn; } diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 6c4c566f5b1..7b25c38648d 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1077,7 +1077,7 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree, int internal_select) newtree= copy_libblock(ntree); } else { newtree= MEM_dupallocN(ntree); - copy_libblock_data(&newtree->id, &ntree->id); /* copy animdata and ID props */ + copy_libblock_data(&newtree->id, &ntree->id, TRUE); /* copy animdata and ID props */ } newtree->nodes.first= newtree->nodes.last= NULL; newtree->links.first= newtree->links.last= NULL; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index e399e0bb83d..df02b3d12d2 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -171,7 +171,7 @@ Scene *copy_scene(Scene *sce, int type) BKE_keyingsets_copy(&(scen->keyingsets), &(sce->keyingsets)); if(sce->nodetree) { - scen->nodetree= ntreeCopyTree(sce->nodetree, 0); + scen->nodetree= ntreeCopyTree(sce->nodetree, 0); /* copies actions */ ntreeSwitchID(scen->nodetree, &sce->id, &scen->id); } @@ -216,9 +216,11 @@ Scene *copy_scene(Scene *sce, int type) /* world */ if(type == SCE_COPY_FULL) { + BKE_copy_animdata_id_action((ID *)scen); if(scen->world) { id_us_plus((ID *)scen->world); scen->world= copy_world(scen->world); + BKE_copy_animdata_id_action((ID *)scen->world); } if(sce->ed) { |