== Action Editor - Time Stuff for Tools ==
Part 2 of work from yesterday. Now tools in Action Editor are aware of (work well) with time display in seconds as well.
This commit is contained in:
@@ -797,7 +797,7 @@ static short transform_action_loop (TransVert *tv, int tvtot, char mode, short c
|
||||
float deltax, startx;
|
||||
float cenf[2];
|
||||
float sval[2], cval[2], lastcval[2]={0,0};
|
||||
float fac=0.0f;
|
||||
float fac=0.0f, secf= ((float)G.scene->r.frs_sec);
|
||||
int loop=1, invert=0;
|
||||
int i;
|
||||
short cancel=0, firsttime=1;
|
||||
@@ -921,8 +921,12 @@ static short transform_action_loop (TransVert *tv, int tvtot, char mode, short c
|
||||
deltax = get_action_frame_inv(OBACT, cval[0]);
|
||||
deltax -= get_action_frame_inv(OBACT, sval[0]);
|
||||
|
||||
if (autosnap == SACTSNAP_STEP)
|
||||
deltax= 1.0f*floor(deltax/1.0f + 0.5f);
|
||||
if (autosnap == SACTSNAP_STEP) {
|
||||
if (G.saction->flag & SACTION_DRAWTIME)
|
||||
deltax= (float)( floor((deltax/secf) + 0.5f) * secf );
|
||||
else
|
||||
deltax= (float)( floor(deltax + 0.5f) );
|
||||
}
|
||||
|
||||
fac = get_action_frame_inv(OBACT, tv[i].loc[0]);
|
||||
fac += deltax;
|
||||
@@ -932,8 +936,12 @@ static short transform_action_loop (TransVert *tv, int tvtot, char mode, short c
|
||||
deltax = cval[0] - sval[0];
|
||||
fac= deltax;
|
||||
|
||||
if (autosnap == SACTSNAP_STEP)
|
||||
fac= 1.0f*floor(fac/1.0f + 0.5f);
|
||||
if (autosnap == SACTSNAP_STEP) {
|
||||
if (G.saction->flag & SACTION_DRAWTIME)
|
||||
fac= (float)( floor((deltax/secf) + 0.5f) * secf );
|
||||
else
|
||||
fac= (float)( floor(fac + 0.5f) );
|
||||
}
|
||||
|
||||
tv[i].loc[0]+=fac;
|
||||
}
|
||||
@@ -944,18 +952,21 @@ static short transform_action_loop (TransVert *tv, int tvtot, char mode, short c
|
||||
fac= fabs(deltax/startx);
|
||||
|
||||
if (autosnap == SACTSNAP_STEP) {
|
||||
fac= 1.0f*floor(fac/1.0f + 0.5f);
|
||||
if (G.saction->flag & SACTION_DRAWTIME)
|
||||
fac= (float)( floor(fac/secf + 0.5f) * secf );
|
||||
else
|
||||
fac= (float)( floor(fac + 0.5f) );
|
||||
}
|
||||
|
||||
if (invert){
|
||||
if (i % 03 == 0){
|
||||
if (invert) {
|
||||
if (i % 03 == 0) {
|
||||
memcpy (tv[i].loc, tv[i].oldloc, sizeof(tv[i+2].oldloc));
|
||||
}
|
||||
if (i % 03 == 2){
|
||||
if (i % 03 == 2) {
|
||||
memcpy (tv[i].loc, tv[i].oldloc, sizeof(tv[i-2].oldloc));
|
||||
}
|
||||
|
||||
fac*=-1;
|
||||
fac *= -1;
|
||||
}
|
||||
startx= (G.scene->r.cfra);
|
||||
if(NLA_ACTION_SCALED && context==ACTCONT_ACTION)
|
||||
@@ -979,7 +990,10 @@ static short transform_action_loop (TransVert *tv, int tvtot, char mode, short c
|
||||
snapval= tv[i].loc[0];
|
||||
|
||||
/* snap to nearest frame */
|
||||
snapval= (float)(floor(snapval+0.5));
|
||||
if (G.saction->flag & SACTION_DRAWTIME)
|
||||
snapval= (float)( floor((snapval/secf) + 0.5f) * secf );
|
||||
else
|
||||
snapval= (float)( floor(snapval+0.5f) );
|
||||
|
||||
/* convert frame out of nla-action time */
|
||||
if (NLA_ACTION_SCALED && context==ACTCONT_ACTION)
|
||||
@@ -999,9 +1013,30 @@ static short transform_action_loop (TransVert *tv, int tvtot, char mode, short c
|
||||
fac = get_action_frame_inv(OBACT, cval[0]);
|
||||
fac -= get_action_frame_inv(OBACT, sval[0]);
|
||||
|
||||
if (autosnap == SACTSNAP_STEP)
|
||||
fac= 1.0f*floor(fac/1.0f + 0.5f);
|
||||
if (autosnap == SACTSNAP_STEP) {
|
||||
if (G.saction->flag & SACTION_DRAWTIME)
|
||||
fac= floor(fac/secf + 0.5f);
|
||||
else
|
||||
fac= floor(fac + 0.5f);
|
||||
}
|
||||
else if (autosnap == SACTSNAP_FRAME) {
|
||||
if (G.saction->flag & SACTION_DRAWTIME)
|
||||
fac= fac / secf;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (autosnap == SACTSNAP_STEP) {
|
||||
if (G.saction->flag & SACTION_DRAWTIME)
|
||||
fac= floor(fac/secf + 0.5f);
|
||||
else
|
||||
fac= floor(fac + 0.5f);
|
||||
}
|
||||
else if (autosnap == SACTSNAP_FRAME) {
|
||||
if (G.saction->flag & SACTION_DRAWTIME)
|
||||
fac= fac / secf;
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(str, "deltaX: %.3f", fac);
|
||||
headerprint(str);
|
||||
}
|
||||
@@ -1157,11 +1192,17 @@ void snap_action_keys(short mode)
|
||||
strcpy(str, "Snap Keys To Nearest Frame");
|
||||
break;
|
||||
case 2:
|
||||
strcpy(str, "Snap Keys To Current Frame");
|
||||
if (G.saction->flag & SACTION_DRAWTIME)
|
||||
strcpy(str, "Snap Keys To Current Time");
|
||||
else
|
||||
strcpy(str, "Snap Keys To Current Frame");
|
||||
break;
|
||||
case 3:
|
||||
strcpy(str, "Snap Keys To Nearest Marker");
|
||||
break;
|
||||
case 4:
|
||||
strcpy(str, "Snap Keys To Nearest Second");
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@@ -2860,7 +2901,11 @@ void winqreadactionspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
||||
if (G.qual & LR_SHIFTKEY) {
|
||||
/* mirror keyframes */
|
||||
if (data) {
|
||||
val = pupmenu("Mirror Keys Over%t|Current Frame%x1|Vertical Axis%x2|Horizontal Axis %x3|Selected Marker %x4");
|
||||
if (G.saction->flag & SACTION_DRAWTIME)
|
||||
val = pupmenu("Mirror Keys Over%t|Current Time%x1|Vertical Axis%x2|Horizontal Axis %x3|Selected Marker %x4");
|
||||
else
|
||||
val = pupmenu("Mirror Keys Over%t|Current Frame%x1|Vertical Axis%x2|Horizontal Axis %x3|Selected Marker %x4");
|
||||
|
||||
mirror_action_keys(val);
|
||||
}
|
||||
}
|
||||
@@ -2911,12 +2956,17 @@ void winqreadactionspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
||||
if (mval[0]>=ACTWIDTH) {
|
||||
if (G.qual & LR_SHIFTKEY) {
|
||||
if (data) {
|
||||
val = pupmenu("Snap Keys To%t|Nearest Frame%x1|Current Frame%x2|Nearest Marker %x3");
|
||||
if (G.saction->flag & SACTION_DRAWTIME)
|
||||
val = pupmenu("Snap Keys To%t|Nearest Second%x4|Current Time%x2|Nearest Marker %x3");
|
||||
else
|
||||
val = pupmenu("Snap Keys To%t|Nearest Frame%x1|Current Frame%x2|Nearest Marker %x3");
|
||||
|
||||
snap_action_keys(val);
|
||||
}
|
||||
}
|
||||
else
|
||||
transform_action_keys ('s', 0);
|
||||
else {
|
||||
transform_action_keys('s', 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -575,6 +575,14 @@ static int snap_bezier_nearest(BezTriple *bezt)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int snap_bezier_nearestsec(BezTriple *bezt)
|
||||
{
|
||||
float secf = (float)(G.scene->r.frs_sec);
|
||||
if(bezt->f2 & SELECT)
|
||||
bezt->vec[1][0]= (float)(floor(bezt->vec[1][0]/secf + 0.5f) * secf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int snap_bezier_cframe(BezTriple *bezt)
|
||||
{
|
||||
if(bezt->f2 & SELECT)
|
||||
@@ -593,7 +601,7 @@ static int snap_bezier_nearmarker(BezTriple *bezt)
|
||||
void snap_ipo_keys(Ipo *ipo, short snaptype)
|
||||
{
|
||||
switch (snaptype) {
|
||||
case 1: /* snap to nearest */
|
||||
case 1: /* snap to nearest frame */
|
||||
ipo_keys_bezier_loop(ipo, snap_bezier_nearest, calchandles_ipocurve);
|
||||
break;
|
||||
case 2: /* snap to current frame */
|
||||
@@ -602,6 +610,9 @@ void snap_ipo_keys(Ipo *ipo, short snaptype)
|
||||
case 3: /* snap to nearest marker */
|
||||
ipo_keys_bezier_loop(ipo, snap_bezier_nearmarker, calchandles_ipocurve);
|
||||
break;
|
||||
case 4: /* snap to nearest second */
|
||||
ipo_keys_bezier_loop(ipo, snap_bezier_nearestsec, calchandles_ipocurve);
|
||||
break;
|
||||
default: /* just in case */
|
||||
ipo_keys_bezier_loop(ipo, snap_bezier_nearest, calchandles_ipocurve);
|
||||
break;
|
||||
|
||||
@@ -167,6 +167,7 @@ void transform_markers(int mode, int smode) // mode and smode unused here, for c
|
||||
{
|
||||
SpaceLink *slink= curarea->spacedata.first;
|
||||
SpaceTime *stime= curarea->spacedata.first;
|
||||
SpaceAction *saction = curarea->spacedata.first;
|
||||
TimeMarker *marker, *selmarker=NULL;
|
||||
float dx, fac;
|
||||
int a, ret_val= 0, totmark=0, *oldframe, offs, firsttime=1;
|
||||
@@ -219,22 +220,34 @@ void transform_markers(int mode, int smode) // mode and smode unused here, for c
|
||||
|
||||
if(totmark==1) { // we print current marker value
|
||||
if (ELEM(slink->spacetype, SPACE_TIME, SPACE_SOUND)) {
|
||||
if(stime->flag & TIME_DRAWFRAMES)
|
||||
if (stime->flag & TIME_DRAWFRAMES)
|
||||
sprintf(str, "Marker %d offset %d", selmarker->frame, offs);
|
||||
else
|
||||
sprintf(str, "Marker %.2f offset %.2f", (selmarker->frame/(float)G.scene->r.frs_sec), (offs/(float)G.scene->r.frs_sec));
|
||||
}
|
||||
else if (slink->spacetype == SPACE_ACTION) {
|
||||
if (saction->flag & SACTION_DRAWTIME)
|
||||
sprintf(str, "Marker %.2f offset %.2f", (selmarker->frame/(float)G.scene->r.frs_sec), (offs/(float)G.scene->r.frs_sec));
|
||||
else
|
||||
sprintf(str, "Marker %.2f offset %.2f", (double)(selmarker->frame), (double)(offs));
|
||||
}
|
||||
else {
|
||||
sprintf(str, "Marker %.2f offset %.2f", (double)(selmarker->frame), (double)(offs));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ELEM(slink->spacetype, SPACE_TIME, SPACE_SOUND)) {
|
||||
if(stime->flag & TIME_DRAWFRAMES)
|
||||
if (stime->flag & TIME_DRAWFRAMES)
|
||||
sprintf(str, "Marker offset %d ", offs);
|
||||
else
|
||||
sprintf(str, "Marker offset %.2f ", (offs/(float)G.scene->r.frs_sec));
|
||||
}
|
||||
else if (slink->spacetype == SPACE_ACTION) {
|
||||
if (saction->flag & SACTION_DRAWTIME)
|
||||
sprintf(str, "Marker offset %.2f ", (offs/(float)G.scene->r.frs_sec));
|
||||
else
|
||||
sprintf(str, "Marker offset %.2f ", (double)(offs));
|
||||
}
|
||||
else {
|
||||
sprintf(str, "Marker offset %.2f ", (double)(offs));
|
||||
}
|
||||
|
||||
@@ -134,6 +134,7 @@
|
||||
#define ACTMENU_KEY_SNAP_NEARFRAME 1
|
||||
#define ACTMENU_KEY_SNAP_CURFRAME 2
|
||||
#define ACTMENU_KEY_SNAP_NEARMARK 3
|
||||
#define ACTMENU_KEY_SNAP_NEARTIME 4
|
||||
|
||||
#define ACTMENU_KEY_MIRROR_CURFRAME 1
|
||||
#define ACTMENU_KEY_MIRROR_YAXIS 2
|
||||
@@ -282,13 +283,13 @@ static uiBlock *action_viewmenu(void *arg_unused)
|
||||
|
||||
if (G.saction->flag & SACTION_DRAWTIME) {
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
|
||||
"Show Frames|T", 0, yco-=20,
|
||||
"Show Frames|Ctrl T", 0, yco-=20,
|
||||
menuwidth, 19, NULL, 0.0, 0.0, 1,
|
||||
ACTMENU_VIEW_TIME, "");
|
||||
}
|
||||
else {
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
|
||||
"Show Seconds|T", 0, yco-=20,
|
||||
"Show Seconds|Ctrl T", 0, yco-=20,
|
||||
menuwidth, 19, NULL, 0.0, 0.0, 1,
|
||||
ACTMENU_VIEW_TIME, "");
|
||||
}
|
||||
@@ -811,6 +812,7 @@ static void do_action_keymenu_snapmenu(void *arg, int event)
|
||||
case ACTMENU_KEY_SNAP_NEARFRAME:
|
||||
case ACTMENU_KEY_SNAP_CURFRAME:
|
||||
case ACTMENU_KEY_SNAP_NEARMARK:
|
||||
case ACTMENU_KEY_SNAP_NEARTIME:
|
||||
snap_action_keys(event);
|
||||
break;
|
||||
}
|
||||
@@ -827,14 +829,27 @@ static uiBlock *action_keymenu_snapmenu(void *arg_unused)
|
||||
UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
|
||||
uiBlockSetButmFunc(block, do_action_keymenu_snapmenu, NULL);
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
|
||||
"Nearest Frame|Shift S, 1", 0, yco-=20,
|
||||
menuwidth, 19, NULL, 0.0, 0.0, 0,
|
||||
ACTMENU_KEY_SNAP_NEARFRAME, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
|
||||
"Current Frame|Shift S, 2", 0, yco-=20,
|
||||
menuwidth, 19, NULL, 0.0, 0.0, 0,
|
||||
ACTMENU_KEY_SNAP_CURFRAME, "");
|
||||
if (G.saction->flag & SACTION_DRAWTIME) {
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
|
||||
"Nearest Second|Shift S, 1", 0, yco-=20,
|
||||
menuwidth, 19, NULL, 0.0, 0.0, 0,
|
||||
ACTMENU_KEY_SNAP_NEARTIME, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
|
||||
"Current Time|Shift S, 2", 0, yco-=20,
|
||||
menuwidth, 19, NULL, 0.0, 0.0, 0,
|
||||
ACTMENU_KEY_SNAP_CURFRAME, "");
|
||||
|
||||
}
|
||||
else {
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
|
||||
"Nearest Frame|Shift S, 1", 0, yco-=20,
|
||||
menuwidth, 19, NULL, 0.0, 0.0, 0,
|
||||
ACTMENU_KEY_SNAP_NEARFRAME, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
|
||||
"Current Frame|Shift S, 2", 0, yco-=20,
|
||||
menuwidth, 19, NULL, 0.0, 0.0, 0,
|
||||
ACTMENU_KEY_SNAP_CURFRAME, "");
|
||||
}
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
|
||||
"Nearest Marker|Shift S, 3", 0, yco-=20,
|
||||
menuwidth, 19, NULL, 0.0, 0.0, 0,
|
||||
@@ -1154,12 +1169,20 @@ void action_buttons(void)
|
||||
/* draw AUTOSNAP */
|
||||
xco+= 8;
|
||||
|
||||
uiDefIconTextButS(block, ICONTEXTROW,B_REDR, ICON_PROP_OFF,
|
||||
"Auto-Snap Keys %t|Off %x0|Frame Step %x1|Nearest Frame %x2",
|
||||
xco,0,XIC+10,YIC, &(G.saction->autosnap), 0, 1, 0, 0,
|
||||
"Auto-snapping mode for keys when transforming");
|
||||
if (G.saction->flag & SACTION_DRAWTIME) {
|
||||
uiDefButS(block, MENU, B_REDR,
|
||||
"Auto-Snap Keyframes %t|Off %x0|Second Step %x1|Nearest Second %x2",
|
||||
xco,0,70,YIC, &(G.saction->autosnap), 0, 1, 0, 0,
|
||||
"Auto-snapping mode for keyframes when transforming");
|
||||
}
|
||||
else {
|
||||
uiDefButS(block, MENU, B_REDR,
|
||||
"Auto-Snap Keyframes %t|Off %x0|Frame Step %x1|Nearest Frame %x2",
|
||||
xco,0,70,YIC, &(G.saction->autosnap), 0, 1, 0, 0,
|
||||
"Auto-snapping mode for keyframes when transforming");
|
||||
}
|
||||
|
||||
xco+= (XIC + 18);
|
||||
xco+= (70 + 8);
|
||||
|
||||
/* draw LOCK*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user