Revision: 22139
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22139
Author:   aligorith
Date:     2009-08-02 13:05:13 +0200 (Sun, 02 Aug 2009)

Log Message:
-----------
2.5 - Animation Playback Tweaks 

* Added some optimisations to avoid having to try evaluating some data that 
won't have any effect.

* Converted playback buttons in timeline header to use operators too

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c
    branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c
    branches/blender2.5/blender/source/blender/editors/space_time/time_header.c

Modified: 
branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c     
2009-08-02 10:32:52 UTC (rev 22138)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c     
2009-08-02 11:05:13 UTC (rev 22139)
@@ -1391,21 +1391,38 @@
  * 'local' (i.e. belonging in the nearest ID-block that setting is related to, 
not a
  * standard 'root') block are overridden by a larger 'user'
  */
-// TODO: we currently go over entire 'main' database...
+// FIXME?: we currently go over entire 'main' database...
 void BKE_animsys_evaluate_all_animation (Main *main, float ctime)
 {
        ID *id;
        
        if (G.f & G_DEBUG)
                printf("Evaluate all animation - %f \n", ctime);
-
-       /* macro for less typing */
-#define EVAL_ANIM_IDS(first, flag) \
+       
+       /* macro for less typing 
+        *      - only evaluate animation data for id if it has users (and not 
just fake ones)
+        *      - whether animdata exists is checked for by the evaluation 
function, though taking 
+        *        this outside of the function may make things slightly faster?
+        */
+#define EVAL_ANIM_IDS(first, aflag) \
        for (id= first; id; id= id->next) { \
                AnimData *adt= BKE_animdata_from_id(id); \
-               BKE_animsys_evaluate_animdata(id, adt, ctime, flag); \
+               if ( (id->us > 1) || (id->us && !(id->flag & LIB_FAKEUSER)) ) \
+                       BKE_animsys_evaluate_animdata(id, adt, ctime, aflag); \
        }
        
+       /* optimisation: 
+        * when there are no actions, don't go over database and loop over 
heaps of datablocks, 
+        * which should ultimately be empty, since it is not possible for now 
to have any animation 
+        * without some actions, and drivers wouldn't get affected by any state 
changes
+        */
+       if (main->action.first == NULL) {
+               if (G.f & G_DEBUG)
+                       printf("\tNo Actions, so no animation needs to be 
evaluated...\n");
+                       
+               return;
+       }
+       
        /* nodes */
        // TODO...
        

Modified: branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c      
2009-08-02 10:32:52 UTC (rev 22138)
+++ branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c      
2009-08-02 11:05:13 UTC (rev 22139)
@@ -2311,6 +2311,10 @@
 
 /* ****************** anim player, starts or ends timer ***************** */
 
+/* helper for screen_animation_play() - only to be used for TimeLine */
+// NOTE: defined in time_header.c for now...
+extern ARegion *time_top_left_3dwindow(bScreen *screen);
+
 /* toggle operator */
 static int screen_animation_play(bContext *C, wmOperator *op, wmEvent *event)
 {
@@ -2320,16 +2324,33 @@
                ED_screen_animation_timer(C, 0, 0);
        }
        else {
+               ScrArea *sa= CTX_wm_area(C);
                int mode= (RNA_boolean_get(op->ptr, "reverse")) ? -1 : 1;
                
-               ED_screen_animation_timer(C, TIME_REGION|TIME_ALL_3D_WIN, mode);
-               
-               if(screen->animtimer) {
-                       wmTimer *wt= screen->animtimer;
-                       ScreenAnimData *sad= wt->customdata;
+               /* timeline gets special treatment since it has it's own menu 
for determining redraws */
+               if ((sa) && (sa->spacetype == SPACE_TIME)) {
+                       SpaceTime *stime= (SpaceTime *)sa->spacedata.first;
                        
-                       sad->ar= CTX_wm_region(C);
+                       ED_screen_animation_timer(C, stime->redraws, mode);
+                       
+                       /* update region if TIME_REGION was set, to leftmost 3d 
window */
+                       if(screen->animtimer && (stime->redraws & TIME_REGION)) 
{
+                               wmTimer *wt= screen->animtimer;
+                               ScreenAnimData *sad= wt->customdata;
+                               
+                               sad->ar= time_top_left_3dwindow(screen);
+                       }
                }
+               else {
+                       ED_screen_animation_timer(C, 
TIME_REGION|TIME_ALL_3D_WIN, mode);
+                       
+                       if(screen->animtimer) {
+                               wmTimer *wt= screen->animtimer;
+                               ScreenAnimData *sad= wt->customdata;
+                               
+                               sad->ar= CTX_wm_region(C);
+                       }
+               }
        }
        
        return OPERATOR_FINISHED;

Modified: 
branches/blender2.5/blender/source/blender/editors/space_time/time_header.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_time/time_header.c 
2009-08-02 10:32:52 UTC (rev 22138)
+++ branches/blender2.5/blender/source/blender/editors/space_time/time_header.c 
2009-08-02 11:05:13 UTC (rev 22139)
@@ -69,7 +69,8 @@
 
 /* ************************ header time area region *********************** */
 
-static ARegion *time_top_left_3dwindow(bScreen *screen)
+/* exported for use in screen_ops.c */
+ARegion *time_top_left_3dwindow(bScreen *screen)
 {
        ARegion *aret= NULL;
        ScrArea *sa;
@@ -204,12 +205,6 @@
                case 7:
                        //nextprev_marker(-1);
                        break;
-               case 8:
-                       //nextprev_timeline_key(1);
-                       break;
-               case 9:
-                       //nextprev_timeline_key(-1);
-                       break;
                case 10:
                        //timeline_frame_to_center();
                        break;
@@ -372,8 +367,6 @@
 
 void do_time_buttons(bContext *C, void *arg, int event)
 {
-       bScreen *screen= CTX_wm_screen(C);
-       SpaceTime *stime= CTX_wm_space_time(C);
        Scene *scene= CTX_data_scene(C);
        
        switch(event) {
@@ -383,34 +376,6 @@
                case B_NEWFRAME:
                        WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
                        break;
-               case B_TL_PLAY:
-                       ED_screen_animation_timer(C, stime->redraws, 1);
-                       
-                       /* update region if TIME_REGION was set, to leftmost 3d 
window */
-                       if(screen->animtimer && (stime->redraws & TIME_REGION)) 
{
-                               wmTimer *wt= screen->animtimer;
-                               ScreenAnimData *sad= wt->customdata;
-                               
-                               sad->ar= time_top_left_3dwindow(screen);
-                       }
-                       
-                       break;
-               case B_TL_RPLAY:
-                       ED_screen_animation_timer(C, stime->redraws, -1);
-                       
-                       /* update region if TIME_REGION was set, to leftmost 3d 
window */
-                       if(screen->animtimer && (stime->redraws & TIME_REGION)) 
{
-                               wmTimer *wt= screen->animtimer;
-                               ScreenAnimData *sad= wt->customdata;
-                               
-                               sad->ar= time_top_left_3dwindow(screen);
-                       }
-                       
-                       break;
-               case B_TL_STOP:
-                       ED_screen_animation_timer(C, 0, 0);
-                       break;
-                       
                case B_TL_PREVIEWON:
                        if (scene->r.psfra) {
                                /* turn on preview range */
@@ -526,19 +491,17 @@
        
        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");
-                                        
+               but=uiDefIconButO(block, BUT, "SCREEN_OT_animation_play", 
WM_OP_INVOKE_REGION_WIN, ICON_PAUSE, xco,yco,XIC*2,YIC, "Stop Playing 
Timeline");
+               
                xco+= XIC;
        }
        else {     
-               uiDefIconBut(block, BUT, B_TL_RPLAY, ICON_PLAY_REVERSE,
-                                        xco, yco, XIC, YIC, 0, 0, 0, 0, 0, 
"Play Timeline in Reverse");
-                                        
+               but=uiDefIconButO(block, BUT, "SCREEN_OT_animation_play", 
WM_OP_INVOKE_REGION_WIN, ICON_PLAY_REVERSE, xco,yco,XIC,YIC, "Play Timeline in 
Reverse");
+                       RNA_boolean_set(uiButGetOperatorPtrRNA(but), "reverse", 
1);     
                xco+= XIC;
                                         
-               uiDefIconBut(block, BUT, B_TL_PLAY, ICON_PLAY,
-                                        xco, yco, XIC, YIC, 0, 0, 0, 0, 0, 
"Play Timeline ");
+               but=uiDefIconButO(block, BUT, "SCREEN_OT_animation_play", 
WM_OP_INVOKE_REGION_WIN, ICON_PLAY, xco,yco,XIC,YIC, "Play Timeline");
+                       RNA_boolean_set(uiButGetOperatorPtrRNA(but), "reverse", 
0);     
        }
        xco+= XIC;
        
@@ -551,7 +514,7 @@
        xco+= XIC;
        uiBlockEndAlign(block);
 
-       xco+= 2*XIC;
+       xco+= 1.5*XIC;
        
        uiBlockBeginAlign(block);
        uiDefIconButBitS(block, TOG, AUTOKEY_ON, B_REDRAWALL, ICON_REC,


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

Reply via email to