From fe0e2907b360c1235f8373a92fed6d53a0abe111 Mon Sep 17 00:00:00 2001 From: Falk David Date: Thu, 25 Apr 2024 14:23:46 +0200 Subject: [PATCH] GPv3: Remove `OB_MODE_PAINT_GREASE_PENCIL` flag This reverts part of 36cda3b3116acba3b895daf68689f8af01b62392 and replaces the use of `OB_MODE_PAINT_GREASE_PENCIL` `OB_MODE_PAINT_GPENCIL_LEGACY` flag instead. The `OB_MODE_PAINT_GREASE_PENCIL` is removed. The `GREASE_PENCIL_OT_draw_mode_toggle` operator is removed and the `GPENCIL_OT_paintmode_toggle` operator is adapted to work with GPv3. Pull Request: https://projects.blender.org/blender/blender/pulls/121027 --- scripts/startup/bl_ui/space_view3d.py | 17 ++-- source/blender/blenkernel/BKE_paint.hh | 1 + source/blender/blenkernel/intern/context.cc | 10 ++- source/blender/blenkernel/intern/paint.cc | 16 ++-- .../draw/engines/gpencil/gpencil_engine_c.cc | 8 +- .../editors/gpencil_legacy/gpencil_edit.cc | 84 +++++++++++++----- .../grease_pencil/intern/grease_pencil_ops.cc | 2 +- .../editors/interface/interface_icons.cc | 1 - source/blender/editors/object/object_modes.cc | 20 +++-- .../sculpt_paint/grease_pencil_draw_ops.cc | 86 ------------------- source/blender/makesdna/DNA_object_enums.h | 4 +- source/blender/makesrna/intern/rna_object.cc | 5 -- .../makesrna/intern/rna_sculpt_paint.cc | 7 +- 13 files changed, 102 insertions(+), 159 deletions(-) diff --git a/scripts/startup/bl_ui/space_view3d.py b/scripts/startup/bl_ui/space_view3d.py index 9a70bc4b8e4..571577ab80f 100644 --- a/scripts/startup/bl_ui/space_view3d.py +++ b/scripts/startup/bl_ui/space_view3d.py @@ -725,7 +725,7 @@ class VIEW3D_HT_header(Header): else: if (object_mode not in { 'SCULPT', 'SCULPT_CURVES', 'VERTEX_PAINT', 'WEIGHT_PAINT', 'TEXTURE_PAINT', - 'PAINT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_GPENCIL', 'VERTEX_GPENCIL', 'PAINT_GREASE_PENCIL', + 'PAINT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_GPENCIL', 'VERTEX_GPENCIL', }) or has_pose_mode: show_snap = True else: @@ -870,11 +870,11 @@ class VIEW3D_HT_header(Header): depress=(tool_settings.gpencil_selectmode_edit == 'STROKE'), ).mode = 'STROKE' - if object_mode == 'PAINT_GREASE_PENCIL': + if object_mode == 'PAINT_GPENCIL': row = layout.row(align=True) row.prop(tool_settings, "use_gpencil_draw_additive", text="", icon='FREEZE') - if object_mode in {'PAINT_GREASE_PENCIL', 'EDIT', 'WEIGHT_PAINT'}: + if object_mode in {'PAINT_GPENCIL', 'EDIT', 'WEIGHT_PAINT'}: row = layout.row(align=True) row.prop(tool_settings, "use_grease_pencil_multi_frame_editing", text="") @@ -961,9 +961,9 @@ class VIEW3D_HT_header(Header): layout.separator_spacer() - if object_mode in {'PAINT_GPENCIL', 'SCULPT_GPENCIL', 'PAINT_GREASE_PENCIL'}: + if object_mode in {'PAINT_GPENCIL', 'SCULPT_GPENCIL'}: # Grease pencil - if object_mode in {'PAINT_GPENCIL', 'PAINT_GREASE_PENCIL'}: + if object_mode == 'PAINT_GPENCIL': sub = layout.row(align=True) sub.prop_with_popover( tool_settings, @@ -972,7 +972,7 @@ class VIEW3D_HT_header(Header): panel="VIEW3D_PT_gpencil_origin", ) - if object_mode in {'PAINT_GPENCIL', 'SCULPT_GPENCIL', 'PAINT_GREASE_PENCIL'}: + if object_mode in {'PAINT_GPENCIL', 'SCULPT_GPENCIL'}: sub = layout.row(align=True) sub.active = tool_settings.gpencil_stroke_placement_view3d != 'SURFACE' sub.prop_with_popover( @@ -985,7 +985,8 @@ class VIEW3D_HT_header(Header): if object_mode == 'PAINT_GPENCIL': # FIXME: this is bad practice! # Tool options are to be displayed in the top-bar. - if context.workspace.tools.from_space_view3d_mode(object_mode).idname == "builtin_brush.Draw": + tool = context.workspace.tools.from_space_view3d_mode(object_mode) + if tool and tool.idname == "builtin_brush.Draw": settings = tool_settings.gpencil_sculpt.guide row = layout.row(align=True) row.prop(settings, "use_guide", text="", icon='GRID') @@ -1166,7 +1167,7 @@ class VIEW3D_MT_editor_menus(Menu): obj = context.active_object mode_string = context.mode edit_object = context.edit_object - gp_edit = obj and obj.mode in { + gp_edit = obj and obj.type == 'GPENCIL' and obj.mode in { 'EDIT_GPENCIL', 'PAINT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_GPENCIL', 'VERTEX_GPENCIL', } tool_settings = context.tool_settings diff --git a/source/blender/blenkernel/BKE_paint.hh b/source/blender/blenkernel/BKE_paint.hh index 67e27967692..727a65503f6 100644 --- a/source/blender/blenkernel/BKE_paint.hh +++ b/source/blender/blenkernel/BKE_paint.hh @@ -84,6 +84,7 @@ extern const uchar PAINT_CURSOR_VERTEX_PAINT[3]; extern const uchar PAINT_CURSOR_WEIGHT_PAINT[3]; extern const uchar PAINT_CURSOR_TEXTURE_PAINT[3]; extern const uchar PAINT_CURSOR_SCULPT_CURVES[3]; +extern const uchar PAINT_CURSOR_PAINT_GREASE_PENCIL[3]; extern const uchar PAINT_CURSOR_SCULPT_GREASE_PENCIL[3]; enum class PaintMode : int8_t { diff --git a/source/blender/blenkernel/intern/context.cc b/source/blender/blenkernel/intern/context.cc index 6a4fd110f60..0186d8ed12e 100644 --- a/source/blender/blenkernel/intern/context.cc +++ b/source/blender/blenkernel/intern/context.cc @@ -1183,7 +1183,12 @@ enum eContextObjectMode CTX_data_mode_enum_ex(const Object *obedit, return CTX_MODE_PARTICLE; } if (object_mode & OB_MODE_PAINT_GPENCIL_LEGACY) { - return CTX_MODE_PAINT_GPENCIL_LEGACY; + if (ob->type == OB_GPENCIL_LEGACY) { + return CTX_MODE_PAINT_GPENCIL_LEGACY; + } + if (ob->type == OB_GREASE_PENCIL) { + return CTX_MODE_PAINT_GREASE_PENCIL; + } } if (object_mode & OB_MODE_EDIT_GPENCIL_LEGACY) { return CTX_MODE_EDIT_GPENCIL_LEGACY; @@ -1210,9 +1215,6 @@ enum eContextObjectMode CTX_data_mode_enum_ex(const Object *obedit, if (object_mode & OB_MODE_SCULPT_CURVES) { return CTX_MODE_SCULPT_CURVES; } - if (object_mode & OB_MODE_PAINT_GREASE_PENCIL) { - return CTX_MODE_PAINT_GREASE_PENCIL; - } } } diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc index c3df560a8cd..e5ee9ead6f8 100644 --- a/source/blender/blenkernel/intern/paint.cc +++ b/source/blender/blenkernel/intern/paint.cc @@ -251,6 +251,7 @@ const uchar PAINT_CURSOR_VERTEX_PAINT[3] = {255, 255, 255}; const uchar PAINT_CURSOR_WEIGHT_PAINT[3] = {200, 200, 255}; const uchar PAINT_CURSOR_TEXTURE_PAINT[3] = {255, 255, 255}; const uchar PAINT_CURSOR_SCULPT_CURVES[3] = {255, 100, 100}; +const uchar PAINT_CURSOR_PAINT_GREASE_PENCIL[3] = {255, 100, 100}; const uchar PAINT_CURSOR_SCULPT_GREASE_PENCIL[3] = {255, 100, 100}; static ePaintOverlayControlFlags overlay_flags = (ePaintOverlayControlFlags)0; @@ -532,8 +533,6 @@ Paint *BKE_paint_get_active(Scene *sce, ViewLayer *view_layer) return &ts->gp_weightpaint->paint; case OB_MODE_SCULPT_CURVES: return &ts->curves_sculpt->paint; - case OB_MODE_PAINT_GREASE_PENCIL: - return &ts->gp_paint->paint; case OB_MODE_EDIT: return ts->uvsculpt ? &ts->uvsculpt->paint : nullptr; default: @@ -615,6 +614,8 @@ PaintMode BKE_paintmode_get_active_from_context(const bContext *C) return PaintMode::SculptGreasePencil; } return PaintMode::Invalid; + case OB_MODE_PAINT_GPENCIL_LEGACY: + return PaintMode::GPencil; case OB_MODE_WEIGHT_GPENCIL_LEGACY: return PaintMode::WeightGPencil; case OB_MODE_VERTEX_PAINT: @@ -627,8 +628,6 @@ PaintMode BKE_paintmode_get_active_from_context(const bContext *C) return PaintMode::SculptUV; case OB_MODE_SCULPT_CURVES: return PaintMode::SculptCurves; - case OB_MODE_PAINT_GREASE_PENCIL: - return PaintMode::GPencil; default: return PaintMode::Texture2D; } @@ -728,12 +727,7 @@ void BKE_paint_runtime_init(const ToolSettings *ts, Paint *paint) } else if (ts->gp_paint && paint == &ts->gp_paint->paint) { paint->runtime.tool_offset = offsetof(Brush, gpencil_tool); - if (U.experimental.use_grease_pencil_version3) { - paint->runtime.ob_mode = OB_MODE_PAINT_GREASE_PENCIL; - } - else { - paint->runtime.ob_mode = OB_MODE_PAINT_GPENCIL_LEGACY; - } + paint->runtime.ob_mode = OB_MODE_PAINT_GPENCIL_LEGACY; } else if (ts->gp_vertexpaint && paint == &ts->gp_vertexpaint->paint) { paint->runtime.tool_offset = offsetof(Brush, gpencil_vertex_tool); @@ -1115,7 +1109,7 @@ eObjectMode BKE_paint_object_mode_from_paintmode(const PaintMode mode) case PaintMode::SculptCurves: return OB_MODE_SCULPT_CURVES; case PaintMode::GPencil: - return OB_MODE_PAINT_GREASE_PENCIL; + return OB_MODE_PAINT_GPENCIL_LEGACY; case PaintMode::SculptGreasePencil: return OB_MODE_SCULPT_GPENCIL_LEGACY; case PaintMode::Invalid: diff --git a/source/blender/draw/engines/gpencil/gpencil_engine_c.cc b/source/blender/draw/engines/gpencil/gpencil_engine_c.cc index 1e206ad4766..59ff134c588 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine_c.cc +++ b/source/blender/draw/engines/gpencil/gpencil_engine_c.cc @@ -781,9 +781,11 @@ static GPENCIL_tObject *grease_pencil_object_cache_populate(GPENCIL_PrivateData const VArray stroke_materials = *attributes.lookup_or_default( "material_index", bke::AttrDomain::Curve, 0); - const bool only_lines = - !ELEM(ob->mode, OB_MODE_PAINT_GREASE_PENCIL, OB_MODE_WEIGHT_PAINT, OB_MODE_VERTEX_PAINT) && - info.frame_number != pd->cfra && pd->use_multiedit_lines_only; + const bool only_lines = !ELEM(ob->mode, + OB_MODE_PAINT_GPENCIL_LEGACY, + OB_MODE_WEIGHT_GPENCIL_LEGACY, + OB_MODE_VERTEX_GPENCIL_LEGACY) && + info.frame_number != pd->cfra && pd->use_multiedit_lines_only; const bool is_onion = info.onion_id != 0; visible_strokes.foreach_index([&](const int stroke_i) { diff --git a/source/blender/editors/gpencil_legacy/gpencil_edit.cc b/source/blender/editors/gpencil_legacy/gpencil_edit.cc index d44757f578c..4d24b08a1c6 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_edit.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_edit.cc @@ -339,10 +339,22 @@ static bool gpencil_paintmode_toggle_poll(bContext *C) { /* if using gpencil object, use this gpd */ Object *ob = CTX_data_active_object(C); - if ((ob) && (ob->type == OB_GPENCIL_LEGACY)) { + if ((ob) && (ELEM(ob->type, OB_GPENCIL_LEGACY, OB_GREASE_PENCIL))) { return ob->data != nullptr; } - return ED_gpencil_data_get_active(C) != nullptr; + return false; +} + +static bool gpencil_paint_poll_view3d(bContext *C) +{ + const Object *ob = CTX_data_active_object(C); + if (ob == nullptr || (ob->mode & OB_MODE_PAINT_GPENCIL_LEGACY) == 0) { + return false; + } + if (CTX_wm_region_view3d(C) == nullptr) { + return false; + } + return true; } static int gpencil_paintmode_toggle_exec(bContext *C, wmOperator *op) @@ -351,7 +363,6 @@ static int gpencil_paintmode_toggle_exec(bContext *C, wmOperator *op) wmMsgBus *mbus = CTX_wm_message_bus(C); Main *bmain = CTX_data_main(C); - bGPdata *gpd = ED_gpencil_data_get_active(C); ToolSettings *ts = CTX_data_tool_settings(C); bool is_object = false; @@ -359,28 +370,48 @@ static int gpencil_paintmode_toggle_exec(bContext *C, wmOperator *op) /* if using a gpencil object, use this datablock */ Object *ob = CTX_data_active_object(C); if ((ob) && (ob->type == OB_GPENCIL_LEGACY)) { - gpd = static_cast(ob->data); + bGPdata *gpd = static_cast(ob->data); + if (gpd == nullptr) { + return OPERATOR_CANCELLED; + } + /* Just toggle paintmode flag... */ + gpd->flag ^= GP_DATA_STROKE_PAINTMODE; + /* set mode */ + if (gpd->flag & GP_DATA_STROKE_PAINTMODE) { + mode = OB_MODE_PAINT_GPENCIL_LEGACY; + } + else { + mode = OB_MODE_OBJECT; + } is_object = true; } - - if (gpd == nullptr) { - return OPERATOR_CANCELLED; - } - - /* Just toggle paintmode flag... */ - gpd->flag ^= GP_DATA_STROKE_PAINTMODE; - /* set mode */ - if (gpd->flag & GP_DATA_STROKE_PAINTMODE) { - mode = OB_MODE_PAINT_GPENCIL_LEGACY; - } - else { - mode = OB_MODE_OBJECT; + if ((ob) && (ob->type == OB_GREASE_PENCIL)) { + const bool is_mode_set = (ob->mode & OB_MODE_PAINT_GPENCIL_LEGACY) != 0; + if (!is_mode_set) { + Scene *scene = CTX_data_scene(C); + BKE_paint_init(bmain, scene, PaintMode::GPencil, PAINT_CURSOR_PAINT_GREASE_PENCIL); + Paint *paint = BKE_paint_get_active_from_paintmode(scene, PaintMode::GPencil); + ED_paint_cursor_start(paint, gpencil_paint_poll_view3d); + mode = OB_MODE_PAINT_GPENCIL_LEGACY; + } + else { + mode = OB_MODE_OBJECT; + } + is_object = true; } if (is_object) { /* try to back previous mode */ - if ((ob->restore_mode) && ((gpd->flag & GP_DATA_STROKE_PAINTMODE) == 0) && (back == 1)) { - mode = ob->restore_mode; + if (ob->type == OB_GPENCIL_LEGACY) { + bGPdata *gpd = static_cast(ob->data); + if ((ob->restore_mode) && ((gpd->flag & GP_DATA_STROKE_PAINTMODE) == 0) && (back == 1)) { + mode = ob->restore_mode; + } + } + if (ob->type == OB_GREASE_PENCIL) { + if ((ob->restore_mode) && ((ob->mode & OB_MODE_PAINT_GPENCIL_LEGACY) == 0) && (back == 1)) { + mode = ob->restore_mode; + } } ob->restore_mode = ob->mode; ob->mode = mode; @@ -406,10 +437,17 @@ static int gpencil_paintmode_toggle_exec(bContext *C, wmOperator *op) BKE_paint_toolslots_brush_validate(bmain, &ts->gp_paint->paint); } - /* setup other modes */ - ED_gpencil_setup_modes(C, gpd, mode); - /* set cache as dirty */ - DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); + if (ob->type == OB_GPENCIL_LEGACY) { + bGPdata *gpd = static_cast(ob->data); + /* setup other modes */ + ED_gpencil_setup_modes(C, gpd, mode); + /* set cache as dirty */ + DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); + } + if (ob->type == OB_GREASE_PENCIL) { + GreasePencil *grease_pencil = static_cast(ob->data); + DEG_id_tag_update(&grease_pencil->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); + } WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | ND_GPENCIL_EDITMODE, nullptr); WM_event_add_notifier(C, NC_SCENE | ND_MODE, nullptr); diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_ops.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_ops.cc index 13cc00eff43..b5895192197 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_ops.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_ops.cc @@ -72,7 +72,7 @@ bool grease_pencil_painting_poll(bContext *C) return false; } Object *object = CTX_data_active_object(C); - if ((object->mode & OB_MODE_PAINT_GREASE_PENCIL) == 0) { + if ((object->mode & OB_MODE_PAINT_GPENCIL_LEGACY) == 0) { return false; } ToolSettings *ts = CTX_data_tool_settings(C); diff --git a/source/blender/editors/interface/interface_icons.cc b/source/blender/editors/interface/interface_icons.cc index c0539777410..fc6112d42eb 100644 --- a/source/blender/editors/interface/interface_icons.cc +++ b/source/blender/editors/interface/interface_icons.cc @@ -2624,7 +2624,6 @@ int UI_icon_from_object_mode(const int mode) return ICON_PARTICLEMODE; case OB_MODE_POSE: return ICON_POSE_HLT; - case OB_MODE_PAINT_GREASE_PENCIL: case OB_MODE_PAINT_GPENCIL_LEGACY: return ICON_GREASEPENCIL; } diff --git a/source/blender/editors/object/object_modes.cc b/source/blender/editors/object/object_modes.cc index ce526439a14..9ba510549fc 100644 --- a/source/blender/editors/object/object_modes.cc +++ b/source/blender/editors/object/object_modes.cc @@ -82,9 +82,6 @@ static const char *object_mode_op_string(eObjectMode mode) if (mode == OB_MODE_EDIT_GPENCIL_LEGACY) { return "GPENCIL_OT_editmode_toggle"; } - if (mode == OB_MODE_PAINT_GREASE_PENCIL) { - return "GREASE_PENCIL_OT_draw_mode_toggle"; - } if (mode == OB_MODE_PAINT_GPENCIL_LEGACY) { return "GPENCIL_OT_paintmode_toggle"; } @@ -148,7 +145,7 @@ bool mode_compat_test(const Object *ob, eObjectMode mode) } break; case OB_GREASE_PENCIL: - if (mode & (OB_MODE_EDIT | OB_MODE_PAINT_GREASE_PENCIL | OB_MODE_SCULPT_GPENCIL_LEGACY | + if (mode & (OB_MODE_EDIT | OB_MODE_PAINT_GPENCIL_LEGACY | OB_MODE_SCULPT_GPENCIL_LEGACY | OB_MODE_WEIGHT_GPENCIL_LEGACY)) { return true; @@ -307,10 +304,17 @@ static bool ed_object_mode_generic_exit_ex( } ED_object_gpencil_exit(bmain, ob); } - else if (ob->mode & OB_MODE_PAINT_GREASE_PENCIL) { - ob->mode &= ~OB_MODE_PAINT_GREASE_PENCIL; - DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_SYNC_TO_EVAL); - WM_main_add_notifier(NC_SCENE | ND_MODE | NS_MODE_OBJECT, nullptr); + else if (ob->type == OB_GREASE_PENCIL) { + BLI_assert((ob->mode & OB_MODE_OBJECT) == 0); + if (only_test) { + return true; + } + ob->restore_mode = ob->mode; + ob->mode &= ~(OB_MODE_PAINT_GPENCIL_LEGACY | OB_MODE_EDIT | OB_MODE_SCULPT_GPENCIL_LEGACY | + OB_MODE_WEIGHT_GPENCIL_LEGACY | OB_MODE_VERTEX_GPENCIL_LEGACY); + + /* Inform all evaluated versions that we changed the mode. */ + DEG_id_tag_update_ex(bmain, &ob->id, ID_RECALC_SYNC_TO_EVAL); } else { if (only_test) { diff --git a/source/blender/editors/sculpt_paint/grease_pencil_draw_ops.cc b/source/blender/editors/sculpt_paint/grease_pencil_draw_ops.cc index cabbec6ccf7..2d001bb5363 100644 --- a/source/blender/editors/sculpt_paint/grease_pencil_draw_ops.cc +++ b/source/blender/editors/sculpt_paint/grease_pencil_draw_ops.cc @@ -325,91 +325,6 @@ static void GREASE_PENCIL_OT_sculpt_paint(wmOperatorType *ot) /** \} */ -/* -------------------------------------------------------------------- */ -/** \name Toggle Draw Mode - * \{ */ - -static bool grease_pencil_mode_poll_paint_cursor(bContext *C) -{ - if (!grease_pencil_brush_stroke_poll(C)) { - return false; - } - if (CTX_wm_region_view3d(C) == nullptr) { - return false; - } - return true; -} - -static void grease_pencil_draw_mode_enter(bContext *C) -{ - Scene *scene = CTX_data_scene(C); - wmMsgBus *mbus = CTX_wm_message_bus(C); - - Object *ob = CTX_data_active_object(C); - GpPaint *grease_pencil_paint = scene->toolsettings->gp_paint; - BKE_paint_ensure(scene->toolsettings, (Paint **)&grease_pencil_paint); - - ob->mode = OB_MODE_PAINT_GREASE_PENCIL; - - /* TODO: Setup cursor color. BKE_paint_init() could be used, but creates an additional brush. */ - ED_paint_cursor_start(&grease_pencil_paint->paint, grease_pencil_mode_poll_paint_cursor); - paint_init_pivot(ob, scene); - - /* Necessary to change the object mode on the evaluated object. */ - DEG_id_tag_update(&ob->id, ID_RECALC_SYNC_TO_EVAL); - WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode); - WM_event_add_notifier(C, NC_SCENE | ND_MODE, nullptr); -} - -static void grease_pencil_draw_mode_exit(bContext *C) -{ - Object *ob = CTX_data_active_object(C); - ob->mode = OB_MODE_OBJECT; -} - -static int grease_pencil_draw_mode_toggle_exec(bContext *C, wmOperator *op) -{ - Object *ob = CTX_data_active_object(C); - wmMsgBus *mbus = CTX_wm_message_bus(C); - - const bool is_mode_set = ob->mode == OB_MODE_PAINT_GREASE_PENCIL; - - if (is_mode_set) { - if (!object::mode_compat_set(C, ob, OB_MODE_PAINT_GREASE_PENCIL, op->reports)) { - return OPERATOR_CANCELLED; - } - } - - if (is_mode_set) { - grease_pencil_draw_mode_exit(C); - } - else { - grease_pencil_draw_mode_enter(C); - } - - WM_toolsystem_update_from_context_view3d(C); - - /* Necessary to change the object mode on the evaluated object. */ - DEG_id_tag_update(&ob->id, ID_RECALC_SYNC_TO_EVAL); - WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode); - WM_event_add_notifier(C, NC_SCENE | ND_MODE, nullptr); - return OPERATOR_FINISHED; -} - -static void GREASE_PENCIL_OT_draw_mode_toggle(wmOperatorType *ot) -{ - ot->name = "Grease Pencil Draw Mode Toggle"; - ot->idname = "GREASE_PENCIL_OT_draw_mode_toggle"; - ot->description = "Enter/Exit draw mode for grease pencil"; - - ot->exec = grease_pencil_draw_mode_toggle_exec; - ot->poll = ed::greasepencil::active_grease_pencil_poll; - - ot->flag = OPTYPE_UNDO | OPTYPE_REGISTER; -} - -/** \} */ - } // namespace blender::ed::sculpt_paint /* -------------------------------------------------------------------- */ @@ -421,7 +336,6 @@ void ED_operatortypes_grease_pencil_draw() using namespace blender::ed::sculpt_paint; WM_operatortype_append(GREASE_PENCIL_OT_brush_stroke); WM_operatortype_append(GREASE_PENCIL_OT_sculpt_paint); - WM_operatortype_append(GREASE_PENCIL_OT_draw_mode_toggle); } /** \} */ diff --git a/source/blender/makesdna/DNA_object_enums.h b/source/blender/makesdna/DNA_object_enums.h index 1418a2c2747..0984bf1579e 100644 --- a/source/blender/makesdna/DNA_object_enums.h +++ b/source/blender/makesdna/DNA_object_enums.h @@ -26,7 +26,6 @@ typedef enum eObjectMode { OB_MODE_WEIGHT_GPENCIL_LEGACY = 1 << 10, OB_MODE_VERTEX_GPENCIL_LEGACY = 1 << 11, OB_MODE_SCULPT_CURVES = 1 << 12, - OB_MODE_PAINT_GREASE_PENCIL = 1 << 13, } eObjectMode; /** #Object.dt, #View3DShading.type */ @@ -60,5 +59,4 @@ typedef enum eDrawType { #define OB_MODE_ALL_MODE_DATA \ (OB_MODE_EDIT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_SCULPT | OB_MODE_POSE | \ OB_MODE_PAINT_GPENCIL_LEGACY | OB_MODE_EDIT_GPENCIL_LEGACY | OB_MODE_SCULPT_GPENCIL_LEGACY | \ - OB_MODE_WEIGHT_GPENCIL_LEGACY | OB_MODE_VERTEX_GPENCIL_LEGACY | OB_MODE_SCULPT_CURVES | \ - OB_MODE_PAINT_GREASE_PENCIL) + OB_MODE_WEIGHT_GPENCIL_LEGACY | OB_MODE_VERTEX_GPENCIL_LEGACY | OB_MODE_SCULPT_CURVES) diff --git a/source/blender/makesrna/intern/rna_object.cc b/source/blender/makesrna/intern/rna_object.cc index dfd92b6432c..208673c3f3f 100644 --- a/source/blender/makesrna/intern/rna_object.cc +++ b/source/blender/makesrna/intern/rna_object.cc @@ -89,11 +89,6 @@ const EnumPropertyItem rna_enum_object_mode_items[] = { "Vertex Paint", "Grease Pencil Vertex Paint Strokes"}, {OB_MODE_SCULPT_CURVES, "SCULPT_CURVES", ICON_SCULPTMODE_HLT, "Sculpt Mode", ""}, - {OB_MODE_PAINT_GREASE_PENCIL, - "PAINT_GREASE_PENCIL", - ICON_GREASEPENCIL, - "Draw Mode", - "Paint Grease Pencil Strokes"}, {0, nullptr, 0, nullptr, nullptr}, }; diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.cc b/source/blender/makesrna/intern/rna_sculpt_paint.cc index a4f4c407266..8ca9258118f 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.cc +++ b/source/blender/makesrna/intern/rna_sculpt_paint.cc @@ -345,12 +345,7 @@ static bool rna_Brush_mode_with_tool_poll(PointerRNA *ptr, PointerRNA value) if (slot_index != brush->gpencil_tool) { return false; } - if (U.experimental.use_grease_pencil_version3) { - mode = OB_MODE_PAINT_GREASE_PENCIL; - } - else { - mode = OB_MODE_PAINT_GPENCIL_LEGACY; - } + mode = OB_MODE_PAINT_GPENCIL_LEGACY; } else if (paint_contains_brush_slot(&ts->gp_vertexpaint->paint, tslot, &slot_index)) { if (slot_index != brush->gpencil_vertex_tool) {