Revision: 18559
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18559
Author:   aligorith
Date:     2009-01-18 11:41:45 +0100 (Sun, 18 Jan 2009)

Log Message:
-----------
2.5 - AnimSys Data management stuff...

* Removed nAction struct. We'll be using good ol' bAction structs again, but 
putting new data in a different list. Apart from that, the data is similar 
enough to do so.

* Rearranged code in DNA_action_types.h while renaming the structs to avoid 
confusion over what is currently in use...

* Added freeing and AnimData execution loops for many other ID-types too. 
(NOTE: I've added AnimData in NodeTree struct too, but it's not clear to me 
where the relevant data-management calls should go in Nodes code).

* File writing code should now only write the new data to files

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/BKE_action.h
    branches/blender2.5/blender/source/blender/blenkernel/BKE_animsys.h
    branches/blender2.5/blender/source/blender/blenkernel/BKE_fcurve.h
    branches/blender2.5/blender/source/blender/blenkernel/BKE_main.h
    branches/blender2.5/blender/source/blender/blenkernel/intern/action.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/curve.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/key.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/library.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/material.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/object.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/texture.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/world.c
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/blenloader/intern/writefile.c
    branches/blender2.5/blender/source/blender/editors/animation/keyframing.c
    branches/blender2.5/blender/source/blender/editors/include/ED_anim_api.h
    branches/blender2.5/blender/source/blender/makesdna/DNA_action_types.h
    branches/blender2.5/blender/source/blender/makesdna/DNA_anim_types.h
    branches/blender2.5/blender/source/blender/makesdna/DNA_curve_types.h
    branches/blender2.5/blender/source/blender/makesdna/DNA_node_types.h

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_action.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_action.h  
2009-01-18 07:35:44 UTC (rev 18558)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_action.h  
2009-01-18 10:41:45 UTC (rev 18559)
@@ -40,7 +40,7 @@
  * The following structures are defined in DNA_action_types.h, and 
DNA_anim_types.h
  */
 
-struct nAction;
+struct bAction;
 struct bPose;
 struct bPoseChannel;
 struct Object;
