diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-01-18 13:41:45 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-01-18 13:41:45 +0300 |
commit | 53ae509cc5ad75dca490dea8c632d542285e0058 (patch) | |
tree | 3ccf1ca8583c46b67391ceca2b07698c19f28c8c /source | |
parent | 711d04a4995f16abbbaca0deecadd48fefbbe165 (diff) |
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
Diffstat (limited to 'source')
23 files changed, 580 insertions, 488 deletions
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index 444a97364ab..9ef91d60e89 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -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,23 +52,28 @@ struct ID; 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. @@ -115,21 +120,19 @@ struct bPoseChannel *verify_pose_channel(struct bPose* pose, 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 */ diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index f8a5d91bfa5..3b6b01a2341 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -19,6 +19,12 @@ struct AnimData *BKE_animdata_from_id(struct ID *id); /* 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 diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h index 82914cbfd59..7a71168684e 100644 --- a/source/blender/blenkernel/BKE_fcurve.h +++ b/source/blender/blenkernel/BKE_fcurve.h @@ -79,6 +79,9 @@ void fcurve_bake_modifiers(struct FCurve *fcu, int start, int end); 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); diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h index 34ecb2bbba1..30cf800a3d8 100644 --- a/source/blender/blenkernel/BKE_main.h +++ b/source/blender/blenkernel/BKE_main.h @@ -62,7 +62,7 @@ typedef struct Main { ListBase latt; ListBase lamp; ListBase camera; - ListBase ipo; + ListBase ipo; // XXX depreceated ListBase key; ListBase world; ListBase screen; diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index a7427b1b306..eb68b1f3a6a 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -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 @@ nAction *add_empty_action(const char name[]) } // 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 make_local_action(nAction *act) } -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 @@ void free_action (nAction *act) BLI_freelistN(&act->markers); } -nAction *copy_action (nAction *src) +bAction *copy_action (bAction *src) { - nAction *dst = NULL; - //bActionChannel *dchan, *schan; - // bActionGroup *dgrp, *sgrp; - - if (!src) return NULL; + bAction *dst = NULL; + //bActionGroup *dgrp, *sgrp; // XXX not used yet + 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 *get_pose_channel(const bPose *pose, const char *name) { 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 *verify_pose_channel(bPose* pose, const char* name) { 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 @@ bPoseChannel *verify_pose_channel(bPose* pose, const char* name) /* 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 @@ bPoseChannel *get_active_posechannel (Object *ob) /* 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; diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 18172488908..fb2a9731a40 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -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,36 +25,52 @@ /* ***************************************** */ /* 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 + * the AnimData pointer is stored immediately after the given ID-block in the struct, + * as per IdAdtTemplate. + */ +AnimData *BKE_animdata_from_id (ID *id) +{ + /* 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 + */ + if (id_has_animdata(id)) { + IdAdtTemplate *iat= (IdAdtTemplate *)id; + return iat->adt; + } + else + return NULL; } /* Add AnimData to the given ID-block. In order for this to work, we assume that @@ -62,47 +79,82 @@ AnimData *BKE_animdata_from_id (ID *id) */ AnimData *BKE_id_add_animdata (ID *id) { - /* sanity check */ - if (id == NULL) - return NULL; + /* Only some ID-blocks have this info for now, so we cast the + * types that do to be of type IdAdtTemplate, and add the AnimData + * to it using the template + */ + if (id_has_animdata(id)) { + IdAdtTemplate *iat= (IdAdtTemplate *)id; - /* only some ID-blocks have this info for now, so we cast the - * types that do to be of type IdAdtTemplate, and add AnimData that - * way + iat->adt= MEM_callocN(sizeof(AnimData), "AnimData"); + return iat->adt; + } + else + return NULL; +} + +/* Freeing -------------------------------------------- */ + +/* Free AnimData used by the nominated ID-block, and clear ID-block's AnimData pointer */ +void BKE_free_animdata (ID *id) +{ + /* Only some ID-blocks have this info for now, so we cast the + * types that do to be of type IdAdtTemplate */ - // TODO: finish adding this for the other blocktypes - switch (GS(id->name)) { - case ID_OB: - case ID_KE: - case ID_MA: case ID_TE: - case ID_LA: case ID_CA: case ID_WO: - case ID_SCE: - { - IdAdtTemplate *iat= (IdAdtTemplate *)id; + if (id_has_animdata(id)) { + IdAdtTemplate *iat= (IdAdtTemplate *)id; + AnimData *adt= iat->adt; + + /* check if there's any AnimData to start with */ + if (adt) { + /* unlink action (don't free, as it's in its own list) */ + if (adt->action) + adt->action->id.us--; + + /* free drivers - stored as a list of F-Curves */ + free_fcurves(&adt->drivers); + + /* free overrides */ + // TODO... - iat->adt= MEM_callocN(sizeof(AnimData), "AnimData"); - return iat->adt; + /* free animdata now */ + MEM_freeN(adt); + iat->adt= NULL; } - break; } - - /* no AnimData (ID-block does not contain this data) */ - return NULL; } +/* Freeing -------------------------------------------- */ -/* Obtain an RNA-Path from the given ID-block to the property of interest - * - id: ID block that will be used as the 'root' of the path - * - ptr: pointer to struct where setting is stored - * - prop: property to get path for - */ -// TODO: should this be part of RNA Access API instead? or through editors only? -char *BKE_animsys_get_rnapath (ID *id, PointerRNA *ptr, PropertyRNA *prop) +/* Make a copy of the given AnimData - to be used when copying datablocks */ +AnimData *BKE_copy_animdata (AnimData *adt) { - // FIXME: this could be quite messy to do right :/ - return NULL; + AnimData *dadt; + + /* sanity check before duplicating struct */ + if (adt == NULL) + return NULL; + dadt= MEM_dupallocN(adt); + + /* make a copy of action - at worst, user has to delete copies... */ + // XXX review this... it might not be optimal behaviour yet... + //id_us_plus((ID *)dadt->action); + dadt->action= copy_action(adt->action); + + /* duplicate NLA data */ + // XXX todo... + + /* duplicate drivers (F-Curves) */ + copy_fcurves(&dadt->drivers, &adt->drivers); + + /* don't copy overrides */ + dadt->overrides.first= dadt->overrides.last= NULL; + + /* return */ + return dadt; } + /* ***************************************** */ /* Evaluation Data-Setting Backend */ @@ -138,8 +190,7 @@ static void animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_in if (RNA_path_resolve(ptr, path, &new_ptr, &prop)) { /* set value - only for animatable numerical values */ - // FIXME: probably 'editable' might not be enough in future... - if (RNA_property_editable(&new_ptr, prop)) + if (RNA_property_animateable(&new_ptr, prop)) { switch (RNA_property_type(&new_ptr, prop)) { @@ -244,7 +295,7 @@ static void animsys_evaluate_drivers (PointerRNA *ptr, AnimData *adt, float ctim /* Actions Evaluation */ /* Evaluate Action (F-Curve Bag) */ -static void animsys_evaluate_action (PointerRNA *ptr, nAction *act, AnimMapper *remap, float ctime) +static void animsys_evaluate_action (PointerRNA *ptr, bAction *act, AnimMapper *remap, float ctime) { /* check if mapper is appropriate for use here (we set to NULL if it's inappropriate) */ if (act == NULL) return; @@ -565,20 +616,46 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime) ID *id; //printf("Evaluate all animation - %f \n", ctime); - - /* cameras */ + + /* macro for less typing */ +#define EVAL_ANIM_IDS(first) \ + for (id= first; id; id= id->next) { \ + AnimData *adt= BKE_animdata_from_id(id); \ + BKE_animsys_evaluate_animdata(id, adt, ctime, ADT_RECALC_ANIM); \ + } + + /* nodes */ + // TODO... /* textures */ + EVAL_ANIM_IDS(main->tex.first); /* lamps */ + EVAL_ANIM_IDS(main->lamp.first); /* materials */ + EVAL_ANIM_IDS(main->mat.first); + + /* cameras */ + EVAL_ANIM_IDS(main->camera.first); + + /* shapekeys */ + // TODO... + + /* curves */ + // TODO... + + /* meshes */ + // TODO... /* objects */ - for (id= main->object.first; id; id= id->next) { - AnimData *adt= BKE_animdata_from_id(id); - BKE_animsys_evaluate_animdata(id, adt, ctime, ADT_RECALC_ANIM); - } + EVAL_ANIM_IDS(main->object.first); + + /* worlds */ + EVAL_ANIM_IDS(main->world.first); + + /* scenes */ + EVAL_ANIM_IDS(main->scene.first); } /* ***************************************** */ diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index d52d91e40e9..91189fc7d3a 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -52,6 +52,7 @@ #include "DNA_scene_types.h" #include "DNA_vfont_types.h" +#include "BKE_animsys.h" #include "BKE_anim.h" #include "BKE_curve.h" #include "BKE_displist.h" @@ -83,10 +84,6 @@ void unlink_curve(Curve *cu) cu->vfont= 0; if(cu->key) cu->key->id.us--; cu->key= 0; -#if 0 // XXX old animation system - if(cu->ipo) cu->ipo->id.us--; - cu->ipo= 0; -#endif // XXX old animation system } @@ -105,6 +102,7 @@ void free_curve(Curve *cu) } unlink_curve(cu); + BKE_free_animdata((ID *)cu); if(cu->mat) MEM_freeN(cu->mat); if(cu->str) MEM_freeN(cu->str); diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 0e94faf0c4d..a7d375cb955 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -37,7 +37,7 @@ /* ---------------------- Freeing --------------------------- */ -/* Frees the F-Curve itself too */ +/* Frees the F-Curve itself too, so make sure BLI_remlink is called before calling this... */ void free_fcurve (FCurve *fcu) { if (fcu == NULL) @@ -61,6 +61,28 @@ void free_fcurve (FCurve *fcu) MEM_freeN(fcu); } +/* Frees a list of F-Curves */ +void free_fcurves (ListBase *list) +{ + FCurve *fcu, *fcn; + + /* sanity check */ + if (list == NULL) + return; + + /* free data - no need to call remlink before freeing each curve, + * as we store reference to next, and freeing only touches the curve + * it's given + */ + for (fcu= list->first; fcu; fcu= fcn) { + fcn= fcu->next; + free_fcurve(fcu); + } + + /* clear pointers just in case */ + list->first= list->last= NULL; +} + /* ---------------------- Copy --------------------------- */ /* duplicate an F-Curve */ @@ -74,6 +96,7 @@ FCurve *copy_fcurve (FCurve *fcu) /* make a copy */ fcu_d= MEM_dupallocN(fcu); + fcu_d->next= fcu_d->prev= NULL; /* copy curve data */ fcu_d->bezt= MEM_dupallocN(fcu_d->bezt); @@ -92,6 +115,25 @@ FCurve *copy_fcurve (FCurve *fcu) return fcu_d; } +/* duplicate a list of F-Curves */ +void copy_fcurves (ListBase *dst, ListBase *src) +{ + FCurve *dfcu, *sfcu; + + /* sanity checks */ + if ELEM(NULL, dst, src) + return; + + /* clear destination list first */ + dst->first= dst->last= NULL; + + /* copy one-by-one */ + for (sfcu= src->first; sfcu; sfcu= sfcu->next) { + dfcu= copy_fcurve(sfcu); + BLI_addtail(dst, dfcu); + } +} + /* ---------------------- Relink --------------------------- */ #if 0 @@ -1395,7 +1437,7 @@ void fcurve_free_modifiers (FCurve *fcu) if (fcu == NULL) return; - /* free each modifier in order */ + /* free each modifier in order - modifier is unlinked from list and freed */ for (fcm= fcu->modifiers.first; fcm; fcm= fmn) { fmn= fcm->next; fcurve_remove_modifier(fcu, fcm); @@ -1472,6 +1514,7 @@ float evaluate_fcurve (FCurve *fcu, float evaltime) FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm); /* only evaluate if there's a callback for this */ + // TODO: implement the 'influence' control feature... if (fmi && fmi->evaluate_modifier) { if ((fcm->flag & FMODIFIER_FLAG_DISABLED) == 0) fmi->evaluate_modifier(fcu, fcm, &cvalue, evaltime); diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index f06583a6ace..718ddf2dc96 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -43,6 +43,7 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "BKE_animsys.h" #include "BKE_action.h" #include "BKE_blender.h" #include "BKE_curve.h" @@ -77,9 +78,7 @@ void free_key(Key *key) { KeyBlock *kb; -#if 0 // XXX old animation system - if(key->ipo) key->ipo->id.us--; -#endif // XXX old animation system + BKE_free_animdata((ID *)key); while( (kb= key->block.first) ) { diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index d0e5da5f936..ecd6e22c3ef 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -359,7 +359,7 @@ static ID *alloc_libblock_notest(short type) id = MEM_callocN(sizeof(bArmature), "armature"); break; case ID_AC: - id = MEM_callocN(sizeof(nAction), "action"); // XXX animation system + id = MEM_callocN(sizeof(bAction), "action"); break; case ID_NT: id = MEM_callocN(sizeof(bNodeTree), "nodetree"); @@ -520,7 +520,7 @@ void free_libblock(ListBase *lb, void *idv) free_armature((bArmature *)id); break; case ID_AC: - free_action((nAction *)id); // XXX animation system... + free_action((bAction *)id); break; case ID_NT: ntreeFreeTree((bNodeTree *)id); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 66339cd977d..b410c521dea 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -47,6 +47,7 @@ #include "BLI_blenlib.h" #include "BLI_arithb.h" +#include "BKE_animsys.h" #include "BKE_blender.h" #include "BKE_displist.h" #include "BKE_global.h" @@ -92,6 +93,8 @@ void free_material(Material *ma) if(ma->ramp_col) MEM_freeN(ma->ramp_col); if(ma->ramp_spec) MEM_freeN(ma->ramp_spec); + BKE_free_animdata((ID *)ma); + BKE_previewimg_free(&ma->preview); BKE_icon_delete((struct ID*)ma); ma->id.icon_id = 0; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 28cf5e84d89..8b3f495e495 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -248,10 +248,7 @@ void free_object(Object *ob) ob->bb= 0; if(ob->path) free_path(ob->path); ob->path= 0; -#if 0 // XXX old animation system - if(ob->ipo) ob->ipo->id.us--; - if(ob->action) ob->action->id.us--; -#endif // XXX old animation system + if(ob->adt) BKE_free_animdata((ID *)ob); if(ob->poselib) ob->poselib->id.us--; if(ob->dup_group) ob->dup_group->id.us--; if(ob->defbase.first) @@ -266,9 +263,6 @@ void free_object(Object *ob) free_actuators(&ob->actuators); free_constraints(&ob->constraints); -#if 0 // XXX old animation system - free_nlastrips(&ob->nlastrips); -#endif #ifndef DISABLE_PYTHON BPY_free_scriptlink(&ob->scriptlink); @@ -559,11 +553,6 @@ void unlink_object(Scene *scene, Object *ob) if(v3d->localvd->persp==V3D_CAMOB) v3d->localvd->persp= V3D_PERSP; } } - else if(sl->spacetype==SPACE_IPO) { - // XXX animsys this is likely to change... - SpaceIpo *sipo= (SpaceIpo *)sl; - if(sipo->from == (ID *)ob) sipo->from= NULL; - } else if(sl->spacetype==SPACE_OOPS) { SpaceOops *so= (SpaceOops *)sl; Oops *oops; @@ -643,10 +632,7 @@ Camera *copy_camera(Camera *cam) Camera *camn; camn= copy_libblock(cam); - -#if 0 // XXX old animation system - id_us_plus((ID *)camn->ipo); -#endif // XXX old animation system + camn->adt= BKE_copy_animdata(cam->adt); #ifndef DISABLE_PYTHON BPY_copy_scriptlink(&camn->scriptlink); @@ -862,6 +848,7 @@ void free_camera(Camera *ca) #ifndef DISABLE_PYTHON BPY_free_scriptlink(&ca->scriptlink); #endif + BKE_free_animdata((ID *)ca); } void free_lamp(Lamp *la) @@ -880,9 +867,7 @@ void free_lamp(Lamp *la) if(mtex) MEM_freeN(mtex); } -#if 0 // XXX old animation system - la->ipo= 0; -#endif // XXX old animation system + BKE_free_animdata((ID *)la); curvemapping_free(la->curfalloff); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index cfd88d3d438..3247c963644 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -148,6 +148,8 @@ void free_scene(Scene *sce) #ifndef DISABLE_PYTHON BPY_free_scriptlink(&sce->scriptlink); #endif + + BKE_free_animdata((ID *)sce); if (sce->r.avicodecdata) { free_avicodecdata(sce->r.avicodecdata); @@ -611,10 +613,6 @@ void scene_update_for_newframe(Scene *sce, unsigned int lay) Scene *scene= sce; float ctime = frame_to_float(sce, sce->r.cfra); - /* clears all BONE_UNKEYED flags for every pose's pchans */ - // xxx old animation system - //framechange_poses_clear_unkeyed(); - /* clear animation overrides */ // XXX TODO... diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 495d50725d0..66f7fe8a44b 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -74,6 +74,7 @@ #include "BKE_icons.h" #include "BKE_brush.h" #include "BKE_node.h" +#include "BKE_animsys.h" /* ------------------------------------------------------------------------- */ diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index bd747bc1b61..7278460c61c 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -48,6 +48,7 @@ #include "BKE_utildefines.h" #include "BKE_library.h" +#include "BKE_animsys.h" #include "BKE_world.h" #include "BKE_global.h" #include "BKE_main.h" @@ -76,9 +77,7 @@ void free_world(World *wrld) } BKE_previewimg_free(&wrld->preview); -#if 0 // XXX old animation system - wrld->ipo= 0; -#endif // XXX old animation system + BKE_free_animdata((ID *)wrld); BKE_icon_delete((struct ID*)wrld); wrld->id.icon_id = 0; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index e7c834e68a2..b9777b81dcf 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -48,6 +48,7 @@ #include <io.h> // for open close read #endif +#include "DNA_anim_types.h" #include "DNA_action_types.h" #include "DNA_armature_types.h" #include "DNA_ID.h" @@ -105,6 +106,7 @@ #include "BLI_arithb.h" #include "BLI_storage_types.h" // for relname flags +#include "BKE_animsys.h" #include "BKE_action.h" #include "BKE_armature.h" #include "BKE_cdderivedmesh.h" @@ -116,10 +118,10 @@ #include "BKE_deform.h" #include "BKE_depsgraph.h" #include "BKE_effect.h" /* give_parteff */ +#include "BKE_fcurve.h" #include "BKE_global.h" // for G #include "BKE_group.h" #include "BKE_image.h" -#include "BKE_ipo.h" #include "BKE_key.h" //void set_four_ipo #include "BKE_lattice.h" #include "BKE_library.h" // for wich_libbase @@ -3753,6 +3755,7 @@ static void direct_link_scene(FileData *fd, Scene *sce) This is needed, to make Ipo-Pinning work for Sequence-Ipos... */ +// XXX old animation system - depreceated stuff... static Sequence * find_sequence_from_ipo_helper(Main * main, Ipo * ipo) { Sequence *seq; @@ -9265,8 +9268,10 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob) expand_doit(fd, mainvar, ob->data); +// XXX old animation system expand_doit(fd, mainvar, ob->ipo); expand_doit(fd, mainvar, ob->action); +// XXX old animation system expand_doit(fd, mainvar, ob->poselib); for (md=ob->modifiers.first; md; md=md->next) { @@ -9275,6 +9280,8 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob) expand_pose(fd, mainvar, ob->pose); expand_constraints(fd, mainvar, &ob->constraints); + +// XXX old animation system expand_constraint_channels(fd, mainvar, &ob->constraintChannels); for (strip=ob->nlastrips.first; strip; strip=strip->next){ @@ -9282,6 +9289,7 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob) expand_doit(fd, mainvar, strip->act); expand_doit(fd, mainvar, strip->ipo); } +// XXX old animation system for(a=0; a<ob->totcol; a++) { expand_doit(fd, mainvar, ob->mat[a]); diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index df6f233a20f..4a8233b964b 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -89,6 +89,7 @@ Any case: direct data is ALWAYS after the lib block #include <string.h> #include <stdlib.h> +#include "DNA_anim_types.h" #include "DNA_armature_types.h" #include "DNA_action_types.h" #include "DNA_actuator_types.h" @@ -105,7 +106,7 @@ Any case: direct data is ALWAYS after the lib block #include "DNA_group_types.h" #include "DNA_gpencil_types.h" #include "DNA_image_types.h" -#include "DNA_ipo_types.h" +#include "DNA_ipo_types.h" // XXX depreceated - animsys #include "DNA_fileglobal_types.h" #include "DNA_key_types.h" #include "DNA_lattice_types.h" @@ -161,6 +162,7 @@ Any case: direct data is ALWAYS after the lib block #include "BKE_utildefines.h" // for defines #include "BKE_modifier.h" #include "BKE_idprop.h" +#include "BKE_fcurve.h" #include "BLO_writefile.h" #include "BLO_readfile.h" @@ -758,19 +760,113 @@ static void write_actuators(WriteData *wd, ListBase *lb) } } -static void write_nlastrips(WriteData *wd, ListBase *nlabase) +static void write_fcurves(WriteData *wd, ListBase *fcurves) { - bActionStrip *strip; - bActionModifier *amod; + FCurve *fcu; + FModifier *fcm; - for (strip=nlabase->first; strip; strip=strip->next) - writestruct(wd, DATA, "bActionStrip", 1, strip); - for (strip=nlabase->first; strip; strip=strip->next) { - for(amod= strip->modifiers.first; amod; amod= amod->next) - writestruct(wd, DATA, "bActionModifier", 1, amod); + for (fcu=fcurves->first; fcu; fcu=fcu->next) { + /* F-Curve */ + writestruct(wd, DATA, "FCurve", 1, fcu); + + /* curve data */ + if (fcu->bezt) + writestruct(wd, DATA, "BezTriple", fcu->totvert, fcu->bezt); + if (fcu->fpt) + writestruct(wd, DATA, "FPoint", fcu->totvert, fcu->fpt); + + if (fcu->rna_path) + writedata(wd, DATA, strlen(fcu->rna_path)+1, fcu->rna_path); + + /* driver data */ + if (fcu->driver) { + ChannelDriver *driver= fcu->driver; + + writestruct(wd, DATA, "ChannelDriver", 1, driver); + + if (driver->rna_path) + writedata(wd, DATA, strlen(driver->rna_path)+1, driver->rna_path); + if (driver->rna_path2) + writedata(wd, DATA, strlen(driver->rna_path2)+1, driver->rna_path2); + } + + /* Modifiers */ + for (fcm= fcu->modifiers.first; fcm; fcm= fcm->next) { + FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm); + + /* Write the specific data */ + if (fmi && fcm->data) { + /* firstly, just write the plain fmi->data struct */ + writestruct(wd, DATA, fmi->structName, 1, fcm->data); + + /* do any constraint specific stuff */ + switch (fcm->type) { + case FMODIFIER_TYPE_GENERATOR: + { + FMod_Generator *data= (FMod_Generator *)fcm->data; + + /* write polynomial coefficients array */ + if (data->poly_coefficients) + writedata(wd, DATA, sizeof(float)*(data->poly_order+1), data->poly_coefficients); + } + break; + } + } + + /* Write the constraint */ + writestruct(wd, DATA, "FModifier", 1, fcm); + } } } +static void write_actions(WriteData *wd, ListBase *idbase) +{ + bAction *act; + bActionGroup *grp; + TimeMarker *marker; + + for(act=idbase->first; act; act= act->id.next) { + if (act->id.us>0 || wd->current) { + writestruct(wd, ID_AC, "bAction", 1, act); + if (act->id.properties) IDP_WriteProperty(act->id.properties, wd); + + write_fcurves(wd, &act->curves); + + for (grp=act->groups.first; grp; grp=grp->next) { + writestruct(wd, DATA, "bActionGroup", 1, grp); + } + + for (marker=act->markers.first; marker; marker=marker->next) { + writestruct(wd, DATA, "TimeMarker", 1, marker); + } + } + } + + /* flush helps the compression for undo-save */ + mywrite(wd, MYWRITE_FLUSH, 0); +} + +static void write_animdata(WriteData *wd, AnimData *adt) +{ + AnimOverride *aor; + + /* firstly, just write the AnimData block */ + writestruct(wd, DATA, "AnimData", 1, adt); + + /* write drivers */ + write_fcurves(wd, &adt->drivers); + + /* write overrides */ + for (aor= adt->overrides.first; aor; aor= aor->next) { + /* overrides consist of base data + rna_path */ + writestruct(wd, DATA, "AnimOverride", 1, aor); + writedata(wd, DATA, strlen(aor->rna_path)+1, aor->rna_path); + } + + /* write NLA data */ + // XXX todo... +} + static void write_constraints(WriteData *wd, ListBase *conlist) { bConstraint *con; @@ -843,15 +939,6 @@ static void write_defgroups(WriteData *wd, ListBase *defbase) writestruct(wd, DATA, "bDeformGroup", 1, defgroup); } -static void write_constraint_channels(WriteData *wd, ListBase *chanbase) -{ - bConstraintChannel *chan; - - for (chan = chanbase->first; chan; chan=chan->next) - writestruct(wd, DATA, "bConstraintChannel", 1, chan); - -} - static void write_modifiers(WriteData *wd, ListBase *modbase, int write_undo) { ModifierData *md; @@ -937,8 +1024,6 @@ static void write_objects(WriteData *wd, ListBase *idbase, int write_undo) write_pose(wd, ob->pose); write_defgroups(wd, &ob->defbase); write_constraints(wd, &ob->constraints); - write_constraint_channels(wd, &ob->constraintChannels); - write_nlastrips(wd, &ob->nlastrips); writestruct(wd, DATA, "PartDeflect", 1, ob->pd); writestruct(wd, DATA, "SoftBody", 1, ob->soft); @@ -981,40 +1066,6 @@ static void write_vfonts(WriteData *wd, ListBase *idbase) } } -static void write_ipos(WriteData *wd, ListBase *idbase) -{ - Ipo *ipo; - IpoCurve *icu; - - ipo= idbase->first; - while(ipo) { - if(ipo->id.us>0 || wd->current) { - /* write LibData */ - writestruct(wd, ID_IP, "Ipo", 1, ipo); - if (ipo->id.properties) IDP_WriteProperty(ipo->id.properties, wd); - - /* direct data */ - icu= ipo->curve.first; - while(icu) { - writestruct(wd, DATA, "IpoCurve", 1, icu); - icu= icu->next; - } - - icu= ipo->curve.first; - while(icu) { - if(icu->bezt) writestruct(wd, DATA, "BezTriple", icu->totvert, icu->bezt); - if(icu->bp) writestruct(wd, DATA, "BPoint", icu->totvert, icu->bp); - if(icu->driver) writestruct(wd, DATA, "IpoDriver", 1, icu->driver); - icu= icu->next; - } - } - - ipo= ipo->id.next; - } - - /* flush helps the compression for undo-save */ - mywrite(wd, MYWRITE_FLUSH, 0); -} static void write_keys(WriteData *wd, ListBase *idbase) { @@ -1108,6 +1159,7 @@ static void write_curves(WriteData *wd, ListBase *idbase) /* direct data */ writedata(wd, DATA, sizeof(void *)*cu->totcol, cu->mat); if (cu->id.properties) IDP_WriteProperty(cu->id.properties, wd); + if (cu->adt) write_animdata(wd, cu->adt); if(cu->vfont) { writedata(wd, DATA, amount_of_chars(cu->str)+1, cu->str); @@ -1842,34 +1894,6 @@ static void write_armatures(WriteData *wd, ListBase *idbase) mywrite(wd, MYWRITE_FLUSH, 0); } -static void write_actions(WriteData *wd, ListBase *idbase) -{ - bAction *act; - bActionChannel *chan; - bActionGroup *grp; - TimeMarker *marker; - - for(act=idbase->first; act; act= act->id.next) { - if (act->id.us>0 || wd->current) { - writestruct(wd, ID_AC, "bAction", 1, act); - if (act->id.properties) IDP_WriteProperty(act->id.properties, wd); - - for (chan=act->chanbase.first; chan; chan=chan->next) { - writestruct(wd, DATA, "bActionChannel", 1, chan); - write_constraint_channels(wd, &chan->constraintChannels); - } - - for (grp=act->groups.first; grp; grp=grp->next) { - writestruct(wd, DATA, "bActionGroup", 1, grp); - } - - for (marker=act->markers.first; marker; marker=marker->next) { - writestruct(wd, DATA, "TimeMarker", 1, marker); - } - } - } -} - static void write_texts(WriteData *wd, ListBase *idbase) { Text *text; @@ -2090,7 +2114,6 @@ static int write_file_handle(Main *mainvar, int handle, MemFile *compare, MemFil write_lamps (wd, &mainvar->lamp); write_lattices (wd, &mainvar->latt); write_vfonts (wd, &mainvar->vfont); - write_ipos (wd, &mainvar->ipo); write_keys (wd, &mainvar->key); write_worlds (wd, &mainvar->world); write_texts (wd, &mainvar->text); diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 9dbf38066a0..afefd842639 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -100,7 +100,7 @@ typedef struct bKeyingContext { FCurve *verify_fcurve (ID *id, const char rna_path[], const int array_index, short add) { AnimData *adt; - nAction *act; + bAction *act; FCurve *fcu; /* sanity checks */ @@ -823,7 +823,7 @@ short deletekey (ID *id, const char rna_path[], int array_index, float cfra, sho /* only continue if we have an ipo-curve to remove keyframes from */ if (adt && adt->action && fcu) { - nAction *act= adt->action; + bAction *act= adt->action; short found = -1; int i; @@ -2120,7 +2120,8 @@ static int delete_key_exec (bContext *C, wmOperator *op) /* loop through all curves in animdata and delete keys on this frame */ if (ob->adt) { - nAction *act= ob->adt->action; + AnimData *adt= ob->adt; + bAction *act= adt->action; for (fcu= act->curves.first; fcu; fcu= fcn) { fcn= fcu->next; @@ -2163,7 +2164,7 @@ void ANIM_OT_delete_keyframe (wmOperatorType *ot) /* Checks whether an IPO-block has a keyframe for a given frame * Since we're only concerned whether a keyframe exists, we can simply loop until a match is found... */ -short action_frame_has_keyframe (nAction *act, float frame, short filter) +short action_frame_has_keyframe (bAction *act, float frame, short filter) { FCurve *fcu; @@ -2206,11 +2207,11 @@ short action_frame_has_keyframe (nAction *act, float frame, short filter) short object_frame_has_keyframe (Object *ob, float frame, short filter) { /* error checking */ - if (ELEM(NULL, ob, ob->adt)) + if (ob == NULL) return 0; /* check own animation data - specifically, the action it contains */ - if (ob->adt->action) { + if ((ob->adt) && (ob->adt->action)) { if (action_frame_has_keyframe(ob->adt->action, frame, filter)) return 1; } diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 20c72c9f0e2..4b58aa4a6c8 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -181,6 +181,10 @@ typedef enum eAnimFilter_Flags { #define FILTER_CAM_OBJD(ca) ((ca->flag & CAM_DS_EXPAND)) #define FILTER_CUR_OBJD(cu) ((cu->flag & CU_DS_EXPAND)) /* 'Sub-object/Action' channels (flags stored in Action) */ + // XXX temp flags for things removed +#define ACTC_SELECTED 1 +#define ACTC_EXPANDED 2 + // XXX these need to be fixed #define SEL_ACTC(actc) ((actc->flag & ACTC_SELECTED)) #define EXPANDED_ACTC(actc) ((actc->flag & ACTC_EXPANDED)) diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index cb75badd0ea..e9ffad60f52 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -40,10 +40,16 @@ struct SpaceLink; struct Object; -/* -------------- Poses ----------------- */ +/* ************************************************ */ +/* Poses */ -/* PoseChannel stores the results of Actions (ipos) and transform information - with respect to the restposition of Armature bones */ +/* PoseChannel ------------------------------------ */ + +/* PoseChannel + * + * A PoseChannel stores the results of Actions and transform information + * with respect to the restposition of Armature bones + */ typedef struct bPoseChannel { struct bPoseChannel *next, *prev; ListBase constraints;/* Constraints that act on this PoseChannel */ @@ -94,7 +100,63 @@ typedef struct bPoseChannel { struct Object *custom; /* draws custom object instead of this channel */ } bPoseChannel; -/* Pose-Object. It is only found under ob->pose. It is not library data, even + +/* PoseChannel (transform) flags */ +enum { + POSE_LOC = 0x0001, + POSE_ROT = 0x0002, + POSE_SIZE = 0x0004, + POSE_IK_MAT = 0x0008, + POSE_UNUSED2 = 0x0010, + POSE_UNUSED3 = 0x0020, + POSE_UNUSED4 = 0x0040, + POSE_UNUSED5 = 0x0080, + POSE_HAS_IK = 0x0100, + POSE_CHAIN = 0x0200, + POSE_DONE = 0x0400, + POSE_KEY = 0x1000, + POSE_STRIDE = 0x2000 +} ePchan_Flag; + +/* PoseChannel constflag (constraint detection) */ +enum { + PCHAN_HAS_IK = (1<<0), + PCHAN_HAS_CONST = (1<<1), + /* only used for drawing Posemode, not stored in channel */ + PCHAN_HAS_ACTION = (1<<2), + PCHAN_HAS_TARGET = (1<<3), + /* only for drawing Posemode too */ + PCHAN_HAS_STRIDE = (1<<4) +} ePchan_ConstFlag; + +/* PoseChannel->ikflag */ +enum { + BONE_IK_NO_XDOF = (1<<0), + BONE_IK_NO_YDOF = (1<<1), + BONE_IK_NO_ZDOF = (1<<2), + + BONE_IK_XLIMIT = (1<<3), + BONE_IK_YLIMIT = (1<<4), + BONE_IK_ZLIMIT = (1<<5), + + BONE_IK_NO_XDOF_TEMP = (1<<10), + BONE_IK_NO_YDOF_TEMP = (1<<11), + BONE_IK_NO_ZDOF_TEMP = (1<<12) +} ePchan_IkFlag; + +/* PoseChannel->rotmode */ +enum { + /* quaternion rotations (default, and for older Blender versions) */ + PCHAN_ROT_QUAT = 0, + /* euler rotations (xyz only) */ + PCHAN_ROT_EUL, +} ePchan_RotMode; + +/* Pose ------------------------------------ */ + +/* Pose-Object. + * + * It is only found under ob->pose. It is not library data, even * though there is a define for it (hack for the outliner). */ typedef struct bPose { @@ -114,15 +176,33 @@ typedef struct bPose { } bPose; -/* ------------- Action ---------------- */ +/* Pose->flag */ +enum { + /* results in armature_rebuild_pose being called */ + POSE_RECALC = (1<<0), + /* prevents any channel from getting overridden by anim from IPO */ + POSE_LOCKED = (1<<1), + /* clears the POSE_LOCKED flag for the next time the pose is evaluated */ + POSE_DO_UNLOCK = (1<<2), + /* pose has constraints which depend on time (used when depsgraph updates for a new frame) */ + POSE_CONSTRAINTS_TIMEDEPEND = (1<<3), + /* recalculate bone paths */ + POSE_RECALCPATHS = (1<<4), +} ePose_Flags; + +/* ************************************************ */ +/* Action */ -/* Action-Channel Group. These are stored as a list per-Action, and are only used to - * group that Action's Action-Channels when displayed in the Action Editor. +/* Groups -------------------------------------- */ + +/* Action-Channel Group (agrp) + + * These are stored as a list per-Action, and are only used to + * group that Action's channels in an Animation Editor. * - * Even though all Action-Channels live in a big list per Action, each group they are in also + * Even though all FCurves live in a big list per Action, each group they are in also * holds references to the achans within that list which belong to it. Care must be taken to * ensure that action-groups never end up being the sole 'owner' of a channel. - * * * This is also exploited for bone-groups. Bone-Groups are stored per bPose, and are used * primarily to colour bones in the 3d-view. There are other benefits too, but those are mostly related @@ -131,51 +211,67 @@ typedef struct bPose { typedef struct bActionGroup { struct bActionGroup *next, *prev; - ListBase channels; /* Note: this must not be touched by standard listbase functions */ + ListBase channels; /* Note: this must not be touched by standard listbase functions which would clear links to other channels */ int flag; /* settings for this action-group */ int customCol; /* index of custom color set to use when used for bones (0=default - used for all old files, -1=custom set) */ - char name[32]; /* name of the group */ + char name[64]; /* name of the group */ ThemeWireColor cs; /* color set to use when customCol == -1 */ } bActionGroup; -/* Action Channels belong to Actions. They are linked with an IPO block, and can also own - * Constraint Channels in certain situations. - * - * Action-Channels can only belong to one group at a time, but they still live the Action's - * list of achans (to preserve backwards compatability, and also minimise the code - * that would need to be recoded). Grouped achans are stored at the start of the list, according - * to the position of the group in the list, and their position within the group. - */ -typedef struct bActionChannel { - struct bActionChannel *next, *prev; - bActionGroup *grp; /* Action Group this Action Channel belongs to */ - - struct Ipo *ipo; /* IPO block this action channel references */ - ListBase constraintChannels; /* Constraint Channels (when Action Channel represents an Object or Bone) */ +/* Action Group flags */ +enum { + AGRP_SELECTED = (1<<0), + AGRP_ACTIVE = (1<<1), + AGRP_PROTECTED = (1<<2), + AGRP_EXPANDED = (1<<3), - int flag; /* settings accessed via bitmapping */ - char name[32]; /* channel name */ - int temp; /* temporary setting - may be used to indicate group that channel belongs to during syncing */ -} bActionChannel; + AGRP_TEMP = (1<<30), + AGRP_MOVED = (1<<31) +} eActionGroup_Flag; -/* Action. A recyclable block that contains a series of Action Channels (ipo), which define - * a clip of reusable animation for use in the NLA. + +/* Actions -------------------------------------- */ + +/* Action - reusable F-Curve 'bag' (act) + * + * This contains F-Curves that may affect settings from more than one ID blocktype and/or + * datablock (i.e. sub-data linked/used directly to the ID block that the animation data is linked to), + * but with the restriction that the other unrelated data (i.e. data that is not directly used or linked to + * by the source ID block). + * + * It serves as a 'unit' of reusable animation information (i.e. keyframes/motion data), that + * affects a group of related settings (as defined by the user). */ +// XXX use this as drop-in replacement at some point... typedef struct bAction { - ID id; + ID id; /* ID-serialisation for relinking */ - ListBase chanbase; /* Action Channels in this Action */ - ListBase groups; /* Action Groups in the Action */ - ListBase markers; /* TimeMarkers local to this Action for labelling 'poses' */ + ListBase curves; /* function-curves (FCurve) */ + ListBase chanbase; /* legacy data - Action Channels (bActionChannel) in pre-2.5 animation system */ + ListBase groups; /* groups of function-curves (bActionGroup) */ + ListBase markers; /* markers local to the Action (used to provide Pose-Libraries) */ - int active_marker; /* Index of active-marker (first marker = 1) */ - int flag; /* flags for this action */ + int flag; /* settings for this action */ + int active_marker; /* index of the active marker */ } bAction; -/* ------------- Action Editor --------------------- */ +/* Flags for the action */ +enum { + /* flags for displaying in UI */ + ACT_EXPANDED = (1<<0), + ACT_SELECTED = (1<<1), + + /* flags for evaluation/editing */ + ACT_MUTED = (1<<9), + ACT_PROTECTED = (1<<10), +} eAction_Flags; + + +/* ************************************************ */ +/* Action/Dopesheet Editor */ /* Storage for Dopesheet/Grease-Pencil Editor data */ typedef struct bDopeSheet { @@ -186,62 +282,6 @@ typedef struct bDopeSheet { int flag; /* standard flags */ } bDopeSheet; -/* Action Editor Space. This is defined here instead of in DNA_space_types.h */ -typedef struct SpaceAction { - struct SpaceLink *next, *prev; - ListBase regionbase; /* storage of regions for inactive spaces */ - int spacetype; - float blockscale; - - short blockhandler[8]; - - View2D v2d; /* depricated, copied to region */ - - bAction *action; /* the currently active action */ - bDopeSheet ads; /* the currently active context (when not showing action) */ - - char mode, autosnap; /* mode: editing context; autosnap: automatic keyframe snapping mode */ - short flag, actnr; /* flag: bitmapped settings; */ - short pin, lock; /* pin: keep showing current action; actnr: used for finding chosen action from menu; lock: lock time to other windows */ - short actwidth; /* width of the left-hand side name panel (in pixels?) */ // XXX depreceated! - float timeslide; /* for Time-Slide transform mode drawing - current frame? */ -} SpaceAction; - - -/* -------------- Action Flags -------------- */ - -/* Action Channel flags */ -typedef enum ACHAN_FLAG { - ACHAN_SELECTED = (1<<0), - ACHAN_HILIGHTED = (1<<1), - ACHAN_HIDDEN = (1<<2), - ACHAN_PROTECTED = (1<<3), - ACHAN_EXPANDED = (1<<4), - ACHAN_SHOWIPO = (1<<5), - ACHAN_SHOWCONS = (1<<6), - ACHAN_MOVED = (1<<31), -} ACHAN_FLAG; - - -/* Action Group flags */ -typedef enum AGRP_FLAG { - AGRP_SELECTED = (1<<0), - AGRP_ACTIVE = (1<<1), - AGRP_PROTECTED = (1<<2), - AGRP_EXPANDED = (1<<3), - - AGRP_TEMP = (1<<30), - AGRP_MOVED = (1<<31) -} AGRP_FLAG; - - -/* 'Action' Channel flags */ -typedef enum ACT_FLAG { - ACTC_SELECTED = (1<<0), - ACTC_EXPANDED = (1<<1), -} ACT_FLAG; - -/* ------------ DopeSheet Flags ------------------ */ /* DopeSheet filter-flag */ typedef enum DOPESHEET_FILTERFLAG { @@ -270,10 +310,31 @@ typedef enum DOPESHEET_FILTERFLAG { //} DOPESHEET_FLAG; -/* ------------ Action Editor Flags -------------- */ + + +/* Action Editor Space. This is defined here instead of in DNA_space_types.h */ +typedef struct SpaceAction { + struct SpaceLink *next, *prev; + ListBase regionbase; /* storage of regions for inactive spaces */ + int spacetype; + float blockscale; + + short blockhandler[8]; + + View2D v2d; /* depricated, copied to region */ + + bAction *action; /* the currently active action */ + bDopeSheet ads; /* the currently active context (when not showing action) */ + + char mode, autosnap; /* mode: editing context; autosnap: automatic keyframe snapping mode */ + short flag, actnr; /* flag: bitmapped settings; */ + short pin, lock; /* pin: keep showing current action; actnr: used for finding chosen action from menu; lock: lock time to other windows */ + short actwidth; /* width of the left-hand side name panel (in pixels?) */ // XXX depreceated! + float timeslide; /* for Time-Slide transform mode drawing - current frame? */ +} SpaceAction; /* SpaceAction flag */ -typedef enum SACTION_FLAG { +enum { /* during transform (only set for TimeSlide) */ SACTION_MOVING = (1<<0), /* show sliders (if relevant) */ @@ -292,10 +353,11 @@ typedef enum SACTION_FLAG { SACTION_NODRAWGCOLORS = (1<<7), /* don't draw current frame number beside frame indicator */ SACTION_NODRAWCFRANUM = (1<<8), -} SACTION_FLAG; +} eSAction_Flag; /* SpaceAction Mode Settings */ -typedef enum SACTCONT_MODES { +// XXX should this be used by other editors too? +enum { /* action (default) */ SACTCONT_ACTION = 0, /* editing of shapekey's IPO block */ @@ -303,11 +365,11 @@ typedef enum SACTCONT_MODES { /* editing of gpencil data */ SACTCONT_GPENCIL, /* dopesheet */ - SACTCONT_DOPESHEET -} SACTCONTEXT_MODES; + SACTCONT_DOPESHEET, +} eAnimEdit_Context; -/* SpaceAction AutoSnap Settings (also used by SpaceNLA) */ -typedef enum SACTSNAP_MODES { +/* SpaceAction AutoSnap Settings (also used by other Animation Editors) */ +enum { /* no auto-snap */ SACTSNAP_OFF = 0, /* snap to 1.0 frame/second intervals */ @@ -316,75 +378,47 @@ typedef enum SACTSNAP_MODES { SACTSNAP_FRAME, /* snap to nearest marker */ SACTSNAP_MARKER, -} SACTSNAP_MODES; - - -/* --------- Pose Flags --------------- */ +} eAnimEdit_AutoSnap; -/* Pose->flag */ -typedef enum POSE_FLAG { - /* results in armature_rebuild_pose being called */ - POSE_RECALC = (1<<0), - /* prevents any channel from getting overridden by anim from IPO */ - POSE_LOCKED = (1<<1), - /* clears the POSE_LOCKED flag for the next time the pose is evaluated */ - POSE_DO_UNLOCK = (1<<2), - /* pose has constraints which depend on time (used when depsgraph updates for a new frame) */ - POSE_CONSTRAINTS_TIMEDEPEND = (1<<3), - /* recalculate bone paths */ - POSE_RECALCPATHS = (1<<4), -} POSE_FLAG; -/* PoseChannel (transform) flags */ -enum { - POSE_LOC = 0x0001, - POSE_ROT = 0x0002, - POSE_SIZE = 0x0004, - POSE_IK_MAT = 0x0008, - POSE_UNUSED2 = 0x0010, - POSE_UNUSED3 = 0x0020, - POSE_UNUSED4 = 0x0040, - POSE_UNUSED5 = 0x0080, - POSE_HAS_IK = 0x0100, - POSE_CHAIN = 0x0200, - POSE_DONE = 0x0400, - POSE_KEY = 0x1000, - POSE_STRIDE = 0x2000 -}; - -/* PoseChannel constflag (constraint detection) */ -typedef enum PCHAN_CONSTFLAG { - PCHAN_HAS_IK = (1<<0), - PCHAN_HAS_CONST = (1<<1), - /* only used for drawing Posemode, not stored in channel */ - PCHAN_HAS_ACTION = (1<<2), - PCHAN_HAS_TARGET = (1<<3), - /* only for drawing Posemode too */ - PCHAN_HAS_STRIDE = (1<<4) -} PCHAN_CONSTFLAG; +/* ************************************************ */ +/* Legacy Data */ -/* PoseChannel->ikflag */ -typedef enum PCHAN_IKFLAG { - BONE_IK_NO_XDOF = (1<<0), - BONE_IK_NO_YDOF = (1<<1), - BONE_IK_NO_ZDOF = (1<<2), - - BONE_IK_XLIMIT = (1<<3), - BONE_IK_YLIMIT = (1<<4), - BONE_IK_ZLIMIT = (1<<5), +/* WARNING: Action Channels are now depreceated... they were part of the old animation system! + * (ONLY USED FOR DO_VERSIONS...) + * + * Action Channels belong to Actions. They are linked with an IPO block, and can also own + * Constraint Channels in certain situations. + * + * Action-Channels can only belong to one group at a time, but they still live the Action's + * list of achans (to preserve backwards compatability, and also minimise the code + * that would need to be recoded). Grouped achans are stored at the start of the list, according + * to the position of the group in the list, and their position within the group. + */ +typedef struct bActionChannel { + struct bActionChannel *next, *prev; + bActionGroup *grp; /* Action Group this Action Channel belongs to */ - BONE_IK_NO_XDOF_TEMP = (1<<10), - BONE_IK_NO_YDOF_TEMP = (1<<11), - BONE_IK_NO_ZDOF_TEMP = (1<<12) -} PCHAN_IKFLAG; + struct Ipo *ipo; /* IPO block this action channel references */ + ListBase constraintChannels; /* Constraint Channels (when Action Channel represents an Object or Bone) */ + + int flag; /* settings accessed via bitmapping */ + char name[32]; /* channel name */ + int temp; /* temporary setting - may be used to indicate group that channel belongs to during syncing */ +} bActionChannel; + +/* Action Channel flags (ONLY USED FOR DO_VERSIONS...) */ +typedef enum ACHAN_FLAG { + ACHAN_SELECTED = (1<<0), + ACHAN_HILIGHTED = (1<<1), + ACHAN_HIDDEN = (1<<2), + ACHAN_PROTECTED = (1<<3), + ACHAN_EXPANDED = (1<<4), + ACHAN_SHOWIPO = (1<<5), + ACHAN_SHOWCONS = (1<<6), + ACHAN_MOVED = (1<<31), +} ACHAN_FLAG; -/* PoseChannel->rotmode */ -typedef enum PCHAN_ROTMODE { - /* quaternion rotations (default, and for older Blender versions) */ - PCHAN_ROT_QUAT = 0, - /* euler rotations (xyz only) */ - PCHAN_ROT_EUL, -} PCHAN_ROTMODE; #endif diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h index 98ec0da8f21..d3bf525208f 100644 --- a/source/blender/makesdna/DNA_anim_types.h +++ b/source/blender/makesdna/DNA_anim_types.h @@ -11,6 +11,7 @@ extern "C" { #include "DNA_ID.h" #include "DNA_listBase.h" +#include "DNA_action_types.h" #include "DNA_curve_types.h" /* ************************************************ */ @@ -262,85 +263,11 @@ enum { /* ************************************************ */ /* 'Action' Datatypes */ -/* Groups -------------------------------------- */ - -#if 0 - -/* Action-Channel Group (agrp) - - * These are stored as a list per-Action, and are only used to - * group that Action's channels in an Animation Editor. - * - * Even though all FCurves live in a big list per Action, each group they are in also - * holds references to the achans within that list which belong to it. Care must be taken to - * ensure that action-groups never end up being the sole 'owner' of a channel. - * - * This is also exploited for bone-groups. Bone-Groups are stored per bPose, and are used - * primarily to colour bones in the 3d-view. There are other benefits too, but those are mostly related - * to Action-Groups. - */ -typedef struct bActionGroup { - struct ActionGroup *next, *prev; - - ListBase channels; /* Note: this must not be touched by standard listbase functions which would clear links to other channels */ - - int flag; /* settings for this action-group */ - int customCol; /* index of custom color set to use when used for bones (0=default - used for all old files, -1=custom set) */ - char name[64]; /* name of the group */ - - ThemeWireColor cs; /* color set to use when customCol == -1 */ -} bActionGroup; - -/* Action Group flags */ -enum { - AGRP_SELECTED = (1<<0), - AGRP_ACTIVE = (1<<1), - AGRP_PROTECTED = (1<<2), - AGRP_EXPANDED = (1<<3), - - AGRP_TEMP = (1<<30), - AGRP_MOVED = (1<<31) -} eActionGroup_Flag; - -#endif - -/* Actions -------------------------------------- */ - -/* Action - reusable F-Curve 'bag' (act) - * - * This contains F-Curves that may affect settings from more than one ID blocktype and/or - * datablock (i.e. sub-data linked/used directly to the ID block that the animation data is linked to), - * but with the restriction that the other unrelated data (i.e. data that is not directly used or linked to - * by the source ID block). - * - * It serves as a 'unit' of reusable animation information (i.e. keyframes/motion data), that - * affects a group of related settings (as defined by the user). +/* NOTE: Although these are part of the Animation System, + * they are not stored here... see DNA_action_types.h instead */ -// XXX use this as drop-in replacement at some point... -typedef struct nAction { - ID id; /* ID-serialisation for relinking */ - - ListBase curves; /* function-curves (FCurve) */ - ListBase chanbase; /* legacy data - Action Channels (bActionChannel) in pre-2.5 animation system */ - ListBase groups; /* groups of function-curves (bActionGroup) */ - ListBase markers; /* markers local to the Action (used to provide Pose-Libraries) */ - - int flag; /* settings for this action */ - int active_marker; /* index of the active marker */ -} nAction; - - -/* Flags for the action */ -enum { - /* flags for displaying in UI */ - ACT_EXPANDED = (1<<0), - ACT_SELECTED = (1<<1), - - /* flags for evaluation/editing */ - ACT_MUTED = (1<<9), - ACT_PROTECTED = (1<<10), -} eAction_Flags; + /* ************************************************ */ /* Animation Reuse - i.e. users of Actions */ @@ -373,7 +300,7 @@ typedef struct AnimMapPair { typedef struct AnimMapper { struct AnimMapper *next, *prev; - nAction *target; /* target action */ + bAction *target; /* target action */ ListBase mappings; /* remapping table (bAnimMapPair) */ } AnimMapper; @@ -403,7 +330,7 @@ typedef struct AnimMapper { typedef struct NlaStrip { struct NlaStrip *next, *prev; - nAction *act; /* Action that is referenced by this strip */ + bAction *act; /* Action that is referenced by this strip */ AnimMapper *remap; /* Remapping info this strip (for tweaking correspondance of action with context) */ ListBase modifiers; /* NLA Modifiers */ @@ -538,7 +465,7 @@ typedef struct AnimOverride { */ typedef struct AnimData { /* active action - acts as the 'tweaking track' for the NLA */ - nAction *action; + bAction *action; /* remapping-info for active action - should only be used if needed * (for 'foreign' actions that aren't working correctly) */ diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index ecda0004042..bde65329371 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -45,6 +45,7 @@ struct Ipo; struct Key; struct Material; struct VFont; +struct AnimData; /* These two Lines with # tell makesdna this struct can be excluded. */ # @@ -135,6 +136,7 @@ typedef struct TextBox { typedef struct Curve { ID id; + struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */ struct BoundBox *bb; diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 49711963870..6c8ce968ac2 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -39,6 +39,7 @@ struct SpaceNode; struct bNodeLink; struct bNodeType; struct bNodeGroup; +struct AnimData; #define NODE_MAXSTR 32 @@ -162,6 +163,7 @@ typedef struct bNodeLink { /* only re-usable node trees are in the library though, materials and textures allocate own tree struct */ typedef struct bNodeTree { ID id; + struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */ ListBase nodes, links; |