Revision: 18750
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18750
Author:   ton
Date:     2009-01-30 15:23:31 +0100 (Fri, 30 Jan 2009)

Log Message:
-----------
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)

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/intern/library.c

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/library.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/library.c      
2009-01-30 12:58:00 UTC (rev 18749)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/library.c      
2009-01-30 14:23:31 UTC (rev 18750)
@@ -83,8 +83,9 @@
 #include "BLI_blenlib.h"
 #include "BLI_dynstr.h"
 
+#include "BKE_animsys.h"
+#include "BKE_context.h"
 #include "BKE_library.h"
-#include "BKE_context.h"
 #include "BKE_main.h"
 #include "BKE_global.h"
 #include "BKE_sound.h"
@@ -401,6 +402,45 @@
 /* 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 @@
        idn->flag |= LIB_NEW;
        if (id->properties) idn->properties = IDP_CopyProperty(id->properties);
 
+       id_copy_animdata(id);
+       
        return idn;
 }
 


_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to