Fix T76563: Transforming an auto-aligned point won't set it aligned

Correct previous commit that was checking values not yet initialized,
causing T77796.
This commit is contained in:
2020-06-15 01:07:59 +10:00
parent cbd894e5a8
commit 9464260ed7
3 changed files with 36 additions and 39 deletions

View File

@@ -70,41 +70,21 @@ bool transform_mode_use_local_origins(const TransInfo *t)
* Transforming around ourselves is no use, fallback to individual origins,
* useful for curve/armatures.
*/
void transform_around_single_fallback(TransInfo *t)
void transform_around_single_fallback_ex(TransInfo *t, int data_len_all)
{
if ((ELEM(t->around, V3D_AROUND_CENTER_BOUNDS, V3D_AROUND_CENTER_MEDIAN, V3D_AROUND_ACTIVE)) &&
transform_mode_use_local_origins(t)) {
bool is_data_single = false;
if (t->data_len_all == 1) {
is_data_single = true;
}
else if (t->data_len_all == 3) {
if (t->obedit_type == OB_CURVE) {
/* Special case check for curve, if we have a single curve bezier triple selected
* treat */
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
if (!tc->data_len) {
continue;
}
if (tc->data_len == 3) {
const TransData *td = tc->data;
if ((td[0].flag | td[1].flag | td[2].flag) & TD_BEZTRIPLE) {
if ((td[0].loc == td[1].loc) && (td[1].loc == td[2].loc)) {
is_data_single = true;
}
}
}
break;
}
}
}
if (is_data_single) {
if (data_len_all == 1) {
t->around = V3D_AROUND_LOCAL_ORIGINS;
}
}
}
void transform_around_single_fallback(TransInfo *t)
{
transform_around_single_fallback_ex(t, t->data_len_all);
}
/* -------------------------------------------------------------------- */
/** \name Proportional Editing
* \{ */

View File

@@ -84,6 +84,7 @@ typedef enum eTransConvertType {
/* transform_convert.c */
bool transform_mode_use_local_origins(const TransInfo *t);
void transform_around_single_fallback_ex(TransInfo *t, int data_len_all);
void transform_around_single_fallback(TransInfo *t);
void posttrans_fcurve_clean(struct FCurve *fcu, const int sel_flag, const bool use_handle);
bool constraints_list_needinv(TransInfo *t, ListBase *list);

View File

@@ -87,6 +87,10 @@ void createTransCurveVerts(TransInfo *t)
t->data_len_all = 0;
/* Count control points (one per bez-triple) 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,6 +98,7 @@ 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;
View3D *v3d = t->view;
short hide_handles = (v3d != NULL) ? (v3d->overlay.handle_display == CURVE_HANDLE_NONE) :
@@ -106,17 +111,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,11 +133,13 @@ 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++;
}
}
}
@@ -140,18 +151,23 @@ void createTransCurveVerts(TransInfo *t)
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) {