Revision: 40907
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40907
Author:   campbellbarton
Date:     2011-10-10 12:56:21 +0000 (Mon, 10 Oct 2011)
Log Message:
-----------
fix [#28850] With "Auto-keyframe" on, the "Selection to Cursor" option doesn't 
create keyframe.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/animation/keyframing.c
    trunk/blender/source/blender/editors/armature/poseobject.c
    trunk/blender/source/blender/editors/include/ED_keyframing.h
    trunk/blender/source/blender/editors/object/object_transform.c
    trunk/blender/source/blender/editors/space_view3d/view3d_snap.c

Modified: trunk/blender/source/blender/editors/animation/keyframing.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyframing.c 2011-10-10 
10:35:18 UTC (rev 40906)
+++ trunk/blender/source/blender/editors/animation/keyframing.c 2011-10-10 
12:56:21 UTC (rev 40907)
@@ -1748,3 +1748,56 @@
 }
 
 /* ************************************************** */
+
+int ED_autokeyframe_object(bContext *C, Scene *scene, Object *ob, KeyingSet 
*ks)
+{
+       /* auto keyframing */
+       if (autokeyframe_cfra_can_key(scene, &ob->id)) {
+               ListBase dsources = {NULL, NULL};
+
+               /* now insert the keyframe(s) using the Keying Set
+                *      1) add datasource override for the Object
+                *      2) insert keyframes
+                *      3) free the extra info
+                */
+               ANIM_relative_keyingset_add_source(&dsources, &ob->id, NULL, 
NULL);
+               ANIM_apply_keyingset(C, &dsources, NULL, ks, 
MODIFYKEY_MODE_INSERT, (float)CFRA);
+               BLI_freelistN(&dsources);
+
+               return TRUE;
+       }
+       else {
+               return FALSE;
+       }
+}
+
+int ED_autokeyframe_pchan(bContext *C, Scene *scene, Object *ob, bPoseChannel 
*pchan, KeyingSet *ks)
+{
+       if (autokeyframe_cfra_can_key(scene, &ob->id)) {
+               ListBase dsources = {NULL, NULL};
+
+               /* now insert the keyframe(s) using the Keying Set
+                *      1) add datasource override for the PoseChannel
+                *      2) insert keyframes
+                *      3) free the extra info
+                */
+               ANIM_relative_keyingset_add_source(&dsources, &ob->id, 
&RNA_PoseBone, pchan);
+               ANIM_apply_keyingset(C, &dsources, NULL, ks, 
MODIFYKEY_MODE_INSERT, (float)CFRA);
+               BLI_freelistN(&dsources);
+
+               /* clear any unkeyed tags */
+               if (pchan->bone) {
+                       pchan->bone->flag &= ~BONE_UNKEYED;
+               }
+
+               return TRUE;
+       }
+       else {
+               /* add unkeyed tags */
+               if (pchan->bone) {
+                       pchan->bone->flag |= BONE_UNKEYED;
+               }
+
+               return FALSE;
+       }
+}

Modified: trunk/blender/source/blender/editors/armature/poseobject.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poseobject.c  2011-10-10 
10:35:18 UTC (rev 40906)
+++ trunk/blender/source/blender/editors/armature/poseobject.c  2011-10-10 
12:56:21 UTC (rev 40907)
@@ -1149,7 +1149,10 @@
        bPoseChannel *chan;
        int flip= RNA_boolean_get(op->ptr, "flipped");
        int selOnly= RNA_boolean_get(op->ptr, "selected_mask");
-       
+
+       /* get KeyingSet to use */
+       KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, "LocRotScale");
+
        /* sanity checks */
        if ELEM(NULL, ob, ob->pose)
                return OPERATOR_CANCELLED;
@@ -1166,7 +1169,7 @@
                if (CTX_DATA_COUNT(C, selected_pose_bones) == 0)
                        selOnly = 0;
        }
