diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-05-09 16:42:19 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-05-09 16:42:19 +0400 |
commit | 1e30f000308debebf7cd5bbf6a9b37b8a94182de (patch) | |
tree | d6edeb35644fd1048d4b71d1f55ef1ab019bacef /source/blender/editors/transform/transform.c | |
parent | 8a20433f0fef5ab2d881d010cd5bd19fe484e555 (diff) | |
parent | 80f6671dfe64ece1e692c8032e1d1169621bceff (diff) |
Merged changes in the trunk up to revision 28685.
Diffstat (limited to 'source/blender/editors/transform/transform.c')
-rw-r--r-- | source/blender/editors/transform/transform.c | 67 |
1 files changed, 49 insertions, 18 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index bdf92039619..2002eb5a549 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -202,17 +202,33 @@ void projectIntView(TransInfo *t, float *vec, int *adr) UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr+1); } - else if(ELEM3(t->spacetype, SPACE_IPO, SPACE_NLA, SPACE_ACTION)) { + else if(t->spacetype == SPACE_ACTION) { + SpaceAction *sact = t->sa->spacedata.first; int out[2] = {0, 0}; - UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], out, out+1); + if (sact->flag & SACTION_DRAWTIME) { + //vec[0] = vec[0]/((t->scene->r.frs_sec / t->scene->r.frs_sec_base)); + + UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1); + } + else { + UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1); + } + + adr[0]= out[0]; + adr[1]= out[1]; + } + else if(ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) { + int out[2] = {0, 0}; + + UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1); adr[0]= out[0]; adr[1]= out[1]; } else if(t->spacetype==SPACE_SEQ) { /* XXX not tested yet, but should work */ int out[2] = {0, 0}; - UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], out, out+1); + UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1); adr[0]= out[0]; adr[1]= out[1]; } @@ -4328,7 +4344,7 @@ static int createSlideVerts(TransInfo *t) // populate the SlideVerts - vertgh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + vertgh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "createSlideVerts gh"); look = vertlist; while(look) { i=0; @@ -4529,7 +4545,7 @@ static int createSlideVerts(TransInfo *t) for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) { - uvarray[uvlay_idx] = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + uvarray[uvlay_idx] = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "createSlideVerts2 gh"); for(ev=em->verts.first;ev;ev=ev->next) { ev->tmp.l = 0; @@ -5285,27 +5301,27 @@ static short getAnimEdit_DrawTime(TransInfo *t) /* This function is used by Animation Editor specific transform functions to do * the Snap Keyframe to Nearest Frame/Marker */ -static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, AnimData *adt, short autosnap) +static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d, AnimData *adt, short autosnap) { /* snap key to nearest frame? */ if (autosnap == SACTSNAP_FRAME) { const Scene *scene= t->scene; - const short doTime= getAnimEdit_DrawTime(t); + const short doTime= 0; //XXX doesn't work - getAnimEdit_DrawTime(t); const double secf= FPS; double val; - + /* convert frame to nla-action time (if needed) */ if (adt) val= BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP); else val= *(td->val); - + /* do the snapping to nearest frame/second */ if (doTime) val= (float)( floor((val/secf) + 0.5f) * secf ); else val= (float)( floor(val+0.5f) ); - + /* convert frame out of nla-action time */ if (adt) *(td->val)= BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP); @@ -5315,23 +5331,34 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, AnimData *adt, sho /* snap key to nearest marker? */ else if (autosnap == SACTSNAP_MARKER) { float val; - + /* convert frame to nla-action time (if needed) */ if (adt) val= BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP); else val= *(td->val); - + /* snap to nearest marker */ // TODO: need some more careful checks for where data comes from val= (float)ED_markers_find_nearest_marker_time(&t->scene->markers, val); - + /* convert frame out of nla-action time */ if (adt) *(td->val)= BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP); else *(td->val)= val; } + + /* if the handles are to be moved too (as side-effect of keyframes moving, to keep the general effect) + * offset them by the same amount so that the general angles are maintained (i.e. won't change while + * handles are free-to-roam and keyframes are snap-locked) + */ + if ((td->flag & TD_MOVEHANDLE1) && td2d->h1) { + td2d->h1[0] = td2d->ih1[0] + *td->val - td->ival; + } + if ((td->flag & TD_MOVEHANDLE2) && td2d->h2) { + td2d->h2[0] = td2d->ih2[0] + *td->val - td->ival; + } } /* ----------------- Translation ----------------------- */ @@ -5394,6 +5421,7 @@ static void headerTimeTranslate(TransInfo *t, char *str) static void applyTimeTranslate(TransInfo *t, float sval) { TransData *td = t->data; + TransData2D *td2d = t->data2d; Scene *scene = t->scene; int i; @@ -5402,16 +5430,18 @@ static void applyTimeTranslate(TransInfo *t, float sval) const short autosnap= getAnimEdit_SnapMode(t); - float deltax, val; + float deltax, val, valprev; /* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */ - for (i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++, td2d++) { /* it is assumed that td->extra is a pointer to the AnimData, * whose active action is where this keyframe comes from * (this is only valid when not in NLA) */ AnimData *adt= (t->spacetype != SPACE_NLA) ? td->extra : NULL; + valprev = *td->val; + /* check if any need to apply nla-mapping */ if (adt && t->spacetype != SPACE_SEQ) { deltax = t->values[0]; @@ -5441,7 +5471,7 @@ static void applyTimeTranslate(TransInfo *t, float sval) } /* apply nearest snapping */ - doAnimEdit_SnapFrame(t, td, adt, autosnap); + doAnimEdit_SnapFrame(t, td, td2d, adt, autosnap); } } @@ -5652,6 +5682,7 @@ static void headerTimeScale(TransInfo *t, char *str) { static void applyTimeScale(TransInfo *t) { Scene *scene = t->scene; TransData *td = t->data; + TransData2D *td2d = t->data2d; int i; const short autosnap= getAnimEdit_SnapMode(t); @@ -5659,7 +5690,7 @@ static void applyTimeScale(TransInfo *t) { const double secf= FPS; - for (i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++, td2d++) { /* it is assumed that td->extra is a pointer to the AnimData, * whose active action is where this keyframe comes from * (this is only valid when not in NLA) @@ -5685,7 +5716,7 @@ static void applyTimeScale(TransInfo *t) { *(td->val) += startx; /* apply nearest snapping */ - doAnimEdit_SnapFrame(t, td, adt, autosnap); + doAnimEdit_SnapFrame(t, td, td2d, adt, autosnap); } } |