diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-12-15 19:07:49 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-12-15 19:07:49 +0300 |
commit | ee09aeb498ee51deb8f5255cf176344a0e64aafb (patch) | |
tree | 6f13e78ee999b0d33c9096e3e806b4062e7171cf /source/blender/editors/transform | |
parent | 53adab987044654f36d4c26906b19ae559a93fc1 (diff) |
dont transform hidden handles in the graph editor.
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 63 |
1 files changed, 37 insertions, 26 deletions
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 1aac6e72228..d545acfb93a 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -3351,7 +3351,7 @@ static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt, static void createTransGraphEditData(bContext *C, TransInfo *t) { - SpaceIpo *sipo= CTX_wm_space_graph(C); + SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first; Scene *scene= t->scene; ARegion *ar= t->ar; View2D *v2d= &ar->v2d; @@ -3368,6 +3368,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) int count=0, i; float cfra; float mtx[3][3], smtx[3][3]; + const short use_handle = !(sipo->flag & SIPO_NOHANDLES); /* determine what type of data we are operating on */ if (ANIM_animdata_get_context(C, &ac) == 0) @@ -3411,13 +3412,17 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) /* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse */ for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) { if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) { + const char sel1= use_handle ? bezt->f1 & SELECT : 0; + const char sel2= bezt->f2 & SELECT; + const char sel3= use_handle ? bezt->f3 & SELECT : 0; + if (ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE)) { /* for 'normal' pivots - just include anything that is selected. this works a bit differently in translation modes */ - if (bezt->f2 & SELECT) count++; + if (sel2) count++; else { - if (bezt->f1 & SELECT) count++; - if (bezt->f3 & SELECT) count++; + if (sel1) count++; + if (sel3) count++; } } else if (sipo->around == V3D_LOCAL) { @@ -3425,17 +3430,17 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) * don't get moved wrong */ if (bezt->ipo == BEZT_IPO_BEZ) { - if (bezt->f1 & SELECT) count++; - if (bezt->f3 & SELECT) count++; + if (sel1) count++; + if (sel3) count++; } - /* else if (bezt->f2 & SELECT) count++; // TODO: could this cause problems? */ + /* else if (sel2) count++; // TODO: could this cause problems? */ /* - yes this causes problems, because no td is created for the center point */ } else { /* for 'normal' pivots - just include anything that is selected */ - if (bezt->f1 & SELECT) count++; - if (bezt->f2 & SELECT) count++; - if (bezt->f3 & SELECT) count++; + if (sel1) count++; + if (sel2) count++; + if (sel3) count++; } } } @@ -3500,21 +3505,25 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) /* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse (if applicable) */ for (i=0, bezt= fcu->bezt; i < fcu->totvert; i++, bezt++) { if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) { + const char sel1= use_handle ? bezt->f1 & SELECT : 0; + const char sel2= bezt->f2 & SELECT; + const char sel3= use_handle ? bezt->f3 & SELECT : 0; + TransDataCurveHandleFlags *hdata = NULL; short h1=1, h2=1; /* only include handles if selected, irrespective of the interpolation modes. * also, only treat handles specially if the center point isn't selected. */ - if (!ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE) || !(bezt->f2 & SELECT)) { - if (bezt->f1 & SELECT) { + if (!ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE) || !(sel2)) { + if (sel1) { hdata = initTransDataCurveHandles(td, bezt); bezt_to_transdata(td++, td2d++, adt, bezt, 0, 1, 1, intvals, mtx, smtx); } else h1= 0; - if (bezt->f3 & SELECT) { + if (sel3) { if (hdata==NULL) hdata = initTransDataCurveHandles(td, bezt); bezt_to_transdata(td++, td2d++, adt, bezt, 2, 1, 1, intvals, mtx, smtx); @@ -3524,16 +3533,16 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) } /* only include main vert if selected */ - if (bezt->f2 & SELECT && (sipo->around != V3D_LOCAL || ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE))) { + if (sel2 && (sipo->around != V3D_LOCAL || ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE))) { /* move handles relative to center */ if (ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE)) { - if (bezt->f1 & SELECT) td->flag |= TD_MOVEHANDLE1; - if (bezt->f3 & SELECT) td->flag |= TD_MOVEHANDLE2; + if (sel1) td->flag |= TD_MOVEHANDLE1; + if (sel3) td->flag |= TD_MOVEHANDLE2; } /* if handles were not selected, store their selection status */ - if (!(bezt->f1 & SELECT) && !(bezt->f3 & SELECT)) { + if (!(sel1) && !(sel3)) { if (hdata == NULL) hdata = initTransDataCurveHandles(td, bezt); } @@ -3547,7 +3556,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) * - If so, change them auto-handles to aligned handles so that handles get affected too */ if ((bezt->h1 == HD_AUTO) && (bezt->h2 == HD_AUTO) && ELEM(t->mode, TFM_ROTATION, TFM_RESIZE)) { - if (hdata && (bezt->f1 & SELECT) && (bezt->f3 & SELECT)) { + if (hdata && (sel1) && (sel3)) { bezt->h1= HD_ALIGN; bezt->h2= HD_ALIGN; } @@ -3579,7 +3588,7 @@ typedef struct BeztMap { /* This function converts an FCurve's BezTriple array to a BeztMap array * NOTE: this allocates memory that will need to get freed later */ -static BeztMap *bezt_to_beztmaps (BezTriple *bezts, int totvert) +static BeztMap *bezt_to_beztmaps (BezTriple *bezts, int totvert, const short UNUSED(use_handle)) { BezTriple *bezt= bezts; BezTriple *prevbezt= NULL; @@ -3606,7 +3615,7 @@ static BeztMap *bezt_to_beztmaps (BezTriple *bezts, int totvert) } /* This function copies the code of sort_time_ipocurve, but acts on BeztMap structs instead */ -static void sort_time_beztmaps (BeztMap *bezms, int totvert) +static void sort_time_beztmaps (BeztMap *bezms, int totvert, const short UNUSED(use_handle)) { BeztMap *bezm; int i, ok= 1; @@ -3652,7 +3661,7 @@ static void sort_time_beztmaps (BeztMap *bezms, int totvert) } /* This function firstly adjusts the pointers that the transdata has to each BezTriple */ -static void beztmap_to_data (TransInfo *t, FCurve *fcu, BeztMap *bezms, int totvert) +static void beztmap_to_data (TransInfo *t, FCurve *fcu, BeztMap *bezms, int totvert, const short use_handle) { BezTriple *bezts = fcu->bezt; BeztMap *bezm; @@ -3679,7 +3688,7 @@ static void beztmap_to_data (TransInfo *t, FCurve *fcu, BeztMap *bezms, int totv /* only selected verts */ if (bezm->pipo == BEZT_IPO_BEZ) { - if (bezm->bezt->f1 & SELECT) { + if (use_handle && bezm->bezt->f1 & SELECT) { if (td->loc2d == bezm->bezt->vec[0]) { if (bezm->swapHs == 1) td->loc2d= (bezts + bezm->newIndex)->vec[2]; @@ -3690,7 +3699,7 @@ static void beztmap_to_data (TransInfo *t, FCurve *fcu, BeztMap *bezms, int totv } } if (bezm->cipo == BEZT_IPO_BEZ) { - if (bezm->bezt->f3 & SELECT) { + if (use_handle && bezm->bezt->f3 & SELECT) { if (td->loc2d == bezm->bezt->vec[2]) { if (bezm->swapHs == 1) td->loc2d= (bezts + bezm->newIndex)->vec[0]; @@ -3728,7 +3737,9 @@ static void beztmap_to_data (TransInfo *t, FCurve *fcu, BeztMap *bezms, int totv */ void remake_graph_transdata (TransInfo *t, ListBase *anim_data) { + SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first; bAnimListElem *ale; + const short use_handle = !(sipo->flag & SIPO_NOHANDLES); /* sort and reassign verts */ for (ale= anim_data->first; ale; ale= ale->next) { @@ -3738,9 +3749,9 @@ void remake_graph_transdata (TransInfo *t, ListBase *anim_data) BeztMap *bezm; /* adjust transform-data pointers */ - bezm= bezt_to_beztmaps(fcu->bezt, fcu->totvert); - sort_time_beztmaps(bezm, fcu->totvert); - beztmap_to_data(t, fcu, bezm, fcu->totvert); + bezm= bezt_to_beztmaps(fcu->bezt, fcu->totvert, use_handle); + sort_time_beztmaps(bezm, fcu->totvert, use_handle); + beztmap_to_data(t, fcu, bezm, fcu->totvert, use_handle); /* free mapping stuff */ MEM_freeN(bezm); |