-       
+
        /* Safely merge all of the channels in the buffer pose into any 
existing pose */
        for (chan= g_posebuf->chanbase.first; chan; chan=chan->next) {
                if (chan->flag & POSE_KEY) {
@@ -1175,30 +1178,7 @@
                        
                        if (pchan) {
                                /* keyframing tagging for successful paste */
-                               if (autokeyframe_cfra_can_key(scene, &ob->id)) {
-                                       ListBase dsources = {NULL, NULL};
-                                       
-                                       /* get KeyingSet to use */
-                                       KeyingSet *ks = 
ANIM_get_keyingset_for_autokeying(scene, "LocRotScale");
-                                       
-                                       /* now insert the keyframe(s) using the 
Keying Set
-                                        *      1) add datasource override for 
the PoseChannel
-                                        *      2) insert keyframes
-                                        *      3) free the extra info 
-                                        */
-                                       
ANIM_relative_keyingset_add_source(&dsources, &ob->id, &RNA_PoseBone, pchan); 
-                                       ANIM_apply_keyingset(C, &dsources, 
NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA);
-                                       BLI_freelistN(&dsources);
-                                       
-                                       /* clear any unkeyed tags */
-                                       if (chan->bone)
-                                               chan->bone->flag &= 
~BONE_UNKEYED;
-                               }
-                               else {
-                                       /* add unkeyed tags */
-                                       if (chan->bone)
-                                               chan->bone->flag |= 
BONE_UNKEYED;
-                               }
+                               ED_autokeyframe_pchan(C, scene, ob, pchan, ks);
                        }
                }
        }
@@ -2194,29 +2174,8 @@
                if (pchan->rotmode == ROT_MODE_QUAT) {
                        /* quaternions have 720 degree range */
                        negate_v4(pchan->quat);
-                       
-                       /* tagging */
-                       if (autokeyframe_cfra_can_key(scene, &ob->id)) {
-                               ListBase dsources = {NULL, NULL};
-                               
-                               /* now insert the keyframe(s) using the Keying 
Set
-                                *      1) add datasource override for the 
PoseChannel
-                                *      2) insert keyframes
-                                *      3) free the extra info 
-                                */
-                               ANIM_relative_keyingset_add_source(&dsources, 
&ob->id, &RNA_PoseBone, pchan); 
-                               ANIM_apply_keyingset(C, &dsources, NULL, ks, 
MODIFYKEY_MODE_INSERT, (float)CFRA);
-                               BLI_freelistN(&dsources);
-                               
-                               /* clear any unkeyed tags */
-                               if (pchan->bone)
-                                       pchan->bone->flag &= ~BONE_UNKEYED;
-                       }
-                       else {
-                               /* add unkeyed tags */
-                               if (pchan->bone)
-                                       pchan->bone->flag |= BONE_UNKEYED;
-                       }
+
+                       ED_autokeyframe_pchan(C, scene, ob, pchan, ks);
                }
        }
        CTX_DATA_END;

Modified: trunk/blender/source/blender/editors/include/ED_keyframing.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_keyframing.h        
2011-10-10 10:35:18 UTC (rev 40906)
+++ trunk/blender/source/blender/editors/include/ED_keyframing.h        
2011-10-10 12:56:21 UTC (rev 40907)
@@ -313,6 +313,11 @@
        ANIMFILTER_KEYS_NOSKEY          = (1<<10),              /* don't 
include shape keys (for geometry) */
 } eAnimFilterFlags;
 
