Revision: 19721
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19721
Author:   aligorith
Date:     2009-04-15 03:10:36 +0200 (Wed, 15 Apr 2009)

Log Message:
-----------
2.5 PoseLib - First steps to get PoseLib to work in 2.5

* Cleaned up Keyframing API to get eliminate some of the problems faced during 
the original implementation of PoseLib, thus reducing code redundancy. 
* Added new Animato evaluation functions specifically for use by PoseLib. 
* Replaced parts of PoseLib code which relied on old animation system to the 
equivalent code for Animato. Notice the much cleaner + saner + compact code!

Next step is to operatorfy the PoseLib tools (while maintaining possibility for 
an API to some things) :)

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/editors/animation/anim_intern.h
    
branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c
    branches/blender2.5/blender/source/blender/editors/animation/keyframing.c
    branches/blender2.5/blender/source/blender/editors/animation/keyingsets.c
    branches/blender2.5/blender/source/blender/editors/armature/poselib.c
    
branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h
    branches/blender2.5/blender/source/blender/editors/include/ED_keyframing.h
    
branches/blender2.5/blender/source/blender/editors/space_action/action_edit.c
    
branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_animsys.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_animsys.h 
2009-04-14 23:57:14 UTC (rev 19720)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_animsys.h 
2009-04-15 01:10:36 UTC (rev 19721)
@@ -12,6 +12,10 @@
 struct KeyingSet;
 struct KS_Path;
 
+struct PointerRNA;
+struct bAction;
+struct AnimMapper;
+
 /* ************************************* */
 /* AnimData API */
 
@@ -50,6 +54,9 @@
 /* ************************************* */
 /* Evaluation API */
 
+/* ------------- Main API -------------------- */
+/* In general, these ones should be called to do all animation evaluation */
+
 /* Evaluation loop for evaluating animation data  */
 void BKE_animsys_evaluate_animdata(struct ID *id, struct AnimData *adt, float 
ctime, short recalc);
 
@@ -57,6 +64,20 @@
 void BKE_animsys_evaluate_all_animation(struct Main *main, float ctime);
 
 
+/* ------------ Specialised API --------------- */
+/* There are a few special tools which require these following functions. They 
are NOT to be used
+ * for standard animation evaluation UNDER ANY CIRCUMSTANCES! 
+ *
+ * i.e. Pose Library (PoseLib) uses some of these for selectively applying 
poses, but 
+ *         Particles/Sequencer performing funky time manipulation is not ok.
+ */
+
+/* Evaluate Action (F-Curve Bag) */
+void animsys_evaluate_action(struct PointerRNA *ptr, struct bAction *act, 
struct AnimMapper *remap, float ctime);
+
+/* Evaluate Action Group */
+void animsys_evaluate_action_group(struct PointerRNA *ptr, struct bAction 
*act, struct bActionGroup *agrp, struct AnimMapper *remap, float ctime);
+
 /* ************************************* */
 
 #endif /* BKE_ANIM_SYS_H*/

Modified: 
branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c     
2009-04-14 23:57:14 UTC (rev 19720)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c     
2009-04-15 01:10:36 UTC (rev 19721)
@@ -504,8 +504,29 @@
 /* ***************************************** */
 /* Actions Evaluation */
 
+/* Evaluate Action Group */
+void animsys_evaluate_action_group (PointerRNA *ptr, bAction *act, 
bActionGroup *agrp, AnimMapper *remap, float ctime)
+{
+       FCurve *fcu;
+       
+       /* check if mapper is appropriate for use here (we set to NULL if it's 
inappropriate) */
+       if ELEM(NULL, act, agrp) return;
+       if ((remap) && (remap->target != act)) remap= NULL;
+       
+       /* calculate then execute each curve */
+       for (fcu= agrp->channels.first; (fcu) && (fcu->grp == agrp); fcu= 
fcu->next) 
+       {
+               /* check if this curve should be skipped */
+               if ((fcu->flag & (FCURVE_MUTED|FCURVE_DISABLED)) == 0) 
+               {
+                       calculate_fcurve(fcu, ctime);
+                       animsys_execute_fcurve(ptr, remap, fcu); 
+               }
+       }
+}
+
 /* Evaluate Action (F-Curve Bag) */
