remove unused includes
[blender.git] / source / blender / editors / armature / poselib.c
index efc7610508370abc1f930ae242227ddff2b1feee..756dee2494be7f358becd2a2727831d391c77e89 100644 (file)
 #include "BKE_action.h"
 #include "BKE_armature.h"
 #include "BKE_depsgraph.h"
-#include "BKE_modifier.h"
-#include "BKE_object.h"
 
-#include "BKE_global.h"
 #include "BKE_context.h"
 #include "BKE_report.h"
-#include "BKE_utildefines.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -704,8 +700,8 @@ static void poselib_apply_pose (tPoseLib_PreviewData *pld)
        bAction *act= pld->act;
        bActionGroup *agrp;
        
-       BeztEditData bed;
-       BeztEditFunc group_ok_cb;
+       KeyframeEditData ked;
+       KeyframeEditFunc group_ok_cb;
        int frame= 1;
        
        /* get the frame */
@@ -717,15 +713,15 @@ static void poselib_apply_pose (tPoseLib_PreviewData *pld)
        
        /* init settings for testing groups for keyframes */
        group_ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
-       memset(&bed, 0, sizeof(BeztEditData)); 
-       bed.f1= ((float)frame) - 0.5f;
-       bed.f2= ((float)frame) + 0.5f;
+       memset(&ked, 0, sizeof(KeyframeEditData)); 
+       ked.f1= ((float)frame) - 0.5f;
+       ked.f2= ((float)frame) + 0.5f;
        
        
        /* start applying - only those channels which have a key at this point in time! */
        for (agrp= act->groups.first; agrp; agrp= agrp->next) {
                /* check if group has any keyframes */
-               if (ANIM_animchanneldata_keys_bezier_loop(&bed, agrp, ALE_GROUP, NULL, group_ok_cb, NULL, 0)) {
+               if (ANIM_animchanneldata_keyframes_loop(&ked, agrp, ALE_GROUP, NULL, group_ok_cb, NULL, 0)) {
                        /* has keyframe on this frame, so try to get a PoseChannel with this name */
                        pchan= get_pose_channel(pose, agrp->name);
                        
@@ -769,12 +765,19 @@ static void poselib_keytag_pose (bContext *C, Scene *scene, tPoseLib_PreviewData
                        if (pchan) {
                                if (autokeyframe_cfra_can_key(scene, &pld->ob->id)) {
                                        ListBase dsources = {NULL, NULL};
+                                       KeyingSet *ks = NULL;
                                        
-                                       /* get KeyingSet to use */
-                                       // TODO: for getting the KeyingSet used, we should really check which channels were affected
-                                       // TODO: this should get modified so that custom props are taken into account too!
+                                       /* get KeyingSet to use 
+                                        *      - use the active KeyingSet if defined (and user wants to use it for all autokeying), 
+                                        *        or otherwise key transforms only
+                                        */
                                        if (poselib_ks_locrotscale == NULL)
                                                poselib_ks_locrotscale= ANIM_builtin_keyingset_get_named(NULL, "LocRotScale");
+                                        
+                                       if (IS_AUTOKEY_FLAG(ONLYKEYINGSET) && (scene->active_keyingset))
+                                               ks = ANIM_scene_get_active_keyingset(scene);
+                                       else 
+                                               ks = ANIM_builtin_keyingset_get_named(NULL, "LocRotScale");
                                        
                                        /* now insert the keyframe(s) using the Keying Set
                                         *      1) add datasource override for the PoseChannel
@@ -782,7 +785,7 @@ static void poselib_keytag_pose (bContext *C, Scene *scene, tPoseLib_PreviewData
                                         *      3) free the extra info 
                                         */
                                        ANIM_relative_keyingset_add_source(&dsources, &pld->ob->id, &RNA_PoseBone, pchan); 
-                                       ANIM_apply_keyingset(C, &dsources, NULL, poselib_ks_locrotscale, MODIFYKEY_MODE_INSERT, (float)CFRA);
+                                       ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA);
                                        BLI_freelistN(&dsources);
                                        
                                        /* clear any unkeyed tags */
@@ -799,7 +802,7 @@ static void poselib_keytag_pose (bContext *C, Scene *scene, tPoseLib_PreviewData
        }
        
        /* send notifiers for this */
-       WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL);
+       WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
 }
 
 /* Apply the relevant changes to the pose */
@@ -847,7 +850,7 @@ static void poselib_preview_apply (bContext *C, wmOperator *op)
                        /* get search-string */
                        index= pld->search_cursor;
                        
-                       if (IN_RANGE(index, 0, 64)) {
+                       if (index >= 0 && index <= 64) {
                                memcpy(&tempstr[0], &pld->searchstr[0], index);
                                tempstr[index]= '|';
                                memcpy(&tempstr[index+1], &pld->searchstr[index], 64-index);