diff options
author | Ton Roosendaal <ton@blender.org> | 2009-01-30 17:23:31 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-01-30 17:23:31 +0300 |
commit | 1122b60f31b3565e35ae3d58029c23766dd1fe65 (patch) | |
tree | c569c2eafdd4c394ee287c1645c0d4d6225f8c63 /source/blender/blenkernel | |
parent | 6009523659a7f3c24cf2ffd79429220065d66a19 (diff) |
2.5
Animsys: added integrated copy of animdata in copy_libblock().
-> by default animdata-copy should relink ID data like Action,
and put a facility to really duplicate it in other code.
(single_user_animdata or so)
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index b74406f3d3f..0712b53c5dd 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -83,8 +83,9 @@ #include "BLI_blenlib.h" #include "BLI_dynstr.h" -#include "BKE_library.h" +#include "BKE_animsys.h" #include "BKE_context.h" +#include "BKE_library.h" #include "BKE_main.h" #include "BKE_global.h" #include "BKE_sound.h" @@ -401,6 +402,45 @@ void *alloc_libblock(ListBase *lb, short type, const char *name) /* from blendef: */ #define GS(a) (*((short *)(a))) +/* by spec, animdata is first item after ID */ +/* we still read ->adt itself, to ensure compiler warns when it doesnt exist */ +static void id_copy_animdata(ID *id) +{ + switch(GS(id->name)) { + case ID_OB: + ((Object *)id)->adt= BKE_copy_animdata(((Object *)id)->adt); + break; + case ID_CU: + ((Curve *)id)->adt= BKE_copy_animdata(((Curve *)id)->adt); + break; + case ID_CA: + ((Camera *)id)->adt= BKE_copy_animdata(((Camera *)id)->adt); + break; + case ID_KE: + ((Key *)id)->adt= BKE_copy_animdata(((Key *)id)->adt); + break; + case ID_LA: + ((Lamp *)id)->adt= BKE_copy_animdata(((Lamp *)id)->adt); + break; + case ID_MA: + ((Material *)id)->adt= BKE_copy_animdata(((Material *)id)->adt); + break; + case ID_NT: + ((bNodeTree *)id)->adt= BKE_copy_animdata(((bNodeTree *)id)->adt); + break; + case ID_SCE: + ((Scene *)id)->adt= BKE_copy_animdata(((Scene *)id)->adt); + break; + case ID_TE: + ((Tex *)id)->adt= BKE_copy_animdata(((Tex *)id)->adt); + break; + case ID_WO: + ((World *)id)->adt= BKE_copy_animdata(((World *)id)->adt); + break; + } + +} + /* used everywhere in blenkernel and text.c */ void *copy_libblock(void *rt) { @@ -429,6 +469,8 @@ void *copy_libblock(void *rt) idn->flag |= LIB_NEW; if (id->properties) idn->properties = IDP_CopyProperty(id->properties); + id_copy_animdata(id); + return idn; } |