-static void animsys_evaluate_action (PointerRNA *ptr, bAction *act, AnimMapper 
*remap, float ctime)
+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;
@@ -863,7 +884,10 @@
        // TODO...
        
        /* objects */
-       EVAL_ANIM_IDS(main->object.first, ADT_RECALC_ANIM);
+               /* ADT_RECALC_ANIM doesn't need to be supplied here, since 
object AnimData gets 
+                * this tagged by Depsgraph on framechange 
+                */
+       EVAL_ANIM_IDS(main->object.first, /*ADT_RECALC_ANIM*/0); 
        
        /* worlds */
        EVAL_ANIM_IDS(main->world.first, ADT_RECALC_ANIM);

Modified: 
branches/blender2.5/blender/source/blender/editors/animation/anim_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_intern.h  
2009-04-14 23:57:14 UTC (rev 19720)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_intern.h  
2009-04-15 01:10:36 UTC (rev 19721)
@@ -5,36 +5,14 @@
 #ifndef ANIM_INTERN_H
 #define ANIM_INTERN_H
 
-/* ----------- Common Keyframe Destination Sources ------------ */
-/* (used as part of KeyingSets/Keyframing interface as separation from 
context) */
 
-/* temporary struct to gather data combos to keyframe */
-typedef struct bCommonKeySrc {
-       struct bCommonKeySrc *next, *prev;
-               
-               /* general data/destination-source settings */
-       ID *id;                                 /* id-block this comes from */
-       
-               /* specific cases */
-       bPoseChannel *pchan;    
-       bConstraint *con;
-} bCommonKeySrc;
-
 /* KeyingSets/Keyframing Interface ------------- */
 
 /* list of builtin KeyingSets (defined in keyingsets.c) */
 extern ListBase builtin_keyingsets;
 
-/* mode for modify_keyframes */
-enum {
-       MODIFYKEY_MODE_INSERT = 0,
-       MODIFYKEY_MODE_DELETE,
-} eModifyKey_Modes;
-
 short keyingset_context_ok_poll(bContext *C, KeyingSet *ks);
 
 short modifykey_get_context_data (bContext *C, ListBase *dsources, KeyingSet 
*ks);
 
-int modify_keyframes(bContext *C, ListBase *dsources, KeyingSet *ks, short 
mode, float cfra);
-
 #endif // ANIM_INTERN_H

Modified: 
branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c   
    2009-04-14 23:57:14 UTC (rev 19720)
+++ 
branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c   
    2009-04-15 01:10:36 UTC (rev 19721)
@@ -239,6 +239,36 @@
        return 0;
 }
 
+/* This function is used to apply operation to all keyframes, regardless of 
the type without needed an AnimListElem wrapper */
+short ANIM_animchanneldata_keys_bezier_loop(BeztEditData *bed, void *data, int 
keytype, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb, int 
filterflag)
+{
+       /* sanity checks */
+       if (data == NULL)
+               return 0;
+       
+       /* method to use depends on the type of keyframe data */
+       switch (keytype) {
+               /* direct keyframe data (these loops are exposed) */
+               case ALE_FCURVE: /* F-Curve */
+                       return ANIM_fcurve_keys_bezier_loop(bed, data, bezt_ok, 
bezt_cb, fcu_cb);
+               
+               /* indirect 'summaries' (these are not exposed directly) 
+                * NOTE: must keep this code in sync with the drawing code and 
also the filtering code!
+                */
+               case ALE_GROUP: /* action group */
+                       return agrp_keys_bezier_loop(bed, (bActionGroup *)data, 
bezt_ok, bezt_cb, fcu_cb);
+               case ALE_ACT: /* action */
+                       return act_keys_bezier_loop(bed, (bAction *)data, 
bezt_ok, bezt_cb, fcu_cb);
+                       
+               case ALE_OB: /* object */
+                       return ob_keys_bezier_loop(bed, (Object *)data, 
bezt_ok, bezt_cb, fcu_cb, filterflag);
+               case ALE_SCE: /* scene */
+                       return scene_keys_bezier_loop(bed, (Scene *)data, 
bezt_ok, bezt_cb, fcu_cb, filterflag);
+       }
+       
+       return 0;
+}
+
 /* ************************************************************************** 
*/
 /* Keyframe Integrity Tools */
 

