diff options
author | Ton Roosendaal <ton@blender.org> | 2005-10-31 12:41:24 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2005-10-31 12:41:24 +0300 |
commit | 53052c9924fe4e3ef4d1966dec3958640c45fab6 (patch) | |
tree | 3f1bce8849f71f46a358ef735c0f0d9eb9ec6e81 /source | |
parent | 3150b5a7a774898b740e0a6b15d109d314e52ae6 (diff) |
iNew: TimeSlide in Action Window
Usage: press Tkey, and you can proportionally squeeze or stretch the
selected keys, with current mouse position as reference. Only works with
more than 3 keys selected horizontally.
I've remapped the old Tkey (ipo type) to SHIFT+T... might be temporal, I
have an idea for a cool 2D manipulator system that makes it much friendlier
to grab/scale/slide keys all in once.
Also: fix for HOME key in action editor (didn't do Pin), and removed gcc
warnings from jiri's commit in editmesh_add.c
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/makesdna/DNA_action_types.h | 9 | ||||
-rw-r--r-- | source/blender/src/drawaction.c | 10 | ||||
-rw-r--r-- | source/blender/src/editaction.c | 63 | ||||
-rw-r--r-- | source/blender/src/editmesh_add.c | 2 | ||||
-rw-r--r-- | source/blender/src/header_action.c | 28 |
5 files changed, 94 insertions, 18 deletions
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index 265e15d8d45..fce02e2e394 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -108,10 +108,8 @@ typedef struct SpaceAction { View2D v2d; bAction *action; int flag; - short pin, reserved1; - short actnr; - short lock; - int pad2; + short pin, actnr, lock, pad; + float timeslide; } SpaceAction; /* Action Channel flags */ @@ -119,9 +117,10 @@ typedef struct SpaceAction { #define ACHAN_HILIGHTED 0x00000002 #define ACHAN_MOVED 0x80000000 +/* SpaceAction flag */ +#define SACTION_MOVING 1 /* Pose->flag */ - #define POSE_RECALC 1 #define POSE_LOCKED 2 #define POSE_DO_UNLOCK 4 diff --git a/source/blender/src/drawaction.c b/source/blender/src/drawaction.c index 1c6c28929e3..7d92b8a746b 100644 --- a/source/blender/src/drawaction.c +++ b/source/blender/src/drawaction.c @@ -440,6 +440,16 @@ static void draw_channel_strips(SpaceAction *saction) } } + if(saction->flag & SACTION_MOVING) { + int frame1_x, channel_y; + gla2DDrawTranslatePt(di, saction->timeslide, 0, &frame1_x, &channel_y); + cpack(0x0); + glBegin(GL_LINES); + glVertex2f(frame1_x, G.v2d->mask.ymin - 100); + glVertex2f(frame1_x, G.v2d->mask.ymax); + glEnd(); + } + glaEnd2DDraw(di); } diff --git a/source/blender/src/editaction.c b/source/blender/src/editaction.c index bd7e978daec..bd50436fff3 100644 --- a/source/blender/src/editaction.c +++ b/source/blender/src/editaction.c @@ -847,9 +847,9 @@ void transform_actionchannel_keys(int mode, int dummy) bConstraintChannel *conchan; bActionChannel *chan; float deltax, startx; - float cenf[2]; + float minx, maxx, cenf[2]; float sval[2], cval[2], lastcval[2]; - float fac=0.0F; + float fac=0.0f; int loop=1; int tvtot=0; int invert=0, firsttime=1; @@ -875,6 +875,7 @@ void transform_actionchannel_keys(int mode, int dummy) /* Build the transvert structure */ tv = MEM_callocN (sizeof(TransVert) * tvtot, "transVert"); + tvtot=0; for (chan=act->chanbase.first; chan; chan=chan->next){ /* Add the actionchannel */ @@ -882,7 +883,14 @@ void transform_actionchannel_keys(int mode, int dummy) for (conchan=chan->constraintChannels.first; conchan; conchan=conchan->next) tvtot = add_trans_ipo_keys(conchan->ipo, tv, tvtot); } - + + /* min max, only every other three */ + minx= maxx= tv[1].loc[0]; + for (i=1; i<tvtot; i+=3){ + if(minx>tv[i].loc[0]) minx= tv[i].loc[0]; + if(maxx<tv[i].loc[0]) maxx= tv[i].loc[0]; + } + /* Do the event loop */ cent[0] = curarea->winx + (G.saction->v2d.hor.xmax)/2; cent[1] = curarea->winy + (G.saction->v2d.hor.ymax)/2; @@ -891,8 +899,21 @@ void transform_actionchannel_keys(int mode, int dummy) getmouseco_areawin (mvals); areamouseco_to_ipoco(G.v2d, mvals, &sval[0], &sval[1]); + if(G.saction->pin==0 && OBACT) + sval[0]= get_action_frame(OBACT, sval[0]); + + /* used for drawing */ + if(mode=='t') { + G.saction->flag |= SACTION_MOVING; + G.saction->timeslide= sval[0]; + } + startx=sval[0]; while (loop) { + + if(mode=='t' && minx==maxx) + break; + /* Get the input */ /* If we're cancelling, reset transformations */ /* Else calc new transformation */ @@ -930,14 +951,36 @@ void transform_actionchannel_keys(int mode, int dummy) } else { getmouseco_areawin (mvalc); areamouseco_to_ipoco(G.v2d, mvalc, &cval[0], &cval[1]); + + if(G.saction->pin==0 && OBACT) + cval[0]= get_action_frame(OBACT, cval[0]); + if(mode=='t') + G.saction->timeslide= cval[0]; + if (!firsttime && lastcval[0]==cval[0] && lastcval[1]==cval[1]) { PIL_sleep_ms(1); } else { + for (i=0; i<tvtot; i++){ tv[i].loc[0]=tv[i].oldloc[0]; switch (mode){ + case 't': + if( sval[0] > minx && sval[0] < maxx) { + float timefac, cvalc= CLAMPIS(cval[0], minx, maxx); + + /* left half */ + if(tv[i].oldloc[0] < sval[0]) { + timefac= ( sval[0] - tv[i].oldloc[0])/(sval[0] - minx); + tv[i].loc[0]= cvalc - timefac*( cvalc - minx); + } + else { + timefac= (tv[i].oldloc[0] - sval[0])/(maxx - sval[0]); + tv[i].loc[0]= cvalc + timefac*(maxx- cvalc); + } + } + break; case 'g': deltax = cval[0]-sval[0]; fac= deltax; @@ -982,6 +1025,12 @@ void transform_actionchannel_keys(int mode, int dummy) sprintf(str, "deltaX: %.3f", fac); headerprint(str); } + else if (mode=='t') { + float fac= 2.0*(cval[0]-sval[0])/(maxx-minx); + CLAMP(fac, -1.0f, 1.0f); + sprintf(str, "TimeSlide: %.3f", fac); + headerprint(str); + } if (G.saction->lock) { if(ob) { @@ -1014,8 +1063,11 @@ void transform_actionchannel_keys(int mode, int dummy) else DAG_object_flush_update(G.scene, ob, OB_RECALC_OB); } + remake_action_ipos(act); + G.saction->flag &= ~SACTION_MOVING; + if(cancel==0) BIF_undo_push("Transform Action"); allqueue (REDRAWVIEW3D, 0); allqueue (REDRAWACTION, 0); @@ -2202,7 +2254,10 @@ void winqreadactionspace(ScrArea *sa, void *spacedata, BWinEvent *evt) /* to do */ } else { - set_ipotype_actionchannels(SET_IPO_POPUP); + if(G.qual & LR_SHIFTKEY) + set_ipotype_actionchannels(SET_IPO_POPUP); + else + transform_actionchannel_keys ('t', 0); } break; diff --git a/source/blender/src/editmesh_add.c b/source/blender/src/editmesh_add.c index 5cdf35870e5..b2f2e154aaf 100644 --- a/source/blender/src/editmesh_add.c +++ b/source/blender/src/editmesh_add.c @@ -459,7 +459,7 @@ static void fix_new_face(EditFace *eface) short smooth=0; /* "total smoothnes" of faces in neighbourhood */ short coef; /* "weight" of smoothness */ short count=0; /* number of edges with same direction as eface */ - short vi00, vi01, vi10, vi11; /* vertex indexes */ + short vi00=0, vi01=0, vi10=0, vi11=0; /* vertex indexes */ efa = em->faces.first; diff --git a/source/blender/src/header_action.c b/source/blender/src/header_action.c index b091e0a2940..7c245132cb7 100644 --- a/source/blender/src/header_action.c +++ b/source/blender/src/header_action.c @@ -95,6 +95,7 @@ #define ACTMENU_KEY_TRANSFORM_MOVE 0 #define ACTMENU_KEY_TRANSFORM_SCALE 1 +#define ACTMENU_KEY_TRANSFORM_SLIDE 2 #define ACTMENU_KEY_HANDLE_AUTO 0 #define ACTMENU_KEY_HANDLE_ALIGN 1 @@ -140,9 +141,10 @@ void do_action_buttons(unsigned short event) float extra; calc_action_range(G.saction->action, &G.v2d->cur.xmin, &G.v2d->cur.xmax); - G.v2d->cur.xmin= get_action_frame_inv(ob, G.v2d->cur.xmin); - G.v2d->cur.xmax= get_action_frame_inv(ob, G.v2d->cur.xmax); - + if(G.saction->pin==0 && ob) { + G.v2d->cur.xmin= get_action_frame_inv(ob, G.v2d->cur.xmin); + G.v2d->cur.xmax= get_action_frame_inv(ob, G.v2d->cur.xmax); + } extra= 0.05*(G.v2d->cur.xmax - G.v2d->cur.xmin); G.v2d->cur.xmin-= extra; G.v2d->cur.xmax+= extra; @@ -413,6 +415,14 @@ static void do_action_keymenu_transformmenu(void *arg, int event) transform_actionchannel_keys ('s', 0); } break; + case ACTMENU_KEY_TRANSFORM_SLIDE: + if (key) { + //transform_meshchannel_keys('t', key); + } + else if (act) { + transform_actionchannel_keys ('t', 0); + } + break; } scrarea_queue_winredraw(curarea); @@ -428,14 +438,16 @@ static uiBlock *action_keymenu_transformmenu(void *arg_unused) uiBlockSetButmFunc(block, do_action_keymenu_transformmenu, NULL); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, - "Grab/Move|G", 0, yco-=20, - menuwidth, 19, NULL, 0.0, 0.0, 0, + "Grab/Move|G", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, ACTMENU_KEY_TRANSFORM_MOVE, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, - "Scale|S", 0, yco-=20, - menuwidth, 19, NULL, 0.0, 0.0, 0, + "Scale|S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, ACTMENU_KEY_TRANSFORM_SCALE, ""); - + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, + "Time Slide|T", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, + ACTMENU_KEY_TRANSFORM_SLIDE, ""); + + uiBlockSetDirection(block, UI_RIGHT); uiTextBoundsBlock(block, 60); |