Cleanup: Remove GPENCIL_ANY_VERTEX_MASK macro

This replaces the `GPENCIL_ANY_VERTEX_MASK` legacy macro
with a function that is used in the Grease Pencil code.

Also removes some includes of legacy headers.
This commit is contained in:
Falk David
2025-07-17 16:18:59 +02:00
parent c5642fc3c6
commit 7d15b346d1
9 changed files with 34 additions and 43 deletions

View File

@@ -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;

View File

@@ -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<bool> any_changed;
Vector<MutableDrawingInfo> 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<GreasePencil *>(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<bool> any_changed;
Vector<MutableDrawingInfo> 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<bool> any_changed;
Vector<MutableDrawingInfo> 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<GreasePencil *>(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<GreasePencil *>(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<bool> any_changed;
Vector<MutableDrawingInfo> drawings = retrieve_editable_drawings(scene, grease_pencil);

View File

@@ -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.
*/

View File

@@ -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);

View File

@@ -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 &params) {
IndexMaskMemory memory;

View File

@@ -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);

View File

@@ -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);

View File

@@ -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 &params) {
IndexMaskMemory memory;

View File

@@ -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)))