Modified: 
branches/blender2.5/blender/source/blender/editors/animation/keyframing.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/keyframing.c   
2009-04-14 23:57:14 UTC (rev 19720)
+++ branches/blender2.5/blender/source/blender/editors/animation/keyframing.c   
2009-04-15 01:10:36 UTC (rev 19721)
@@ -55,20 +55,13 @@
 /* ******************************************* */
 /* Animation Data Validation */
 
-/* Get (or add relevant data to be able to do so) F-Curve from the Active 
Action, 
- * for the given Animation Data block. This assumes that all the destinations 
are valid.
+/* Get (or add relevant data to be able to do so) the Active Action for the 
given 
+ * Animation Data block, given an ID block where the Animation Data should 
reside.
  */
-FCurve *verify_fcurve (ID *id, const char group[], const char rna_path[], 
const int array_index, short add)
+bAction *verify_adt_action (ID *id, short add)
 {
        AnimData *adt;
-       bAction *act;
-       bActionGroup *grp;
-       FCurve *fcu;
        
-       /* sanity checks */
-       if ELEM(NULL, id, rna_path)
-               return NULL;
-       
        /* init animdata if none available yet */
        adt= BKE_animdata_from_id(id);
        if ((adt == NULL) && (add))
@@ -82,8 +75,23 @@
        // TODO: need some wizardry to handle NLA stuff correct
        if ((adt->action == NULL) && (add))
                adt->action= add_empty_action("Action");
-       act= adt->action;
                
+       /* return the action */
+       return adt->action;
+}
+
+/* Get (or add relevant data to be able to do so) F-Curve from the Active 
Action, 
+ * for the given Animation Data block. This assumes that all the destinations 
are valid.
+ */
+FCurve *verify_fcurve (bAction *act, const char group[], const char 
rna_path[], const int array_index, short add)
+{
+       bActionGroup *grp;
+       FCurve *fcu;
+       
+       /* sanity checks */
+       if ELEM(NULL, act, rna_path)
+               return NULL;
+               
        /* try to find f-curve matching for this setting 
         *      - add if not found and allowed to add one
         *              TODO: add auto-grouping support? how this works will 
need to be resolved
@@ -695,7 +703,7 @@
  *     the keyframe insertion. These include the 'visual' keyframing modes, 
quick refresh,
  *     and extra keyframe filtering.
  */
-short insertkey (ID *id, const char group[], const char rna_path[], int 
array_index, float cfra, short flag)
+short insert_keyframe (ID *id, bAction *act, const char group[], const char 
rna_path[], int array_index, float cfra, short flag)
 {      
        PointerRNA id_ptr, ptr;
        PropertyRNA *prop;
@@ -708,8 +716,10 @@
                return 0;
        }
        
-       /* get F-Curve */
-       fcu= verify_fcurve(id, group, rna_path, array_index, 1);
+       /* get F-Curve - if no action is provided, keyframe to the default one 
attached to this ID-block */
+       if (act == NULL)
+               act= verify_adt_action(id, 1);
+       fcu= verify_fcurve(act, group, rna_path, array_index, 1);
        
        /* only continue if we have an F-Curve to add keyframe to */
        if (fcu) {
@@ -797,22 +807,24 @@
  *     The flag argument is used for special settings that alter the behaviour 
of
  *     the keyframe deletion. These include the quick refresh options.
  */
-short deletekey (ID *id, const char group[], const char rna_path[], int 
array_index, float cfra, short flag)
+short delete_keyframe (ID *id, bAction *act, const char group[], const char 
rna_path[], int array_index, float cfra, short flag)
 {
-       AnimData *adt;
-       FCurve *fcu;
+       FCurve *fcu = NULL;
        
        /* get F-Curve
         * Note: here is one of the places where we don't want new Action + 
F-Curve added!

@@ 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