@@ -52,25 +52,30 @@
 extern "C" {
 #endif
 
-struct nAction *add_empty_action(const char name[]);
+struct bAction *add_empty_action(const char name[]);
        
        /**
  * Allocate a new bAction on the heap and copy 
  * the contents of src into it. If src is NULL NULL is returned.
  */
 
-struct nAction *copy_action(struct nAction *src);
+struct bAction *copy_action(struct bAction *src);
 
 /**
  * Deallocate the action's channels including constraint channels.
  * does not free the action structure.
  */
-void free_action(struct nAction *act);
+void free_action(struct bAction *act);
 
 // XXX is this needed?
-void make_local_action(struct nAction *act);
+void make_local_action(struct bAction *act);
        
 /**
+ * Some kind of bounding box operation on the action.
+ */
+void calc_action_range(const struct bAction *act, float *start, float *end, 
int incl_hidden);
+       
+/**
  * Removes and deallocates all channels from a pose.
  * Does not free the pose itself.
  */
@@ -115,21 +120,19 @@
 void update_pose_constraint_flags(struct bPose *pose);
 
 /* clears BONE_UNKEYED flags for frame changing */
+// XXX to be depreceated for a more general solution in animsys...
 void framechange_poses_clear_unkeyed(void);
 
 /**
- * Some kind of bounding box operation on the action.
- */
-void calc_action_range(const struct bAction *act, float *start, float *end, 
int incl_hidden);
-
-/**
  * Set the pose channels from the given action.
  */
+// XXX old crap
 void extract_pose_from_action(struct bPose *pose, struct bAction *act, float 
ctime);
 
 /**
  * Get the effects of the given action using a workob 
  */
+// XXX old crap, used for action constraint though!
 void what_does_obaction(struct Scene *scene, struct Object *ob, struct Object 
*workob, struct bAction *act, float cframe);
 
 /* exported for game engine */

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_animsys.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_animsys.h 
2009-01-18 07:35:44 UTC (rev 18558)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_animsys.h 
2009-01-18 10:41:45 UTC (rev 18559)
@@ -19,6 +19,12 @@
 /* Add AnimData to the given ID-block */
 struct AnimData *BKE_id_add_animdata(struct ID *id);
 
+/* Free AnimData */
+void BKE_free_animdata(struct ID *id);
+
+/* Copy AnimData */
+struct AnimData *BKE_copy_animdata(struct AnimData *adt);
+
 /* ************************************* */
 // TODO: overrides, remapping, and path-finding api's
 

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_fcurve.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_fcurve.h  
2009-01-18 07:35:44 UTC (rev 18558)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_fcurve.h  
2009-01-18 10:41:45 UTC (rev 18559)
@@ -79,6 +79,9 @@
 void free_fcurve(struct FCurve *fcu);
 struct FCurve *copy_fcurve(struct FCurve *fcu);
 
+void free_fcurves(ListBase *list);
+void copy_fcurves(ListBase *dst, ListBase *src);
+
 /* find matching F-Curve in the given list of F-Curves */
 struct FCurve *list_find_fcurve(ListBase *list, const char rna_path[], const 
int array_index);
 

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_main.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_main.h    
2009-01-18 07:35:44 UTC (rev 18558)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_main.h    
2009-01-18 10:41:45 UTC (rev 18559)
@@ -62,7 +62,7 @@
        ListBase latt;
        ListBase lamp;
        ListBase camera;
-       ListBase ipo;
+       ListBase ipo;   // XXX depreceated
        ListBase key;
        ListBase world;
        ListBase screen;

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/action.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/action.c       
2009-01-18 07:35:44 UTC (rev 18558)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/action.c       
2009-01-18 10:41:45 UTC (rev 18559)
@@ -81,9 +81,9 @@
 
 /* ***************** Library data level operations on action ************** */
 
-nAction *add_empty_action(const char name[])
+bAction *add_empty_action(const char name[])
 {
-       nAction *act;
+       bAction *act;
        
        act= alloc_libblock(&G.main->action, ID_AC, name);
        act->id.flag |= LIB_FAKEUSER; // XXX this is nasty for new users... 
maybe we don't want this anymore
@@ -93,10 +93,10 @@
 }      
 
 // does copy_fcurve...
-void make_local_action(nAction *act)
+void make_local_action(bAction *act)
 {
        // Object *ob;
-       nAction *actn;
+       bAction *actn;
        int local=0, lib=0;
        
        if (act->id.lib==0) return;
@@ -147,19 +147,14 @@
 }
 
 
-void free_action (nAction *act)
+void free_action (bAction *act)
 {
-       FCurve *fcu;
-       
        /* sanity check */
        if (act == NULL)
                return;
        
        /* Free F-Curves */
-       while ((fcu= act->curves.first)) {
-               BLI_remlink(&act->curves, fcu);
-               free_fcurve(fcu);
-       }
+       free_fcurves(&act->curves);
        
        /* Free groups */
        if (act->groups.first)
@@ -170,39 +165,20 @@
                BLI_freelistN(&act->markers);
 }
 
-nAction *copy_action (nAction *src)
+bAction *copy_action (bAction *src)
 {
-       nAction *dst = NULL;
-       //bActionChannel *dchan, *schan;
-       // bActionGroup *dgrp, *sgrp;
+       bAction *dst = NULL;
+       //bActionGroup *dgrp, *sgrp;    // XXX not used yet
        
-       if (!src) return NULL;
-       
+       if (src == NULL) 
+               return NULL;
        dst= copy_libblock(src);
        
-       BLI_duplicatelist(&(dst->chanbase), &(src->chanbase));
-       BLI_duplicatelist(&(dst->groups), &(src->groups));
-       BLI_duplicatelist(&(dst->markers), &(src->markers));
+       BLI_duplicatelist(&dst->groups, &src->groups);  // XXX not used yet
+       BLI_duplicatelist(&dst->markers, &src->markers);
        
-#if 0  // XXX old animation system
-       for (dchan=dst->chanbase.first, schan=src->chanbase.first; dchan; 
dchan=dchan->next, schan=schan->next) {
-               for (dgrp=dst->groups.first, sgrp=src->groups.first; dgrp && 
sgrp; dgrp=dgrp->next, sgrp=sgrp->next) {
-                       if (dchan->grp == sgrp) {
-                               dchan->grp= dgrp;
-                               
-                               if (dgrp->channels.first == schan)
-                                       dgrp->channels.first= dchan;
-                               if (dgrp->channels.last == schan)
-                                       dgrp->channels.last= dchan;
-                                       
-                               break;
-                       }
-               }
-               
-               dchan->ipo = copy_ipo(dchan->ipo);
-               copy_constraint_channels(&dchan->constraintChannels, 
&schan->constraintChannels);
-       }
-#endif // XXX old animation system
+       /* copy f-curves */
+       copy_fcurves(&dst->curves, &src->curves);
        
        dst->id.flag |= LIB_FAKEUSER; // XXX this is nasty for new users... 
maybe we don't want this anymore
        dst->id.us++;
@@ -219,12 +195,13 @@
 {
        bPoseChannel *chan;
 
-       if(pose==NULL) return NULL;
+       if (pose==NULL) return NULL;
        
        for (chan=pose->chanbase.first; chan; chan=chan->next) {
-               if(chan->name[0] == name[0])
+               if (chan->name[0] == name[0]) {
                        if (!strcmp (chan->name, name))
                                return chan;
+               }
        }
 
        return NULL;
@@ -236,11 +213,10 @@
 {
        bPoseChannel *chan;
        
-       if (!pose) {
+       if (pose == NULL)
                return NULL;
-       }
        
-       /*      See if this channel exists */
+       /* See if this channel exists */
        for (chan=pose->chanbase.first; chan; chan=chan->next) {
                if (!strcmp (name, chan->name))
                        return chan;
@@ -249,10 +225,10 @@
        /* If not, create it and add it */
        chan = MEM_callocN(sizeof(bPoseChannel), "verifyPoseChannel");
        
-       strncpy (chan->name, name, 31);
+       strncpy(chan->name, name, 31);
        /* init vars to prevent math errors */
-       chan->quat[0] = 1.0F;
-       chan->size[0] = chan->size[1] = chan->size[2] = 1.0F;
+       chan->quat[0] = 1.0f;
+       chan->size[0] = chan->size[1] = chan->size[2] = 1.0f;
        
        chan->limitmin[0]= chan->limitmin[1]= chan->limitmin[2]= -180.0f;
        chan->limitmax[0]= chan->limitmax[1]= chan->limitmax[2]= 180.0f;
@@ -285,7 +261,7 @@
 
 
 /* dst should be freed already, makes entire duplicate */
-void copy_pose(bPose **dst, bPose *src, int copycon)
+void copy_pose (bPose **dst, bPose *src, int copycon)
 {
        bPose *outPose;
        bPoseChannel    *pchan;

Modified: 
branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c     
2009-01-18 07:35:44 UTC (rev 18558)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c     
2009-01-18 10:41:45 UTC (rev 18559)
@@ -12,6 +12,7 @@
 #include "BLI_dynstr.h"
 
 #include "BKE_animsys.h"
+#include "BKE_action.h"
 #include "BKE_fcurve.h"
 #include "BKE_main.h"
 #include "BKE_utildefines.h"
@@ -24,85 +25,136 @@
 /* ***************************************** */
 /* AnimData API */
 
-/* Get AnimData from the given ID-block. In order for this to work, we assume 
that 
- * the AnimData pointer is stored immediately after the given ID-block in the 
struct,
- * as per IdAdtTemplate.
- */
-AnimData *BKE_animdata_from_id (ID *id)
+/* Getter/Setter -------------------------------------------- */
+
+/* Internal utility to check if ID can have AnimData */
+static short id_has_animdata (ID *id)
 {
        /* sanity check */
        if (id == NULL)
-               return NULL;
+               return 0;
                
-       /* only some ID-blocks have this info for now, so we cast the 
-        * types that do to be of type IdAdtTemplate, and extract the
-        * AnimData that way
-        */
+       /* Only some ID-blocks have this info for now */
        // TODO: finish adding this for the other blocktypes
        switch (GS(id->name)) {
+                       /* has AnimData */
                case ID_OB:
+               case ID_CU:
                case ID_KE:
-               case ID_MA: case ID_TE:
+               case ID_MA: case ID_TE: case ID_NT:
                case ID_LA: case ID_CA: case ID_WO:
                case ID_SCE:
                {
-                       IdAdtTemplate *iat= (IdAdtTemplate *)id;
-                       return iat->adt;
+                       return 1;
                }
-                       break;
+               
+                       /* no AnimData */
+               default:
+                       return 0;
        }
-       
-       /* no AnimData (ID-block does not contain this data) */
-       return NULL;
 }
 
+
+/* Get AnimData from the given ID-block. In order for this to work, we assume 
that 

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to