Fix curve set handle type not respecting hidden handles

The handle selection should be ignored when hidden.
Now set handle type considers all handles selected when handles
are hidden and the knot is selected.
This commit is contained in:
Campbell Barton 2023-09-06 21:15:07 +10:00
parent 8c85fd90cb
commit 3cfa61291b
3 changed files with 17 additions and 8 deletions

View File

@ -212,7 +212,9 @@ void BKE_nurbList_duplicate(struct ListBase *lb1, const struct ListBase *lb2);
* - 5: Set align, like 3 but no toggle.
* - 6: Clear align (setting #HD_FREE), like 3 but no toggle.
*/
void BKE_nurbList_handles_set(struct ListBase *editnurb, char code);
void BKE_nurbList_handles_set(struct ListBase *editnurb,
eNurbHandleTest_Mode handle_mode,
char code);
void BKE_nurbList_handles_recalculate(struct ListBase *editnurb, bool calc_length, uint8_t flag);
void BKE_nurbList_handles_autocalc(ListBase *editnurb, uint8_t flag);

View File

@ -4214,7 +4214,9 @@ void BKE_nurbList_handles_autocalc(ListBase *editnurb, uint8_t flag)
}
}
void BKE_nurbList_handles_set(ListBase *editnurb, const char code)
void BKE_nurbList_handles_set(ListBase *editnurb,
eNurbHandleTest_Mode handle_mode,
const char code)
{
BezTriple *bezt;
int a;
@ -4225,11 +4227,12 @@ void BKE_nurbList_handles_set(ListBase *editnurb, const char code)
bezt = nu->bezt;
a = nu->pntsu;
while (a--) {
if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) {
if (bezt->f1 & SELECT) {
const short flag = BKE_nurb_bezt_handle_test_calc_flag(bezt, SELECT, handle_mode);
if ((flag & (1 << 0)) || (flag & (1 << 2))) {
if (flag & (1 << 0)) {
bezt->h1 = code;
}
if (bezt->f3 & SELECT) {
if (flag & (1 << 2)) {
bezt->h2 = code;
}
if (bezt->h1 != bezt->h2) {
@ -4266,8 +4269,9 @@ void BKE_nurbList_handles_set(ListBase *editnurb, const char code)
bezt = nu->bezt;
a = nu->pntsu;
while (a--) {
if (((bezt->f1 & SELECT) && bezt->h1 != HD_FREE) ||
((bezt->f3 & SELECT) && bezt->h2 != HD_FREE)) {
const short flag = BKE_nurb_bezt_handle_test_calc_flag(bezt, SELECT, handle_mode);
if (((flag & (1 << 0)) && bezt->h1 != HD_FREE) ||
((flag & (1 << 2)) && bezt->h2 != HD_FREE)) {
h_new = HD_AUTO;
break;
}

View File

@ -3974,6 +3974,9 @@ static int set_handle_type_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
View3D *v3d = CTX_wm_view3d(C);
const int handle_type = RNA_enum_get(op->ptr, "type");
const bool hide_handles = (v3d && (v3d->overlay.handle_display == CURVE_HANDLE_NONE));
const eNurbHandleTest_Mode handle_mode = hide_handles ? NURB_HANDLE_TEST_KNOT_ONLY :
NURB_HANDLE_TEST_EACH;
uint objects_len;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
@ -3987,7 +3990,7 @@ static int set_handle_type_exec(bContext *C, wmOperator *op)
}
ListBase *editnurb = object_editcurve_get(obedit);
BKE_nurbList_handles_set(editnurb, handle_type);
BKE_nurbList_handles_set(editnurb, handle_mode, handle_type);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
DEG_id_tag_update(static_cast<ID *>(obedit->data), 0);