Revision: 18549 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18549 Author: aligorith Date: 2009-01-17 06:36:58 +0100 (Sat, 17 Jan 2009)
Log Message: ----------- 2.5 - AnimData fixes * Made AnimData blocks be stored as pointer instead of directly in the ID-datablock, so that fewer files will need to be recompiled everytime some animation settings change. * Tried to fix some of the compiler errors that pop up in Yafray code. If this commit doesn't fix it, just disable Yafray code for now (WITH_BF_YAFRAY=0 for scons)... Modified Paths: -------------- branches/blender2.5/blender/source/blender/blenkernel/BKE_animsys.h branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c branches/blender2.5/blender/source/blender/blenkernel/intern/library.c branches/blender2.5/blender/source/blender/editors/animation/keyframing.c branches/blender2.5/blender/source/blender/makesdna/DNA_anim_types.h branches/blender2.5/blender/source/blender/makesdna/DNA_camera_types.h branches/blender2.5/blender/source/blender/makesdna/DNA_key_types.h branches/blender2.5/blender/source/blender/makesdna/DNA_lamp_types.h branches/blender2.5/blender/source/blender/makesdna/DNA_material_types.h branches/blender2.5/blender/source/blender/makesdna/DNA_object_types.h branches/blender2.5/blender/source/blender/makesdna/DNA_scene_types.h branches/blender2.5/blender/source/blender/makesdna/DNA_texture_types.h branches/blender2.5/blender/source/blender/makesdna/DNA_world_types.h Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_animsys.h =================================================================== --- branches/blender2.5/blender/source/blender/blenkernel/BKE_animsys.h 2009-01-17 03:51:13 UTC (rev 18548) +++ branches/blender2.5/blender/source/blender/blenkernel/BKE_animsys.h 2009-01-17 05:36:58 UTC (rev 18549) @@ -16,6 +16,9 @@ /* Get AnimData from the given ID-block. */ 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); + /* ************************************* */ // TODO: overrides, remapping, and path-finding api's 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-17 03:51:13 UTC (rev 18548) +++ branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c 2009-01-17 05:36:58 UTC (rev 18549) @@ -25,7 +25,7 @@ /* AnimData API */ /* Get AnimData from the given ID-block. In order for this to work, we assume that - * the AnimData block is stored immediately after the given ID-block in the struct, + * the AnimData pointer is stored immediately after the given ID-block in the struct, * as per IdAdtTemplate. */ AnimData *BKE_animdata_from_id (ID *id) @@ -36,7 +36,7 @@ /* 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 + * AnimData that way */ // TODO: finish adding this for the other blocktypes switch (GS(id->name)) { @@ -47,7 +47,7 @@ case ID_SCE: { IdAdtTemplate *iat= (IdAdtTemplate *)id; - return &(iat->adt); + return iat->adt; } break; } @@ -56,6 +56,41 @@ return NULL; } +/* Add AnimData to 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. Also note that + */ +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 AnimData that + * way + */ + // 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; + + iat->adt= MEM_callocN(sizeof(AnimData), "AnimData"); + return iat->adt; + } + break; + } + + /* no AnimData (ID-block does not contain this data) */ + return NULL; +} + + /* 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 @@ -541,8 +576,8 @@ /* objects */ for (id= main->object.first; id; id= id->next) { - IdAdtTemplate *iat= (IdAdtTemplate *)id; - BKE_animsys_evaluate_animdata(id, &iat->adt, ctime, ADT_RECALC_ANIM); + AnimData *adt= BKE_animdata_from_id(id); + BKE_animsys_evaluate_animdata(id, adt, ctime, ADT_RECALC_ANIM); } } Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/library.c =================================================================== --- branches/blender2.5/blender/source/blender/blenkernel/intern/library.c 2009-01-17 03:51:13 UTC (rev 18548) +++ branches/blender2.5/blender/source/blender/blenkernel/intern/library.c 2009-01-17 05:36:58 UTC (rev 18549) @@ -78,6 +78,7 @@ #include "DNA_particle_types.h" #include "DNA_space_types.h" #include "DNA_windowmanager_types.h" +#include "DNA_anim_types.h" #include "BLI_blenlib.h" #include "BLI_dynstr.h" Modified: branches/blender2.5/blender/source/blender/editors/animation/keyframing.c =================================================================== --- branches/blender2.5/blender/source/blender/editors/animation/keyframing.c 2009-01-17 03:51:13 UTC (rev 18548) +++ branches/blender2.5/blender/source/blender/editors/animation/keyframing.c 2009-01-17 05:36:58 UTC (rev 18549) @@ -97,14 +97,24 @@ * for the given Animation Data block */ // TODO: should we check if path is valid? For now, assume that it's already set OK by caller... -FCurve *verify_fcurve (AnimData *adt, const char rna_path[], const int array_index, short add) +FCurve *verify_fcurve (ID *id, const char rna_path[], const int array_index, short add) { + AnimData *adt; nAction *act; FCurve *fcu; /* sanity checks */ - if ELEM(NULL, adt, rna_path) + if ELEM(NULL, id, rna_path) return NULL; + + /* init animdata if none available yet */ + adt= BKE_animdata_from_id(id); + if ((adt == NULL) && (add)) + adt= BKE_id_add_animdata(id); + if (adt == NULL) { + /* if still none (as not allowed to add, or ID doesn't have animdata for some reason) */ + return NULL; + } /* init action if none available yet */ // TODO: need some wizardry to handle NLA stuff correct @@ -704,7 +714,6 @@ { PointerRNA id_ptr, ptr; PropertyRNA *prop; - AnimData *adt; FCurve *fcu; /* validate pointer first - exit if failure*/ @@ -715,8 +724,7 @@ } /* get F-Curve */ - adt= BKE_animdata_from_id(id); - fcu= verify_fcurve(adt, rna_path, array_index, 1); + fcu= verify_fcurve(id, rna_path, array_index, 1); /* only continue if we have an F-Curve to add keyframe to */ if (fcu) { @@ -802,8 +810,7 @@ */ short deletekey (ID *id, const char rna_path[], int array_index, float cfra, short flag) { - AnimData *adt= BKE_animdata_from_id(id); - nAction *act; + AnimData *adt; FCurve *fcu; /* get F-Curve @@ -811,11 +818,12 @@ * so 'add' var must be 0 */ // XXX we don't check the validity of the path here yet, but it should be ok... - fcu= verify_fcurve(adt, rna_path, array_index, 0); - act= adt->action; + fcu= verify_fcurve(id, rna_path, array_index, 0); + adt= BKE_animdata_from_id(id); /* only continue if we have an ipo-curve to remove keyframes from */ - if (act && fcu) { + if (adt && adt->action && fcu) { + nAction *act= adt->action; short found = -1; int i; @@ -2107,12 +2115,13 @@ { Object *ob= base->object; ID *id= (ID *)ob; - nAction *act= ob->adt.action; FCurve *fcu, *fcn; short success= 0; /* loop through all curves in animdata and delete keys on this frame */ - if (act) { + if (ob->adt) { + nAction *act= ob->adt->action; + for (fcu= act->curves.first; fcu; fcu= fcn) { fcn= fcu->next; success+= deletekey(id, fcu->rna_path, fcu->array_index, cfra, 0); @@ -2197,12 +2206,12 @@ short object_frame_has_keyframe (Object *ob, float frame, short filter) { /* error checking */ - if (ob == NULL) + if (ELEM(NULL, ob, ob->adt)) return 0; /* check own animation data - specifically, the action it contains */ - if (ob->adt.action) { - if (action_frame_has_keyframe(ob->adt.action, frame, filter)) + if (ob->adt->action) { + if (action_frame_has_keyframe(ob->adt->action, frame, filter)) return 1; } Modified: branches/blender2.5/blender/source/blender/makesdna/DNA_anim_types.h =================================================================== --- branches/blender2.5/blender/source/blender/makesdna/DNA_anim_types.h 2009-01-17 03:51:13 UTC (rev 18548) +++ branches/blender2.5/blender/source/blender/makesdna/DNA_anim_types.h 2009-01-17 05:36:58 UTC (rev 18549) @@ -5,6 +5,10 @@ #ifndef DNA_ANIM_TYPES_H #define DNA_ANIM_TYPES_H +#ifdef __cplusplus +extern "C" { +#endif + #include "DNA_ID.h" #include "DNA_listBase.h" #include "DNA_curve_types.h" @@ -579,9 +583,13 @@ */ typedef struct IdAdtTemplate { ID id; - AnimData adt; + AnimData *adt; } IdAdtTemplate; /* ************************************************ */ +#ifdef __cplusplus +}; +#endif + #endif /* DNA_ANIM_TYPES_H */ Modified: branches/blender2.5/blender/source/blender/makesdna/DNA_camera_types.h =================================================================== --- branches/blender2.5/blender/source/blender/makesdna/DNA_camera_types.h 2009-01-17 03:51:13 UTC (rev 18548) +++ branches/blender2.5/blender/source/blender/makesdna/DNA_camera_types.h 2009-01-17 05:36:58 UTC (rev 18549) @@ -32,7 +32,6 @@ #define DNA_CAMERA_TYPES_H #include "DNA_ID.h" -#include "DNA_anim_types.h" #include "DNA_scriptlink_types.h" #ifdef __cplusplus @@ -45,7 +44,7 @@ typedef struct Camera { ID id; - struct AnimData adt; /* animation data (must be immediately after id for utilities to use it) */ + struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */ short type, flag; float passepartalpha, angle; Modified: branches/blender2.5/blender/source/blender/makesdna/DNA_key_types.h =================================================================== --- branches/blender2.5/blender/source/blender/makesdna/DNA_key_types.h 2009-01-17 03:51:13 UTC (rev 18548) +++ branches/blender2.5/blender/source/blender/makesdna/DNA_key_types.h 2009-01-17 05:36:58 UTC (rev 18549) @@ -33,8 +33,8 @@ #include "DNA_listBase.h" #include "DNA_ID.h" -#include "DNA_anim_types.h" +struct AnimData; struct Ipo; typedef struct KeyBlock { @@ -57,7 +57,7 @@ typedef struct Key { ID id; - struct AnimData adt; /* animation data (must be immediately after id for utilities to use it) */ + struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */ KeyBlock *refkey; char elemstr[32]; Modified: branches/blender2.5/blender/source/blender/makesdna/DNA_lamp_types.h =================================================================== --- branches/blender2.5/blender/source/blender/makesdna/DNA_lamp_types.h 2009-01-17 03:51:13 UTC (rev 18548) +++ branches/blender2.5/blender/source/blender/makesdna/DNA_lamp_types.h 2009-01-17 05:36:58 UTC (rev 18549) @@ -32,7 +32,6 @@ #define DNA_LAMP_TYPES_H #include "DNA_ID.h" -#include "DNA_anim_types.h" #include "DNA_scriptlink_types.h" #ifndef MAX_MTEX @@ -41,11 +40,12 @@ struct MTex; struct CurveMapping; +struct AnimData; struct Ipo; typedef struct Lamp { ID id; - struct AnimData adt; /* animation data (must be immediately after id for utilities to use it) */ + struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */ short type, flag; int mode; @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs