diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-10-01 12:18:43 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-10-01 12:18:43 +0400 |
commit | f1f7648d4ce51b29f17108ff96287de3994d00b0 (patch) | |
tree | 6e83ba72adcce0d381f0a2cd98e7b78595aedf5d /source/blender | |
parent | 4cd779936484043b976f4d84a4480fdbda30f548 (diff) |
fix for error setting vector handles to free when both vector handles were selected but not the mid-point.
only one of the handles would be changed to the HD_FREE.
effected curves and fcurves.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_curve.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_fcurve.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/curve.c | 99 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/fcurve.c | 48 | ||||
-rw-r--r-- | source/blender/editors/animation/keyframes_edit.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_buttons.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_snap.c | 2 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 2 |
8 files changed, 70 insertions, 90 deletions
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index ac114a62de6..07116979eab 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -155,6 +155,7 @@ void BKE_nurb_handle_calc_simple(struct Nurb *nu, struct BezTriple *bezt); void BKE_nurb_handles_calc(struct Nurb *nu); void BKE_nurb_handles_autocalc(struct Nurb *nu, int flag); -void BKE_nurb_handles_test(struct Nurb *nu); +void BKE_nurb_bezt_handle_test(struct BezTriple *bezt, const bool use_handle); +void BKE_nurb_handles_test(struct Nurb *nu, const bool use_handles); #endif /* __BKE_CURVE_H__ */ diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h index 64a6811bf51..6e64c2f60c5 100644 --- a/source/blender/blenkernel/BKE_fcurve.h +++ b/source/blender/blenkernel/BKE_fcurve.h @@ -234,7 +234,7 @@ short fcurve_is_keyframable(struct FCurve *fcu); /* -------- Curve Sanity -------- */ void calchandles_fcurve(struct FCurve *fcu); -void testhandles_fcurve(struct FCurve *fcu, const short use_handle); +void testhandles_fcurve(struct FCurve *fcu, const bool use_handle); void sort_time_fcurve(struct FCurve *fcu); short test_time_fcurve(struct FCurve *fcu); diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 02b35794d28..bfe575575b5 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -3102,46 +3102,67 @@ void BKE_nurb_handle_calc_simple(Nurb *nu, BezTriple *bezt) } } -void BKE_nurb_handles_test(Nurb *nu) -{ - /* use when something has changed with handles. - * it treats all BezTriples with the following rules: - * PHASE 1: do types have to be altered? - * Auto handles: become aligned when selection status is NOT(000 || 111) - * Vector handles: become 'nothing' when (one half selected AND other not) - * PHASE 2: recalculate handles - */ - BezTriple *bezt; - short flag, a; +/** + * Use when something has changed handle positions. + * + * The caller needs to recalculate handles. + */ +void BKE_nurb_bezt_handle_test(BezTriple *bezt, const bool use_handle) +{ + short flag = 0; - if (nu->type != CU_BEZIER) return; +#define SEL_F1 (1 << 0) +#define SEL_F2 (1 << 1) +#define SEL_F3 (1 << 2) - bezt = nu->bezt; - a = nu->pntsu; - while (a--) { - flag = 0; - if (bezt->f1 & SELECT) - flag++; - if (bezt->f2 & SELECT) - flag += 2; - if (bezt->f3 & SELECT) - flag += 4; + if (use_handle) { + if (bezt->f1 & SELECT) flag |= SEL_F1; + if (bezt->f2 & SELECT) flag |= SEL_F2; + if (bezt->f3 & SELECT) flag |= SEL_F3; + } + else { + flag = (bezt->f2 & SELECT) ? (SEL_F1 | SEL_F2 | SEL_F3) : 0; + } - if (!(flag == 0 || flag == 7) ) { - if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM)) { /* auto */ - bezt->h1 = HD_ALIGN; - } - if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { /* auto */ - bezt->h2 = HD_ALIGN; - } + /* check for partial selection */ + if (!ELEM(flag, 0, SEL_F1 | SEL_F2 | SEL_F3)) { + if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM)) { + bezt->h1 = HD_ALIGN; + } + if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { + bezt->h2 = HD_ALIGN; + } - if (bezt->h1 == HD_VECT) { /* vector */ - if (flag < 4) bezt->h1 = 0; + if (bezt->h1 == HD_VECT) { + if ((!(flag & SEL_F1)) != (!(flag & SEL_F2))) { + bezt->h1 = HD_FREE; } - if (bezt->h2 == HD_VECT) { /* vector */ - if (flag > 3) bezt->h2 = 0; + } + if (bezt->h2 == HD_VECT) { + if ((!(flag & SEL_F3)) != (!(flag & SEL_F2))) { + bezt->h2 = HD_FREE; } } + } + +#undef SEL_F1 +#undef SEL_F2 +#undef SEL_F3 + +} + +void BKE_nurb_handles_test(Nurb *nu, const bool use_handle) +{ + BezTriple *bezt; + short a; + + if (nu->type != CU_BEZIER) + return; + + bezt = nu->bezt; + a = nu->pntsu; + while (a--) { + BKE_nurb_bezt_handle_test(bezt, use_handle); bezt++; } @@ -3168,7 +3189,7 @@ void BKE_nurb_handles_autocalc(Nurb *nu, int flag) /* left handle: */ if (flag == 0 || (bezt1->f1 & flag) ) { - bezt1->h1 = 0; + bezt1->h1 = HD_FREE; /* distance too short: vectorhandle */ if (len_v3v3(bezt1->vec[1], bezt0->vec[1]) < 0.0001f) { bezt1->h1 = HD_VECT; @@ -3187,7 +3208,7 @@ void BKE_nurb_handles_autocalc(Nurb *nu, int flag) } /* right handle: */ if (flag == 0 || (bezt1->f3 & flag) ) { - bezt1->h2 = 0; + bezt1->h2 = HD_FREE; /* distance too short: vectorhandle */ if (len_v3v3(bezt1->vec[1], bezt2->vec[1]) < 0.0001f) { bezt1->h2 = HD_VECT; @@ -3203,15 +3224,15 @@ void BKE_nurb_handles_autocalc(Nurb *nu, int flag) } } if (leftsmall && bezt1->h2 == HD_ALIGN) - bezt1->h2 = 0; + bezt1->h2 = HD_FREE; if (rightsmall && bezt1->h1 == HD_ALIGN) - bezt1->h1 = 0; + bezt1->h1 = HD_FREE; /* undesired combination: */ if (bezt1->h1 == HD_ALIGN && bezt1->h2 == HD_VECT) - bezt1->h1 = 0; + bezt1->h1 = HD_FREE; if (bezt1->h2 == HD_ALIGN && bezt1->h1 == HD_VECT) - bezt1->h2 = 0; + bezt1->h2 = HD_FREE; bezt0 = bezt1; bezt1 = bezt2; diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 791c47cc551..88539814c52 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -841,14 +841,7 @@ void calchandles_fcurve(FCurve *fcu) } } -/* Use when F-Curve with handles has changed - * It treats all BezTriples with the following rules: - * - PHASE 1: do types have to be altered? - * -> Auto handles: become aligned when selection status is NOT(000 || 111) - * -> Vector handles: become 'nothing' when (one half selected AND other not) - * - PHASE 2: recalculate handles - */ -void testhandles_fcurve(FCurve *fcu, const short use_handle) +void testhandles_fcurve(FCurve *fcu, const bool use_handle) { BezTriple *bezt; unsigned int a; @@ -856,45 +849,10 @@ void testhandles_fcurve(FCurve *fcu, const short use_handle) /* only beztriples have handles (bpoints don't though) */ if (ELEM(NULL, fcu, fcu->bezt)) return; - + /* loop over beztriples */ for (a = 0, bezt = fcu->bezt; a < fcu->totvert; a++, bezt++) { - short flag = 0; - - /* flag is initialized as selection status - * of beztriple control-points (labelled 0, 1, 2) - */ - if (bezt->f2 & SELECT) flag |= (1 << 1); // == 2 - if (use_handle == FALSE) { - if (flag & 2) { - flag |= (1 << 0) | (1 << 2); - } - } - else { - if (bezt->f1 & SELECT) flag |= (1 << 0); // == 1 - if (bezt->f3 & SELECT) flag |= (1 << 2); // == 4 - } - - /* one or two handles selected only */ - if (ELEM(flag, 0, 7) == 0) { - /* auto handles become aligned */ - if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM)) - bezt->h1 = HD_ALIGN; - if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) - bezt->h2 = HD_ALIGN; - - /* vector handles become 'free' when only one half selected */ - if (bezt->h1 == HD_VECT) { - /* only left half (1 or 2 or 1+2) */ - if (flag < 4) - bezt->h1 = 0; - } - if (bezt->h2 == HD_VECT) { - /* only right half (4 or 2+4) */ - if (flag > 3) - bezt->h2 = 0; - } - } + BKE_nurb_bezt_handle_test(bezt, use_handle); } /* recalculate handles */ diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index decbc351cad..71717284d8e 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -396,7 +396,7 @@ void ANIM_editkeyframes_refresh(bAnimContext *ac) int filter; /* when not in graph view, don't use handles */ SpaceIpo *sipo = (ac->spacetype == SPACE_IPO) ? (SpaceIpo *)ac->sl : NULL; - const short use_handle = sipo ? !(sipo->flag & SIPO_NOHANDLES) : FALSE; + const bool use_handle = sipo ? !(sipo->flag & SIPO_NOHANDLES) : false; /* filter animation data */ filter = ANIMFILTER_DATA_VISIBLE; diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 75e7605df6b..eea084b4750 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -682,7 +682,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float } } BKE_nurb_test2D(nu); - BKE_nurb_handles_test(nu); /* test for bezier too */ + BKE_nurb_handles_test(nu, true); /* test for bezier too */ nu = nu->next; } diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 5f988edb950..7c29ab01c24 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -143,7 +143,7 @@ static void special_transvert_update(Object *obedit) } BKE_nurb_test2D(nu); - BKE_nurb_handles_test(nu); /* test for bezier too */ + BKE_nurb_handles_test(nu, true); /* test for bezier too */ nu = nu->next; } } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 7110e7a66c5..35896f65668 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -1571,7 +1571,7 @@ static void createTransCurveVerts(TransInfo *t) * but for now just don't change handle types */ if (ELEM(t->mode, TFM_CURVE_SHRINKFATTEN, TFM_TILT) == 0) { /* sets the handles based on their selection, do this after the data is copied to the TransData */ - BKE_nurb_handles_test(nu); + BKE_nurb_handles_test(nu, !hide_handles); } } else { |