Fix Face Set Visibility operator using wrong active Face Set

The Face Set visibility operator was using the last active Face Set
updated by the paint cursor, so when the paint cursor is not used (when
using a filter or a transform tool), the active Face Set was not updating
and it was hidding the wrong Face Set based on the last cursor position
with a brush tool active. Now the Face Set Visitility operator has an
invoke callback wich forces a active vertex and face set update
regardless of the active tool, so it should always work correctly.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8580
This commit is contained in:
Pablo Dobarro 2020-08-15 17:03:58 +02:00
parent cfeadaa295
commit 762daacbc7
1 changed files with 20 additions and 0 deletions

View File

@ -932,6 +932,25 @@ static int sculpt_face_sets_change_visibility_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static int sculpt_face_sets_change_visibility_invoke(bContext *C,
wmOperator *op,
const wmEvent *event)
{
Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
/* Update the active vertex and Face Set using the cursor position to avoid relying on the paint
* cursor updates. */
SculptCursorGeometryInfo sgi;
float mouse[2];
mouse[0] = event->mval[0];
mouse[1] = event->mval[1];
SCULPT_vertex_random_access_ensure(ss);
SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
return sculpt_face_sets_change_visibility_exec(C, op);
}
void SCULPT_OT_face_sets_change_visibility(wmOperatorType *ot)
{
/* Identifiers. */
@ -941,6 +960,7 @@ void SCULPT_OT_face_sets_change_visibility(wmOperatorType *ot)
/* Api callbacks. */
ot->exec = sculpt_face_sets_change_visibility_exec;
ot->invoke = sculpt_face_sets_change_visibility_invoke;
ot->poll = SCULPT_mode_poll;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;