+/* utility funcs for auto keyframe */
+int ED_autokeyframe_object(struct bContext *C, struct Scene *scene, struct 
Object *ob, struct KeyingSet *ks);
+int ED_autokeyframe_pchan(struct bContext *C, struct Scene *scene, struct 
Object *ob, struct bPoseChannel *pchan, struct KeyingSet *ks);
+
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/blender/source/blender/editors/object/object_transform.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_transform.c      
2011-10-10 10:35:18 UTC (rev 40906)
+++ trunk/blender/source/blender/editors/object/object_transform.c      
2011-10-10 12:56:21 UTC (rev 40907)
@@ -230,21 +230,9 @@
                if (!(ob->mode & OB_MODE_WEIGHT_PAINT)) {
                        /* run provided clearing function */
                        clear_func(ob);
-                       
-                       /* auto keyframing */
-                       if (autokeyframe_cfra_can_key(scene, &ob->id)) {
-                               ListBase dsources = {NULL, NULL};
-                               
-                               /* now insert the keyframe(s) using the Keying 
Set
-                                *      1) add datasource override for the 
Object
-                                *      2) insert keyframes
-                                *      3) free the extra info 
-                                */
-                               ANIM_relative_keyingset_add_source(&dsources, 
&ob->id, NULL, NULL); 
-                               ANIM_apply_keyingset(C, &dsources, NULL, ks, 
MODIFYKEY_MODE_INSERT, (float)CFRA);
-                               BLI_freelistN(&dsources);
-                       }
-                       
+
+                       ED_autokeyframe_object(C, scene, ob, ks);
+
                        /* tag for updates */
                        DAG_id_tag_update(&ob->id, OB_RECALC_OB);
                }

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_snap.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_snap.c     
2011-10-10 10:35:18 UTC (rev 40906)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_snap.c     
2011-10-10 12:56:21 UTC (rev 40907)
@@ -65,6 +65,7 @@
 
 #include "ED_armature.h"
 #include "ED_mesh.h"
+#include "ED_keyframing.h"
 #include "ED_screen.h"
 #include "ED_curve.h" /* for curve_editnurbs */
 
@@ -494,6 +495,7 @@
        
        }
        else {
+               struct KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, 
"Location");
 
                CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
                        if(ob->mode & OB_MODE_POSE) {
@@ -522,6 +524,9 @@
                                                                        
pchan->loc[0]= vecN[1];
                                                                if 
((pchan->protectflag & OB_LOCK_LOCZ)==0)     
                                                                        
pchan->loc[0]= vecN[2];
+
+                                                               /* 
auto-keyframing */
+                                                               
ED_autokeyframe_pchan(C, scene, ob, pchan, ks);
                                                        }
                                                        /* if the bone has a 
parent and is connected to the parent, 
                                                         * don't do anything - 
will break chain unless we do auto-ik. 
@@ -531,8 +536,6 @@
                                }
                                ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK);
                                
-                               /* auto-keyframing */
-// XXX                         autokeyframe_pose_cb_func(ob, TFM_TRANSLATION, 
0);
                                DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
                        }
                        else {
@@ -556,7 +559,7 @@
                                        ob->loc[2]+= vec[2];
                                
                                /* auto-keyframing */
-// XXX                         autokeyframe_ob_cb_func(ob, TFM_TRANSLATION);
+                               ED_autokeyframe_object(C, scene, ob, ks);
                        }
                }
                CTX_DATA_END;
@@ -622,6 +625,8 @@
                
        }
        else {
+               struct KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, 
"Location");
+
                CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
                        if(ob->mode & OB_MODE_POSE) {
                                bPoseChannel *pchan;
@@ -648,6 +653,9 @@
                                                                        
pchan->loc[1]= curspn[1];
                                                                if 
((pchan->protectflag & OB_LOCK_LOCZ)==0)     
                                                                        
pchan->loc[2]= curspn[2];
+
+                                                               /* 
auto-keyframing */
+                                                               
ED_autokeyframe_pchan(C, scene, ob, pchan, ks);
                                                        }
                                                        /* if the bone has a 
parent and is connected to the parent, 
                                                         * don't do anything - 
will break chain unless we do auto-ik. 
@@ -657,8 +665,6 @@
                                }
                                ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK);
                                
-                               /* auto-keyframing */
-// XXX                         autokeyframe_pose_cb_func(ob, TFM_TRANSLATION, 
0);
                                DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
                        }
                        else {
@@ -680,9 +686,9 @@
                                        ob->loc[1]+= vec[1];
                                if ((ob->protectflag & OB_LOCK_LOCZ)==0)
                                        ob->loc[2]+= vec[2];
-                               
+
                                /* auto-keyframing */
-// XXX                         autokeyframe_ob_cb_func(ob, TFM_TRANSLATION);
+                               ED_autokeyframe_object(C, scene, ob, ks);
                        }
                }
                CTX_DATA_END;

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

Reply via email to