[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24941] trunk/blender/source/blender/ editors: Animation Playback - Return to original frame
Joshua Leung
aligorith at gmail.com
Fri Nov 27 05:14:58 CET 2009
Revision: 24941
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24941
Author: aligorith
Date: 2009-11-27 05:14:56 +0100 (Fri, 27 Nov 2009)
Log Message:
-----------
Animation Playback - Return to original frame
Playback of animation will now be restored to the frame that playback started on when stopping if the SCREEN_OT_animation_cancel operator is used (i.e. ESCKEY).
All other ways of stopping playback (pause button, alt-a) should act more like toggles, and do not reset the playhead.
Modified Paths:
--------------
trunk/blender/source/blender/editors/include/ED_screen_types.h
trunk/blender/source/blender/editors/screen/screen_edit.c
trunk/blender/source/blender/editors/screen/screen_ops.c
Modified: trunk/blender/source/blender/editors/include/ED_screen_types.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_screen_types.h 2009-11-27 00:45:01 UTC (rev 24940)
+++ trunk/blender/source/blender/editors/include/ED_screen_types.h 2009-11-27 04:14:56 UTC (rev 24941)
@@ -32,8 +32,9 @@
/* for animplayer */
typedef struct ScreenAnimData {
ARegion *ar; /* do not read from this, only for comparing if region exists */
- int redraws;
- int flag; /* flags for playback */
+ short redraws;
+ short flag; /* flags for playback */
+ int sfra; /* frame that playback was started from */
} ScreenAnimData;
/* for animplayer */
Modified: trunk/blender/source/blender/editors/screen/screen_edit.c
===================================================================
--- trunk/blender/source/blender/editors/screen/screen_edit.c 2009-11-27 00:45:01 UTC (rev 24940)
+++ trunk/blender/source/blender/editors/screen/screen_edit.c 2009-11-27 04:14:56 UTC (rev 24941)
@@ -1556,10 +1556,11 @@
screen->animtimer= NULL;
if(enable) {
- struct ScreenAnimData *sad= MEM_callocN(sizeof(ScreenAnimData), "ScreenAnimData");
+ ScreenAnimData *sad= MEM_callocN(sizeof(ScreenAnimData), "ScreenAnimData");
screen->animtimer= WM_event_add_timer(wm, win, TIMER0, (1.0/FPS));
sad->ar= CTX_wm_region(C);
+ sad->sfra = scene->r.cfra;
sad->redraws= redraws;
sad->flag |= (enable < 0)? ANIMPLAY_FLAG_REVERSE: 0;
sad->flag |= (sync == 0)? ANIMPLAY_FLAG_NO_SYNC: (sync == 1)? ANIMPLAY_FLAG_SYNC: 0;
Modified: trunk/blender/source/blender/editors/screen/screen_ops.c
===================================================================
--- trunk/blender/source/blender/editors/screen/screen_ops.c 2009-11-27 00:45:01 UTC (rev 24940)
+++ trunk/blender/source/blender/editors/screen/screen_ops.c 2009-11-27 04:14:56 UTC (rev 24941)
@@ -2263,8 +2263,6 @@
// TODO: this may make evaluation a bit slower if the value doesn't change... any way to avoid this?
wt->timestep= (1.0/FPS);
- //WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
-
return OPERATOR_FINISHED;
}
return OPERATOR_PASS_THROUGH;
@@ -2292,6 +2290,7 @@
bScreen *screen= CTX_wm_screen(C);
if(screen->animtimer) {
+ /* stop playback now */
ED_screen_animation_timer(C, 0, 0, 0);
sound_stop_all(C);
}
@@ -2354,8 +2353,19 @@
{
bScreen *screen= CTX_wm_screen(C);
- if(screen->animtimer)
+ if(screen->animtimer) {
+ ScreenAnimData *sad= screen->animtimer->customdata;
+ Scene *scene= CTX_data_scene(C);
+
+ /* reset current frame before stopping, and just send a notifier to deal with the rest
+ * (since playback still needs to be stopped)
+ */
+ scene->r.cfra= sad->sfra;
+ WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
+
+ /* call the other "toggling" operator to clean up now */
return screen_animation_play(C, op, event);
+ }
return OPERATOR_PASS_THROUGH;
}
@@ -2364,7 +2374,7 @@
{
/* identifiers */
ot->name= "Cancel Animation";
- ot->description= "Cancel animation.";
+ ot->description= "Cancel animation, returning to the original frame.";
ot->idname= "SCREEN_OT_animation_cancel";
/* api callbacks */
More information about the Bf-blender-cvs
mailing list