2.5 - More tweaks to realtime record
authorJoshua Leung <aligorith@gmail.com>
Sat, 1 Aug 2009 05:10:57 +0000 (05:10 +0000)
committerJoshua Leung <aligorith@gmail.com>
Sat, 1 Aug 2009 05:10:57 +0000 (05:10 +0000)
* New NLA Tracks/Strips are now only created if the 'layered' button (visible in the timeline header when autokeying is on, and the playback is running) is enabled. This multiple bones to be able to be animated in the same action, but done in multiple passes.

* Made Alt-A work in timeline header too.

source/blender/editors/space_time/space_time.c
source/blender/editors/space_time/time_header.c
source/blender/editors/transform/transform_generics.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesdna/DNA_userdef_types.h

index 61488db0007e1d13e9365a8b33b05adb7e996442..8445f1b47e76702fe412097919b9076aec5be7b5 100644 (file)
@@ -422,7 +422,7 @@ void ED_spacetype_time(void)
        art= MEM_callocN(sizeof(ARegionType), "spacetype time region");
        art->regionid = RGN_TYPE_HEADER;
        art->minsizey= HEADERY;
-       art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
+       art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES;
        
        art->init= time_header_area_init;
        art->draw= time_header_area_draw;
index 436a841deb843ba485fe9e9c24c326932b067b17..fb8c28fd7517846d6cffbbe040cb43cd6728b337 100644 (file)
@@ -447,6 +447,7 @@ void time_header_buttons(const bContext *C, ARegion *ar)
        ScrArea *sa= CTX_wm_area(C);
        SpaceTime *stime= CTX_wm_space_time(C);
        Scene *scene= CTX_data_scene(C);
+       wmTimer *animtimer= CTX_wm_screen(C)->animtimer;
        uiBlock *block;
        uiBut *but;
        int xco, yco= 3;
@@ -536,7 +537,7 @@ void time_header_buttons(const bContext *C, ARegion *ar)
                RNA_boolean_set(uiButGetOperatorPtrRNA(but), "next", 0);
        xco+= XIC;
        
