Fix #133720: Grease Pencil fill operator always enters modal operation
If the "Visual Aids" option (aka. "show extension lines") is disabled the operator should just apply and exit immediately. Pull Request: https://projects.blender.org/blender/blender/pulls/133809
This commit is contained in:
@@ -1677,36 +1677,45 @@ static int grease_pencil_fill_modal(bContext *C, wmOperator *op, const wmEvent *
|
||||
|
||||
auto &op_data = *static_cast<GreasePencilFillOpData *>(op->customdata);
|
||||
|
||||
int estate = OPERATOR_RUNNING_MODAL;
|
||||
switch (event->type) {
|
||||
case EVT_MODAL_MAP:
|
||||
estate = grease_pencil_fill_event_modal_map(C, op, event);
|
||||
break;
|
||||
case MOUSEMOVE: {
|
||||
if (!op_data.is_extension_drag_active) {
|
||||
int estate = OPERATOR_CANCELLED;
|
||||
if (!op_data.show_extension) {
|
||||
/* Apply fill immediately if "Visual Aids" (aka. extension lines) is disabled. */
|
||||
op_data.fill_mouse_pos = float2(event->mval);
|
||||
estate = (grease_pencil_apply_fill(*C, *op, *event) ? OPERATOR_FINISHED : OPERATOR_CANCELLED);
|
||||
}
|
||||
else {
|
||||
estate = OPERATOR_RUNNING_MODAL;
|
||||
switch (event->type) {
|
||||
case EVT_MODAL_MAP:
|
||||
estate = grease_pencil_fill_event_modal_map(C, op, event);
|
||||
break;
|
||||
case MOUSEMOVE: {
|
||||
if (!op_data.is_extension_drag_active) {
|
||||
break;
|
||||
}
|
||||
|
||||
const Object &ob = *CTX_data_active_object(C);
|
||||
const float pixel_size = ED_view3d_pixel_size(&rv3d, ob.loc);
|
||||
const float2 mouse_pos = float2(event->mval);
|
||||
const float initial_dist = math::distance(op_data.extension_mouse_pos,
|
||||
op_data.fill_mouse_pos);
|
||||
const float current_dist = math::distance(mouse_pos, op_data.fill_mouse_pos);
|
||||
|
||||
float delta = (current_dist - initial_dist) * pixel_size * 0.5f;
|
||||
op_data.extension_length = std::clamp(op_data.extension_length + delta, 0.0f, 10.0f);
|
||||
|
||||
/* Update cursor line and extend lines. */
|
||||
WM_main_add_notifier(NC_GEOM | ND_DATA, nullptr);
|
||||
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, nullptr);
|
||||
|
||||
grease_pencil_update_extend(*C, op_data);
|
||||
break;
|
||||
}
|
||||
|
||||
const Object &ob = *CTX_data_active_object(C);
|
||||
const float pixel_size = ED_view3d_pixel_size(&rv3d, ob.loc);
|
||||
const float2 mouse_pos = float2(event->mval);
|
||||
const float initial_dist = math::distance(op_data.extension_mouse_pos,
|
||||
op_data.fill_mouse_pos);
|
||||
const float current_dist = math::distance(mouse_pos, op_data.fill_mouse_pos);
|
||||
|
||||
float delta = (current_dist - initial_dist) * pixel_size * 0.5f;
|
||||
op_data.extension_length = std::clamp(op_data.extension_length + delta, 0.0f, 10.0f);
|
||||
|
||||
/* Update cursor line and extend lines. */
|
||||
WM_main_add_notifier(NC_GEOM | ND_DATA, nullptr);
|
||||
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, nullptr);
|
||||
|
||||
grease_pencil_update_extend(*C, op_data);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Process last operations before exiting. */
|
||||
switch (estate) {
|
||||
case OPERATOR_FINISHED:
|
||||
|
||||
Reference in New Issue
Block a user