diff options
Diffstat (limited to 'source/blender/editors/transform/transform_convert_curve.c')
-rw-r--r-- | source/blender/editors/transform/transform_convert_curve.c | 64 |
1 files changed, 43 insertions, 21 deletions
diff --git a/source/blender/editors/transform/transform_convert_curve.c b/source/blender/editors/transform/transform_convert_curve.c index c5e1e59b9e6..65b2c9f9382 100644 --- a/source/blender/editors/transform/transform_convert_curve.c +++ b/source/blender/editors/transform/transform_convert_curve.c @@ -64,7 +64,7 @@ static int bezt_select_to_transform_triple_flag(const BezTriple *bezt, const boo * When a center point is being moved without the handles, * leaving the handles stationary makes no sense and only causes strange behavior, * where one handle is arbitrarily anchored, the other one is aligned and lengthened - * based on where the center point is moved. Also a bug when cancelling, see: T52007. + * based on where the center point is moved. Also a bug when canceling, see: T52007. * * A more 'correct' solution could be to store handle locations in 'TransDataCurveHandleFlags'. * However that doesn't resolve odd behavior, so best transform the handles in this case. @@ -87,6 +87,10 @@ void createTransCurveVerts(TransInfo *t) t->data_len_all = 0; + /* Count control points (one per #BezTriple) if any number of handles are selected. + * Needed for #transform_around_single_fallback_ex. */ + int data_len_all_pt = 0; + FOREACH_TRANS_DATA_CONTAINER (t, tc) { Curve *cu = tc->obedit->data; BLI_assert(cu->editnurb != NULL); @@ -94,7 +98,9 @@ void createTransCurveVerts(TransInfo *t) BPoint *bp; int a; int count = 0, countsel = 0; + int count_pt = 0, countsel_pt = 0; const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0; + const bool is_prop_connected = (t->flag & T_PROP_CONNECTED) != 0; View3D *v3d = t->view; short hide_handles = (v3d != NULL) ? (v3d->overlay.handle_display == CURVE_HANDLE_NONE) : false; @@ -106,17 +112,21 @@ void createTransCurveVerts(TransInfo *t) for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) { if (bezt->hide == 0) { const int bezt_tx = bezt_select_to_transform_triple_flag(bezt, hide_handles); - if (bezt_tx & SEL_F1) { - countsel++; - } - if (bezt_tx & SEL_F2) { - countsel++; - } - if (bezt_tx & SEL_F3) { - countsel++; + if (bezt_tx & (SEL_F1 | SEL_F2 | SEL_F3)) { + if (bezt_tx & SEL_F1) { + countsel++; + } + if (bezt_tx & SEL_F2) { + countsel++; + } + if (bezt_tx & SEL_F3) { + countsel++; + } + countsel_pt++; } if (is_prop_edit) { count += 3; + count_pt++; } } } @@ -124,34 +134,42 @@ void createTransCurveVerts(TransInfo *t) else { for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a > 0; a--, bp++) { if (bp->hide == 0) { - if (is_prop_edit) { - count++; - } if (bp->f1 & SELECT) { countsel++; + countsel_pt++; + } + if (is_prop_edit) { + count++; + count_pt++; } } } } } - /* note: in prop mode we need at least 1 selected */ - if (countsel == 0) { + + /* Support other objects using PET to adjust these, unless connected is enabled. */ + if (((is_prop_edit && !is_prop_connected) ? count : countsel) == 0) { tc->data_len = 0; continue; } + int data_len_pt = 0; + if (is_prop_edit) { tc->data_len = count; + data_len_pt = count_pt; } else { tc->data_len = countsel; + data_len_pt = countsel_pt; } tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Curve EditMode)"); t->data_len_all += tc->data_len; + data_len_all_pt += data_len_pt; } - transform_around_single_fallback(t); + transform_around_single_fallback_ex(t, data_len_all_pt); t->data_len_all = -1; FOREACH_TRANS_DATA_CONTAINER (t, tc) { @@ -332,12 +350,14 @@ void createTransCurveVerts(TransInfo *t) (void)hdata; /* quiet warning */ } else if (is_prop_edit && head != tail) { - calc_distanceCurveVerts(head, tail - 1); - head = tail; + tail->flag |= TD_NOTCONNECTED; + td++; + tail++; } } if (is_prop_edit && head != tail) { - calc_distanceCurveVerts(head, tail - 1); + bool cyclic = (nu->flagu & CU_NURB_CYCLIC) != 0; + calc_distanceCurveVerts(head, tail - 1, cyclic); } /* TODO - in the case of tilt and radius we can also avoid allocating the @@ -407,12 +427,14 @@ void createTransCurveVerts(TransInfo *t) } } else if (is_prop_edit && head != tail) { - calc_distanceCurveVerts(head, tail - 1); - head = tail; + tail->flag |= TD_NOTCONNECTED; + td++; + tail++; } } if (is_prop_edit && head != tail) { - calc_distanceCurveVerts(head, tail - 1); + bool cyclic = (nu->flagu & CU_NURB_CYCLIC) != 0; + calc_distanceCurveVerts(head, tail - 1, cyclic); } } } |