forked from bartvdbraak/blender
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.
This commit is contained in:
parent
2cb7a0b25c
commit
54701e28fb
@ -32,8 +32,9 @@
|
|||||||
/* for animplayer */
|
/* for animplayer */
|
||||||
typedef struct ScreenAnimData {
|
typedef struct ScreenAnimData {
|
||||||
ARegion *ar; /* do not read from this, only for comparing if region exists */
|
ARegion *ar; /* do not read from this, only for comparing if region exists */
|
||||||
int redraws;
|
short redraws;
|
||||||
int flag; /* flags for playback */
|
short flag; /* flags for playback */
|
||||||
|
int sfra; /* frame that playback was started from */
|
||||||
} ScreenAnimData;
|
} ScreenAnimData;
|
||||||
|
|
||||||
/* for animplayer */
|
/* for animplayer */
|
||||||
|
@ -1556,10 +1556,11 @@ void ED_screen_animation_timer(bContext *C, int redraws, int sync, int enable)
|
|||||||
screen->animtimer= NULL;
|
screen->animtimer= NULL;
|
||||||
|
|
||||||
if(enable) {
|
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));
|
screen->animtimer= WM_event_add_timer(wm, win, TIMER0, (1.0/FPS));
|
||||||
sad->ar= CTX_wm_region(C);
|
sad->ar= CTX_wm_region(C);
|
||||||
|
sad->sfra = scene->r.cfra;
|
||||||
sad->redraws= redraws;
|
sad->redraws= redraws;
|
||||||
sad->flag |= (enable < 0)? ANIMPLAY_FLAG_REVERSE: 0;
|
sad->flag |= (enable < 0)? ANIMPLAY_FLAG_REVERSE: 0;
|
||||||
sad->flag |= (sync == 0)? ANIMPLAY_FLAG_NO_SYNC: (sync == 1)? ANIMPLAY_FLAG_SYNC: 0;
|
sad->flag |= (sync == 0)? ANIMPLAY_FLAG_NO_SYNC: (sync == 1)? ANIMPLAY_FLAG_SYNC: 0;
|
||||||
|
@ -2263,8 +2263,6 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event)
|
|||||||
// TODO: this may make evaluation a bit slower if the value doesn't change... any way to avoid this?
|
// TODO: this may make evaluation a bit slower if the value doesn't change... any way to avoid this?
|
||||||
wt->timestep= (1.0/FPS);
|
wt->timestep= (1.0/FPS);
|
||||||
|
|
||||||
//WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
|
|
||||||
|
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
}
|
}
|
||||||
return OPERATOR_PASS_THROUGH;
|
return OPERATOR_PASS_THROUGH;
|
||||||
@ -2292,6 +2290,7 @@ static int screen_animation_play(bContext *C, wmOperator *op, wmEvent *event)
|
|||||||
bScreen *screen= CTX_wm_screen(C);
|
bScreen *screen= CTX_wm_screen(C);
|
||||||
|
|
||||||
if(screen->animtimer) {
|
if(screen->animtimer) {
|
||||||
|
/* stop playback now */
|
||||||
ED_screen_animation_timer(C, 0, 0, 0);
|
ED_screen_animation_timer(C, 0, 0, 0);
|
||||||
sound_stop_all(C);
|
sound_stop_all(C);
|
||||||
}
|
}
|
||||||
@ -2354,8 +2353,19 @@ static int screen_animation_cancel(bContext *C, wmOperator *op, wmEvent *event)
|
|||||||
{
|
{
|
||||||
bScreen *screen= CTX_wm_screen(C);
|
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 screen_animation_play(C, op, event);
|
||||||
|
}
|
||||||
|
|
||||||
return OPERATOR_PASS_THROUGH;
|
return OPERATOR_PASS_THROUGH;
|
||||||
}
|
}
|
||||||
@ -2364,7 +2374,7 @@ static void SCREEN_OT_animation_cancel(wmOperatorType *ot)
|
|||||||
{
|
{
|
||||||
/* identifiers */
|
/* identifiers */
|
||||||
ot->name= "Cancel Animation";
|
ot->name= "Cancel Animation";
|
||||||
ot->description= "Cancel animation.";
|
ot->description= "Cancel animation, returning to the original frame.";
|
||||||
ot->idname= "SCREEN_OT_animation_cancel";
|
ot->idname= "SCREEN_OT_animation_cancel";
|
||||||
|
|
||||||
/* api callbacks */
|
/* api callbacks */
|
||||||
|
Loading…
Reference in New Issue
Block a user