[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21401] branches/soc-2009-aligorith/source /blender/editors: NLA SoC: Quick hack - Reversed playback
Joshua Leung
aligorith at gmail.com
Tue Jul 7 09:29:21 CEST 2009
Revision: 21401
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21401
Author: aligorith
Date: 2009-07-07 09:29:21 +0200 (Tue, 07 Jul 2009)
Log Message:
-----------
NLA SoC: Quick hack - Reversed playback
Animations can now be played back in reverse, by clicking on the reversed-playback button in the TimeLine header beside the play button (NEW ICON NEEDED HERE).
I'm not sure how well this works with sound, but from what I gather, this can be quite useful for animators to use.
Modified Paths:
--------------
branches/soc-2009-aligorith/source/blender/editors/include/ED_screen_types.h
branches/soc-2009-aligorith/source/blender/editors/screen/screen_edit.c
branches/soc-2009-aligorith/source/blender/editors/screen/screen_ops.c
branches/soc-2009-aligorith/source/blender/editors/space_time/time_header.c
Modified: branches/soc-2009-aligorith/source/blender/editors/include/ED_screen_types.h
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/include/ED_screen_types.h 2009-07-07 07:25:44 UTC (rev 21400)
+++ branches/soc-2009-aligorith/source/blender/editors/include/ED_screen_types.h 2009-07-07 07:29:21 UTC (rev 21401)
@@ -33,6 +33,7 @@
typedef struct ScreenAnimData {
ARegion *ar; /* do not read from this, only for comparing if region exists */
int redraws;
+ int reverse;
} ScreenAnimData;
Modified: branches/soc-2009-aligorith/source/blender/editors/screen/screen_edit.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/screen/screen_edit.c 2009-07-07 07:25:44 UTC (rev 21400)
+++ branches/soc-2009-aligorith/source/blender/editors/screen/screen_edit.c 2009-07-07 07:29:21 UTC (rev 21401)
@@ -1460,7 +1460,9 @@
ed_screen_fullarea(C, sa);
}
-/* redraws: uses defines from stime->redraws */
+/* redraws: uses defines from stime->redraws
+ * enable: 1 - forward on, -1 - backwards on, 0 - off
+ */
void ED_screen_animation_timer(bContext *C, int redraws, int enable)
{
bScreen *screen= CTX_wm_screen(C);
@@ -1477,6 +1479,7 @@
screen->animtimer= WM_event_add_window_timer(win, TIMER0, (1.0/FPS));
sad->ar= CTX_wm_region(C);
sad->redraws= redraws;
+ sad->reverse= (enable < 0);
screen->animtimer->customdata= sad;
}
Modified: branches/soc-2009-aligorith/source/blender/editors/screen/screen_ops.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/screen/screen_ops.c 2009-07-07 07:25:44 UTC (rev 21400)
+++ branches/soc-2009-aligorith/source/blender/editors/screen/screen_ops.c 2009-07-07 07:29:21 UTC (rev 21401)
@@ -2067,19 +2067,40 @@
if(scene->audio.flag & AUDIO_SYNC) {
int step = floor(wt->duration * FPS);
- scene->r.cfra += step;
+ if (sad->reverse) // XXX does this option work with audio?
+ scene->r.cfra -= step;
+ else
+ scene->r.cfra += step;
wt->duration -= ((float)step)/FPS;
}
- else
- scene->r.cfra++;
+ else {
+ if (sad->reverse)
+ scene->r.cfra--;
+ else
+ scene->r.cfra++;
+ }
- if (scene->r.psfra) {
- if(scene->r.cfra > scene->r.pefra)
- scene->r.cfra= scene->r.psfra;
+ if (sad->reverse) {
+ /* jump back to end */
+ if (scene->r.psfra) {
+ if(scene->r.cfra < scene->r.psfra)
+ scene->r.cfra= scene->r.pefra;
+ }
+ else {
+ if(scene->r.cfra < scene->r.sfra)
+ scene->r.cfra= scene->r.efra;
+ }
}
else {
- if(scene->r.cfra > scene->r.efra)
- scene->r.cfra= scene->r.sfra;
+ /* jump back to start */
+ if (scene->r.psfra) {
+ if(scene->r.cfra > scene->r.pefra)
+ scene->r.cfra= scene->r.psfra;
+ }
+ else {
+ if(scene->r.cfra > scene->r.efra)
+ scene->r.cfra= scene->r.sfra;
+ }
}
/* since we follow drawflags, we can't send notifier but tag regions ourselves */
@@ -2127,9 +2148,10 @@
ED_screen_animation_timer(C, 0, 0);
}
else {
- /* todo: RNA properties to define play types */
- ED_screen_animation_timer(C, TIME_REGION|TIME_ALL_3D_WIN, 1);
+ 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;
@@ -2152,7 +2174,7 @@
ot->poll= ED_operator_screenactive;
-
+ RNA_def_boolean(ot->srna, "reverse", 0, "Play in Reverse", "Animation is played backwards");
}
/* ************** border select operator (template) ***************************** */
Modified: branches/soc-2009-aligorith/source/blender/editors/space_time/time_header.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_time/time_header.c 2009-07-07 07:25:44 UTC (rev 21400)
+++ branches/soc-2009-aligorith/source/blender/editors/space_time/time_header.c 2009-07-07 07:29:21 UTC (rev 21401)
@@ -373,6 +373,7 @@
#define B_REDRAWALL 750
#define B_TL_REW 751
#define B_TL_PLAY 752
+#define B_TL_RPLAY 760
#define B_TL_FF 753
#define B_TL_PREVKEY 754
#define B_TL_NEXTKEY 755
@@ -416,6 +417,18 @@
}
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;
@@ -553,14 +566,27 @@
xco, yco, XIC, YIC, 0, 0, 0, 0, 0, "Skip to previous keyframe (Ctrl PageDown)");
xco+= XIC+4;
- if(CTX_wm_screen(C)->animtimer)
+ if(CTX_wm_screen(C)->animtimer) {
+ /* pause button is drawn centered between the two other buttons for now (saves drawing 2 buttons, or having position changes) */
+ xco+= XIC/2 + 2;
+
uiDefIconBut(block, BUT, B_TL_STOP, ICON_PAUSE,
xco, yco, XIC, YIC, 0, 0, 0, 0, 0, "Stop Playing Timeline");
- else
+
+ xco+= XIC/2 + 2;
+ }
+ else {
+ // FIXME: the icon for this is crap
+ uiDefIconBut(block, BUT, B_TL_RPLAY, ICON_REW/*ICON_PLAY*/,
+ xco, yco, XIC, YIC, 0, 0, 0, 0, 0, "Play Timeline in Reverse");
+
+ xco+= XIC+4;
+
uiDefIconBut(block, BUT, B_TL_PLAY, ICON_PLAY,
xco, yco, XIC, YIC, 0, 0, 0, 0, 0, "Play Timeline ");
+ }
+ xco+= XIC+4;
- xco+= XIC+4;
uiDefIconBut(block, BUT, B_TL_NEXTKEY, ICON_NEXT_KEYFRAME,
xco, yco, XIC, YIC, 0, 0, 0, 0, 0, "Skip to next keyframe (Ctrl PageUp)");
xco+= XIC+4;
More information about the Bf-blender-cvs
mailing list