Fix T76563: Transforming an auto-aligned point won't set it aligned
When local origins are used or a single control point is selected, change the handle types from auto to aligned.
This commit is contained in:
parent
0a32f6c868
commit
fe0036c586
@ -259,8 +259,9 @@ void BKE_nurb_handles_calc(struct Nurb *nu);
|
||||
void BKE_nurb_handles_autocalc(struct Nurb *nu, int flag);
|
||||
void BKE_nurb_bezt_handle_test(struct BezTriple *bezt,
|
||||
const eBezTriple_Flag__Alias sel_flag,
|
||||
const bool use_handle);
|
||||
void BKE_nurb_handles_test(struct Nurb *nu, const bool use_handles);
|
||||
const bool use_handle,
|
||||
const bool use_around_local);
|
||||
void BKE_nurb_handles_test(struct Nurb *nu, const bool use_handles, const bool use_around_local);
|
||||
|
||||
/* **** Depsgraph evaluation **** */
|
||||
|
||||
|
@ -4151,7 +4151,8 @@ void BKE_nurb_handle_calc_simple_auto(Nurb *nu, BezTriple *bezt)
|
||||
*/
|
||||
void BKE_nurb_bezt_handle_test(BezTriple *bezt,
|
||||
const eBezTriple_Flag__Alias sel_flag,
|
||||
const bool use_handle)
|
||||
const bool use_handle,
|
||||
const bool use_around_local)
|
||||
{
|
||||
short flag = 0;
|
||||
|
||||
@ -4174,6 +4175,10 @@ void BKE_nurb_bezt_handle_test(BezTriple *bezt,
|
||||
flag = (bezt->f2 & sel_flag) ? (SEL_F1 | SEL_F2 | SEL_F3) : 0;
|
||||
}
|
||||
|
||||
if (use_around_local) {
|
||||
flag &= ~SEL_F2;
|
||||
}
|
||||
|
||||
/* check for partial selection */
|
||||
if (!ELEM(flag, 0, SEL_F1 | SEL_F2 | SEL_F3)) {
|
||||
if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM)) {
|
||||
@ -4200,7 +4205,7 @@ void BKE_nurb_bezt_handle_test(BezTriple *bezt,
|
||||
#undef SEL_F3
|
||||
}
|
||||
|
||||
void BKE_nurb_handles_test(Nurb *nu, const bool use_handle)
|
||||
void BKE_nurb_handles_test(Nurb *nu, const bool use_handle, const bool use_around_local)
|
||||
{
|
||||
BezTriple *bezt;
|
||||
int a;
|
||||
@ -4212,7 +4217,7 @@ void BKE_nurb_handles_test(Nurb *nu, const bool use_handle)
|
||||
bezt = nu->bezt;
|
||||
a = nu->pntsu;
|
||||
while (a--) {
|
||||
BKE_nurb_bezt_handle_test(bezt, SELECT, use_handle);
|
||||
BKE_nurb_bezt_handle_test(bezt, SELECT, use_handle, use_around_local);
|
||||
bezt++;
|
||||
}
|
||||
|
||||
|
@ -1168,7 +1168,7 @@ void testhandles_fcurve(FCurve *fcu, eBezTriple_Flag sel_flag, const bool use_ha
|
||||
|
||||
/* loop over beztriples */
|
||||
for (a = 0, bezt = fcu->bezt; a < fcu->totvert; a++, bezt++) {
|
||||
BKE_nurb_bezt_handle_test(bezt, sel_flag, use_handle);
|
||||
BKE_nurb_bezt_handle_test(bezt, sel_flag, use_handle, false);
|
||||
}
|
||||
|
||||
/* recalculate handles */
|
||||
|
@ -294,7 +294,7 @@ static void graphedit_activekey_handles_cb(bContext *C, void *fcu_ptr, void *bez
|
||||
bezt->h2 = HD_ALIGN;
|
||||
}
|
||||
else {
|
||||
BKE_nurb_bezt_handle_test(bezt, SELECT, true);
|
||||
BKE_nurb_bezt_handle_test(bezt, SELECT, true, false);
|
||||
}
|
||||
|
||||
/* now call standard updates */
|
||||
|
@ -1005,7 +1005,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
|
||||
}
|
||||
}
|
||||
BKE_nurb_test_2d(nu);
|
||||
BKE_nurb_handles_test(nu, true); /* test for bezier too */
|
||||
BKE_nurb_handles_test(nu, true, false); /* test for bezier too */
|
||||
|
||||
nu = nu->next;
|
||||
}
|
||||
|
@ -83,16 +83,45 @@
|
||||
#include "transform_convert.h"
|
||||
#include "transform_mode.h"
|
||||
|
||||
bool transform_mode_use_local_origins(const TransInfo *t)
|
||||
{
|
||||
return ELEM(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforming around ourselves is no use, fallback to individual origins,
|
||||
* useful for curve/armatures.
|
||||
*/
|
||||
void transform_around_single_fallback(TransInfo *t)
|
||||
{
|
||||
if ((t->data_len_all == 1) &&
|
||||
(ELEM(t->around, V3D_AROUND_CENTER_BOUNDS, V3D_AROUND_CENTER_MEDIAN, V3D_AROUND_ACTIVE)) &&
|
||||
(ELEM(t->mode, TFM_RESIZE, TFM_ROTATION, TFM_TRACKBALL))) {
|
||||
t->around = V3D_AROUND_LOCAL_ORIGINS;
|
||||
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].loc == td[1].loc) && (td[1].loc == td[2].loc)) {
|
||||
is_data_single = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_data_single) {
|
||||
t->around = V3D_AROUND_LOCAL_ORIGINS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,6 +100,7 @@ void flushTransTracking(TransInfo *t);
|
||||
/********************* intern **********************/
|
||||
|
||||
/* transform_convert.c */
|
||||
bool transform_mode_use_local_origins(const TransInfo *t);
|
||||
void transform_around_single_fallback(TransInfo *t);
|
||||
bool constraints_list_needinv(TransInfo *t, ListBase *list);
|
||||
void calc_distanceCurveVerts(TransData *head, TransData *tail);
|
||||
|
@ -167,6 +167,8 @@ void createTransCurveVerts(TransInfo *t)
|
||||
((v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_CU_HANDLES) == 0) :
|
||||
false;
|
||||
|
||||
bool use_around_origins_for_handles_test = ((t->around == V3D_AROUND_LOCAL_ORIGINS) &&
|
||||
transform_mode_use_local_origins(t));
|
||||
float mtx[3][3], smtx[3][3];
|
||||
|
||||
copy_m3_m4(mtx, tc->obedit->obmat);
|
||||
@ -342,7 +344,7 @@ void createTransCurveVerts(TransInfo *t)
|
||||
if (ELEM(t->mode, TFM_CURVE_SHRINKFATTEN, TFM_TILT, TFM_DUMMY) == 0) {
|
||||
/* sets the handles based on their selection,
|
||||
* do this after the data is copied to the TransData */
|
||||
BKE_nurb_handles_test(nu, !hide_handles);
|
||||
BKE_nurb_handles_test(nu, !hide_handles, use_around_origins_for_handles_test);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -111,7 +111,7 @@ void ED_transverts_update_obedit(TransVertStore *tvs, Object *obedit)
|
||||
}
|
||||
|
||||
BKE_nurb_test_2d(nu);
|
||||
BKE_nurb_handles_test(nu, true); /* test for bezier too */
|
||||
BKE_nurb_handles_test(nu, true, false); /* test for bezier too */
|
||||
nu = nu->next;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user