diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_select.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_select.cc index b6bb9acc30e..fd24870fa23 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_select.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_select.cc @@ -1097,6 +1097,17 @@ blender::bke::AttrDomain ED_grease_pencil_selection_domain_get(const ToolSetting return blender::bke::AttrDomain::Point; } +bool ED_grease_pencil_any_vertex_mask_selection(const ToolSettings *tool_settings) +{ + const int selectmode = tool_settings->gpencil_selectmode_vertex; + if (selectmode & (GP_VERTEX_MASK_SELECTMODE_POINT | GP_VERTEX_MASK_SELECTMODE_STROKE | + GP_VERTEX_MASK_SELECTMODE_SEGMENT)) + { + return true; + } + return false; +} + bool ED_grease_pencil_edit_segment_selection_enabled(const ToolSettings *tool_settings) { return tool_settings->gpencil_selectmode_edit == GP_SELECTMODE_SEGMENT; diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_vertex_paint.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_vertex_paint.cc index 0c766c46210..23600a70759 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_vertex_paint.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_vertex_paint.cc @@ -20,8 +20,6 @@ #include "ED_curves.hh" #include "ED_grease_pencil.hh" -#include "DNA_gpencil_legacy_types.h" - namespace blender::ed::greasepencil { enum class VertexColorMode : int8_t { @@ -98,8 +96,7 @@ static wmOperatorStatus grease_pencil_vertex_paint_brightness_contrast_exec(bCon const float brightness = RNA_float_get(op->ptr, "brightness"); const float contrast = RNA_float_get(op->ptr, "contrast"); float delta = contrast / 2.0f; - const bool use_selection_mask = GPENCIL_ANY_VERTEX_MASK( - eGP_vertex_SelectMaskFlag(scene.toolsettings->gpencil_selectmode_vertex)); + const bool use_selection_mask = ED_grease_pencil_any_vertex_mask_selection(scene.toolsettings); /* * The algorithm is by Werner D. Streidt @@ -175,8 +172,7 @@ static wmOperatorStatus grease_pencil_vertex_paint_hsv_exec(bContext *C, wmOpera const float hue = RNA_float_get(op->ptr, "h"); const float sat = RNA_float_get(op->ptr, "s"); const float val = RNA_float_get(op->ptr, "v"); - const bool use_selection_mask = GPENCIL_ANY_VERTEX_MASK( - eGP_vertex_SelectMaskFlag(scene.toolsettings->gpencil_selectmode_vertex)); + const bool use_selection_mask = ED_grease_pencil_any_vertex_mask_selection(scene.toolsettings); std::atomic any_changed; Vector drawings = retrieve_editable_drawings(scene, grease_pencil); @@ -246,8 +242,7 @@ static wmOperatorStatus grease_pencil_vertex_paint_invert_exec(bContext *C, wmOp Object &object = *CTX_data_active_object(C); GreasePencil &grease_pencil = *static_cast(object.data); const VertexColorMode mode = VertexColorMode(RNA_enum_get(op->ptr, "mode")); - const bool use_selection_mask = GPENCIL_ANY_VERTEX_MASK( - eGP_vertex_SelectMaskFlag(scene.toolsettings->gpencil_selectmode_vertex)); + const bool use_selection_mask = ED_grease_pencil_any_vertex_mask_selection(scene.toolsettings); std::atomic any_changed; Vector drawings = retrieve_editable_drawings(scene, grease_pencil); @@ -302,8 +297,7 @@ static wmOperatorStatus grease_pencil_vertex_paint_levels_exec(bContext *C, wmOp const VertexColorMode mode = VertexColorMode(RNA_enum_get(op->ptr, "mode")); const float gain = RNA_float_get(op->ptr, "gain"); const float offset = RNA_float_get(op->ptr, "offset"); - const bool use_selection_mask = GPENCIL_ANY_VERTEX_MASK( - eGP_vertex_SelectMaskFlag(scene.toolsettings->gpencil_selectmode_vertex)); + const bool use_selection_mask = ED_grease_pencil_any_vertex_mask_selection(scene.toolsettings); std::atomic any_changed; Vector drawings = retrieve_editable_drawings(scene, grease_pencil); @@ -364,8 +358,7 @@ static wmOperatorStatus grease_pencil_vertex_paint_set_exec(bContext *C, wmOpera GreasePencil &grease_pencil = *static_cast(object.data); const VertexColorMode mode = VertexColorMode(RNA_enum_get(op->ptr, "mode")); const float factor = RNA_float_get(op->ptr, "factor"); - const bool use_selection_mask = GPENCIL_ANY_VERTEX_MASK( - eGP_vertex_SelectMaskFlag(scene.toolsettings->gpencil_selectmode_vertex)); + const bool use_selection_mask = ED_grease_pencil_any_vertex_mask_selection(scene.toolsettings); float3 color_linear; srgb_to_linearrgb_v3_v3(color_linear, BKE_brush_color_get(&paint, &brush)); @@ -432,8 +425,7 @@ static wmOperatorStatus grease_pencil_vertex_paint_reset_exec(bContext *C, wmOpe Object &object = *CTX_data_active_object(C); GreasePencil &grease_pencil = *static_cast(object.data); const VertexColorMode mode = VertexColorMode(RNA_enum_get(op->ptr, "mode")); - const bool use_selection_mask = GPENCIL_ANY_VERTEX_MASK( - eGP_vertex_SelectMaskFlag(scene.toolsettings->gpencil_selectmode_vertex)); + const bool use_selection_mask = ED_grease_pencil_any_vertex_mask_selection(scene.toolsettings); std::atomic any_changed; Vector drawings = retrieve_editable_drawings(scene, grease_pencil); diff --git a/source/blender/editors/include/ED_grease_pencil.hh b/source/blender/editors/include/ED_grease_pencil.hh index 91b2f042b77..ebe636f7abc 100644 --- a/source/blender/editors/include/ED_grease_pencil.hh +++ b/source/blender/editors/include/ED_grease_pencil.hh @@ -100,6 +100,11 @@ blender::bke::AttrDomain ED_grease_pencil_vertex_selection_domain_get( const ToolSettings *tool_settings); blender::bke::AttrDomain ED_grease_pencil_selection_domain_get(const ToolSettings *tool_settings, const Object *object); +/** + * True if any vertex mask selection is used. + */ +bool ED_grease_pencil_any_vertex_mask_selection(const ToolSettings *tool_settings); + /** * True if segment selection is enabled. */ diff --git a/source/blender/editors/sculpt_paint/grease_pencil_vertex_average.cc b/source/blender/editors/sculpt_paint/grease_pencil_vertex_average.cc index 69a8d70c4af..69b0c3f64b2 100644 --- a/source/blender/editors/sculpt_paint/grease_pencil_vertex_average.cc +++ b/source/blender/editors/sculpt_paint/grease_pencil_vertex_average.cc @@ -2,8 +2,6 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include "DNA_gpencil_legacy_types.h" - #include "BKE_brush.hh" #include "BKE_context.hh" #include "BKE_curves.hh" @@ -38,8 +36,8 @@ void VertexAverageOperation::on_stroke_extended(const bContext &C, const float radius = brush_radius(paint, brush, extension_sample.pressure); const float radius_squared = radius * radius; - const bool use_selection_masking = GPENCIL_ANY_VERTEX_MASK( - eGP_vertex_SelectMaskFlag(scene.toolsettings->gpencil_selectmode_vertex)); + const bool use_selection_masking = ED_grease_pencil_any_vertex_mask_selection( + scene.toolsettings); const bool do_points = do_vertex_color_points(brush); const bool do_fill = do_vertex_color_fill(brush); diff --git a/source/blender/editors/sculpt_paint/grease_pencil_vertex_blur.cc b/source/blender/editors/sculpt_paint/grease_pencil_vertex_blur.cc index 669542806d0..4de9ec22048 100644 --- a/source/blender/editors/sculpt_paint/grease_pencil_vertex_blur.cc +++ b/source/blender/editors/sculpt_paint/grease_pencil_vertex_blur.cc @@ -2,8 +2,6 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include "DNA_gpencil_legacy_types.h" - #include "BKE_brush.hh" #include "BKE_context.hh" #include "BKE_curves.hh" @@ -38,8 +36,8 @@ void VertexBlurOperation::on_stroke_extended(const bContext &C, const float radius = brush_radius(paint, brush, extension_sample.pressure); const float radius_squared = radius * radius; - const bool use_selection_masking = GPENCIL_ANY_VERTEX_MASK( - eGP_vertex_SelectMaskFlag(scene.toolsettings->gpencil_selectmode_vertex)); + const bool use_selection_masking = ED_grease_pencil_any_vertex_mask_selection( + scene.toolsettings); this->foreach_editable_drawing(C, GrainSize(1), [&](const GreasePencilStrokeParams ¶ms) { IndexMaskMemory memory; diff --git a/source/blender/editors/sculpt_paint/grease_pencil_vertex_paint.cc b/source/blender/editors/sculpt_paint/grease_pencil_vertex_paint.cc index 5ed2f03235f..a27bf8f09c9 100644 --- a/source/blender/editors/sculpt_paint/grease_pencil_vertex_paint.cc +++ b/source/blender/editors/sculpt_paint/grease_pencil_vertex_paint.cc @@ -4,8 +4,6 @@ #include "BLI_math_color.hh" -#include "DNA_gpencil_legacy_types.h" - #include "BKE_brush.hh" #include "BKE_context.hh" #include "BKE_curves.hh" @@ -39,8 +37,8 @@ void VertexPaintOperation::on_stroke_extended(const bContext &C, const Brush &brush = *BKE_paint_brush(&paint); const bool invert = this->is_inverted(brush); - const bool use_selection_masking = GPENCIL_ANY_VERTEX_MASK( - eGP_vertex_SelectMaskFlag(scene.toolsettings->gpencil_selectmode_vertex)); + const bool use_selection_masking = ED_grease_pencil_any_vertex_mask_selection( + scene.toolsettings); const bool do_points = do_vertex_color_points(brush); const bool do_fill = do_vertex_color_fill(brush); diff --git a/source/blender/editors/sculpt_paint/grease_pencil_vertex_replace.cc b/source/blender/editors/sculpt_paint/grease_pencil_vertex_replace.cc index 737ad87ab97..2573f9da3aa 100644 --- a/source/blender/editors/sculpt_paint/grease_pencil_vertex_replace.cc +++ b/source/blender/editors/sculpt_paint/grease_pencil_vertex_replace.cc @@ -2,8 +2,6 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include "DNA_gpencil_legacy_types.h" - #include "BKE_brush.hh" #include "BKE_context.hh" #include "BKE_curves.hh" @@ -36,8 +34,8 @@ void VertexReplaceOperation::on_stroke_extended(const bContext &C, Paint &paint = *BKE_paint_get_active_from_context(&C); const Brush &brush = *BKE_paint_brush(&paint); - const bool use_selection_masking = GPENCIL_ANY_VERTEX_MASK( - eGP_vertex_SelectMaskFlag(scene.toolsettings->gpencil_selectmode_vertex)); + const bool use_selection_masking = ED_grease_pencil_any_vertex_mask_selection( + scene.toolsettings); const bool do_points = do_vertex_color_points(brush); const bool do_fill = do_vertex_color_fill(brush); diff --git a/source/blender/editors/sculpt_paint/grease_pencil_vertex_smear.cc b/source/blender/editors/sculpt_paint/grease_pencil_vertex_smear.cc index 263158948ae..cdf2a07357e 100644 --- a/source/blender/editors/sculpt_paint/grease_pencil_vertex_smear.cc +++ b/source/blender/editors/sculpt_paint/grease_pencil_vertex_smear.cc @@ -2,8 +2,6 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include "DNA_gpencil_legacy_types.h" - #include "BKE_context.hh" #include "BKE_grease_pencil.hh" #include "BKE_paint.hh" @@ -71,8 +69,8 @@ void VertexSmearOperation::init_color_grid(const bContext &C, const float2 start const Scene &scene = *CTX_data_scene(&C); Paint &paint = *BKE_paint_get_active_from_context(&C); const Brush &brush = *BKE_paint_brush(&paint); - const bool use_selection_masking = GPENCIL_ANY_VERTEX_MASK( - eGP_vertex_SelectMaskFlag(scene.toolsettings->gpencil_selectmode_vertex)); + const bool use_selection_masking = ED_grease_pencil_any_vertex_mask_selection( + scene.toolsettings); const float radius = brush_radius(paint, brush, 1.0f); /* Setup grid values. */ @@ -155,8 +153,8 @@ void VertexSmearOperation::on_stroke_extended(const bContext &C, const Brush &brush = *BKE_paint_brush(&paint); const float radius = brush_radius(paint, brush, extension_sample.pressure); - const bool use_selection_masking = GPENCIL_ANY_VERTEX_MASK( - eGP_vertex_SelectMaskFlag(scene.toolsettings->gpencil_selectmode_vertex)); + const bool use_selection_masking = ED_grease_pencil_any_vertex_mask_selection( + scene.toolsettings); this->foreach_editable_drawing(C, GrainSize(1), [&](const GreasePencilStrokeParams ¶ms) { IndexMaskMemory memory; diff --git a/source/blender/makesdna/DNA_gpencil_legacy_types.h b/source/blender/makesdna/DNA_gpencil_legacy_types.h index 984b049df78..657604adf45 100644 --- a/source/blender/makesdna/DNA_gpencil_legacy_types.h +++ b/source/blender/makesdna/DNA_gpencil_legacy_types.h @@ -800,10 +800,3 @@ typedef enum eGP_DrawMode { GP_DRAWMODE_2D = 0, GP_DRAWMODE_3D = 1, } eGP_DrawMode; - -/* ***************************************** */ -/* Mode Checking Macros */ - -#define GPENCIL_ANY_VERTEX_MASK(flag) \ - ((flag & (GP_VERTEX_MASK_SELECTMODE_POINT | GP_VERTEX_MASK_SELECTMODE_STROKE | \ - GP_VERTEX_MASK_SELECTMODE_SEGMENT)))