-       if(CTX_wm_screen(C)->animtimer) {
+       if (animtimer) {
                /* pause button 2*size to keep buttons in place */
                uiDefIconBut(block, BUT, B_TL_STOP, ICON_PAUSE,
                                         xco, yco, XIC*2, YIC, 0, 0, 0, 0, 0, "Stop Playing Timeline");
@@ -568,13 +569,21 @@ void time_header_buttons(const bContext *C, ARegion *ar)
        uiDefIconButBitS(block, TOG, AUTOKEY_ON, B_REDRAWALL, ICON_REC,
                                         xco, yco, XIC, YIC, &(scene->toolsettings->autokey_mode), 0, 0, 0, 0, "Automatic keyframe insertion for Objects and Bones");
        xco+= XIC;
-
-       if(IS_AUTOKEY_ON(scene)) {
+       
+       if (IS_AUTOKEY_ON(scene)) {
                uiDefButS(block, MENU, B_REDRAWALL, 
                                  "Auto-Keying Mode %t|Add/Replace Keys%x3|Replace Keys %x5", 
                                  xco, yco, (int)5.5*XIC, YIC, &(scene->toolsettings->autokey_mode), 0, 1, 0, 0, 
                                  "Mode of automatic keyframe insertion for Objects and Bones");
                xco+= (5.5*XIC);
+               
+               if (animtimer) {
+                       uiDefButBitS(block, TOG, ANIMRECORD_FLAG_WITHNLA, B_REDRAWALL, "Layered",       
+                                 xco,yco, XIC*2.5, YIC,
+                                 &(scene->toolsettings->autokey_flag),0, 1, 0, 0,
+                                 "Add a new NLA Track + Strip for every loop/pass made over the animation to allow non-destructive tweaking.");
+                       xco+= (3*XIC);
+               }
        }
        else
                xco+= 6;
index 8a7bc51c19e5b3e1b65c90a4a5237ba95532186f..2279bf4dff5728be4c923aaeec7bbe47e4124ed8 100644 (file)
@@ -294,10 +294,12 @@ static void animrecord_check_state (Scene *scene, ID *id, wmTimer *animtimer)
 {
        ScreenAnimData *sad= animtimer->customdata;
        
-       /* if animtimer is running and we're not interested in only keying for available channels,
-        * check if there's a keyframe on the current frame
+       /* check if we need a new strip if:
+        *      - if animtimer is running 
+        *      - we're not only keying for available channels
+        *      - the option to add new actions for each round is not enabled
         */
-       if (IS_AUTOKEY_FLAG(INSERTAVAIL)==0) {
+       if (IS_AUTOKEY_FLAG(INSERTAVAIL)==0 && (scene->toolsettings->autokey_flag & ANIMRECORD_FLAG_WITHNLA)) {
                /* if playback has just looped around, we need to add a new NLA track+strip to allow a clean pass to occur */
                if (sad->flag & ANIMPLAY_FLAG_JUMPED) {
                        AnimData *adt= BKE_animdata_from_id(id);
@@ -306,20 +308,26 @@ static void animrecord_check_state (Scene *scene, ID *id, wmTimer *animtimer)
                         * NOTE: BKE_nla_action_pushdown() sync warning...
                         */
                        if ((adt->action) && !(adt->flag & ADT_NLA_EDIT_ON)) {
-                               NlaStrip *strip= add_nlastrip_to_stack(adt, adt->action);
+                               float astart, aend;
                                
-                               /* clear reference to action now that we've pushed it onto the stack */
-                               adt->action->id.us--;
-                               adt->action= NULL;
-                               
-                               /* adjust blending + extend so that they will behave correctly */
-                               strip->extendmode= NLASTRIP_EXTEND_NOTHING;
-                               strip->flag &= ~(NLASTRIP_FLAG_AUTO_BLENDS|NLASTRIP_FLAG_SELECT|NLASTRIP_FLAG_ACTIVE);
-                               
-                               /* also, adjust the AnimData's action extend mode to be on 
-                                * 'nothing' so that previous result still play 
-                                */
-                               adt->act_extendmode= NLASTRIP_EXTEND_NOTHING;
+                               /* only push down if action is more than 1-2 frames long */
+                               calc_action_range(adt->action, &astart, &aend, 1);
+                               if (aend > astart+2.0f) {
+                                       NlaStrip *strip= add_nlastrip_to_stack(adt, adt->action);
+                                       
+                                       /* clear reference to action now that we've pushed it onto the stack */
+                                       adt->action->id.us--;
+                                       adt->action= NULL;
+                                       
+                                       /* adjust blending + extend so that they will behave correctly */
+                                       strip->extendmode= NLASTRIP_EXTEND_NOTHING;
+                                       strip->flag &= ~(NLASTRIP_FLAG_AUTO_BLENDS|NLASTRIP_FLAG_SELECT|NLASTRIP_FLAG_ACTIVE);
+                                       
+                                       /* also, adjust the AnimData's action extend mode to be on 
+                                        * 'nothing' so that previous result still play 
+                                        */
+                                       adt->act_extendmode= NLASTRIP_EXTEND_NOTHING;
+                               }
                        }
                }
        }
index 28da3ba1316e8b0674fe1a0c3cba3e8b52eb7f3b..752f756401c589c5f485635834a8fb6726d3430b 100644 (file)
@@ -570,7 +570,7 @@ typedef struct ToolSettings {
        float clean_thresh;
 
        /* Auto-Keying Mode */
-       short autokey_mode, pad2;       /* defines in DNA_userdef_types.h */
+       short autokey_mode, autokey_flag;       /* defines in DNA_userdef_types.h */
        
        /* Retopo */
        char retopo_mode;
index bda4355d30bdd483800f081ead9d1f77e538e081..f61b4b2904d268ae2723fced97575548d50da26a 100644 (file)
@@ -404,9 +404,12 @@ extern UserDef U; /* from blenkernel blender.c */
 #define                AUTOKEY_MODE_EDITKEYS   5
 
 /* Auto-Keying flag */
+       /* U.autokey_flag */
 #define                AUTOKEY_FLAG_INSERTAVAIL        (1<<0)
 #define                AUTOKEY_FLAG_INSERTNEEDED       (1<<1)
 #define                AUTOKEY_FLAG_AUTOMATKEY         (1<<2)
+       /* toolsettings->autokey_flag */
+#define        ANIMRECORD_FLAG_WITHNLA         (1<<10)
 
 
 /* transopts */