GPencil: Several Weight Paint additions #106663

Merged
Falk David merged 11 commits from SietseB/blender:gp-weight-paint-additions into main 2023-04-20 07:55:37 +02:00
23 changed files with 1324 additions and 193 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -204,6 +204,9 @@ _km_hierarchy = [
('Grease Pencil Stroke Sculpt (Clone)', 'EMPTY', 'WINDOW', []),
('Grease Pencil Stroke Weight Mode', 'EMPTY', 'WINDOW', []),
('Grease Pencil Stroke Weight (Draw)', 'EMPTY', 'WINDOW', []),
('Grease Pencil Stroke Weight (Blur)', 'EMPTY', 'WINDOW', []),
('Grease Pencil Stroke Weight (Average)', 'EMPTY', 'WINDOW', []),
('Grease Pencil Stroke Weight (Smear)', 'EMPTY', 'WINDOW', []),
('Grease Pencil Stroke Vertex Mode', 'EMPTY', 'WINDOW', []),
('Grease Pencil Stroke Vertex (Draw)', 'EMPTY', 'WINDOW', []),
('Grease Pencil Stroke Vertex (Blur)', 'EMPTY', 'WINDOW', []),

View File

@ -4178,6 +4178,9 @@ def km_grease_pencil_stroke_weight_mode(params):
# Brush size
("wm.radial_control", {"type": 'F', "value": 'PRESS'},
{"properties": [("data_path_primary", 'tool_settings.gpencil_weight_paint.brush.size')]}),
# Brush weight
("wm.radial_control", {"type": 'F', "value": 'PRESS', "ctrl": True},
{"properties": [("data_path_primary", 'tool_settings.gpencil_weight_paint.brush.weight')]}),
# Increase/Decrease brush size
("brush.scale_size", {"type": 'LEFT_BRACKET', "value": 'PRESS', "repeat": True},
{"properties": [("scalar", 0.9)]}),
@ -4197,6 +4200,10 @@ def km_grease_pencil_stroke_weight_mode(params):
op_menu("VIEW3D_MT_gpencil_animation", {"type": 'I', "value": 'PRESS'}),
# Context menu
*_template_items_context_panel("VIEW3D_PT_gpencil_weight_context_menu", params.context_menu_event),
# Toggle Add/Subtract for weight draw tool
("gpencil.weight_toggle_direction", {"type": 'D', "value": 'PRESS'}, None),
# Weight sample
("gpencil.weight_sample", {"type": params.action_mouse, "value": 'PRESS', "ctrl": True}, None),
])
if params.select_mouse == 'LEFTMOUSE':
@ -4220,6 +4227,59 @@ def km_grease_pencil_stroke_weight_draw(_params):
# Draw
("gpencil.weight_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
{"properties": [("wait_for_input", False)]}),
("gpencil.weight_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
{"properties": [("wait_for_input", False)]}),
])
return keymap
def km_grease_pencil_stroke_weight_blur(_params):
items = []
keymap = (
"Grease Pencil Stroke Weight (Blur)",
{"space_type": 'EMPTY', "region_type": 'WINDOW'},
{"items": items},
)
items.extend([
# Blur
("gpencil.weight_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
{"properties": [("wait_for_input", False)]}),
])
return keymap
def km_grease_pencil_stroke_weight_average(_params):
items = []
keymap = (
"Grease Pencil Stroke Weight (Average)",
{"space_type": 'EMPTY', "region_type": 'WINDOW'},
{"items": items},
)
items.extend([
# Average
("gpencil.weight_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
{"properties": [("wait_for_input", False)]}),
])
return keymap
def km_grease_pencil_stroke_weight_smear(_params):
items = []
keymap = (
"Grease Pencil Stroke Weight (Smear)",
{"space_type": 'EMPTY', "region_type": 'WINDOW'},
{"items": items},
)
items.extend([
# Smear
("gpencil.weight_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
{"properties": [("wait_for_input", False)]}),
])
return keymap
@ -8115,6 +8175,9 @@ def generate_keymaps(params=None):
km_grease_pencil_stroke_sculpt_clone(params),
km_grease_pencil_stroke_weight_mode(params),
km_grease_pencil_stroke_weight_draw(params),
km_grease_pencil_stroke_weight_blur(params),
km_grease_pencil_stroke_weight_average(params),
km_grease_pencil_stroke_weight_smear(params),
km_grease_pencil_stroke_vertex_mode(params),
km_grease_pencil_stroke_vertex_draw(params),
km_grease_pencil_stroke_vertex_blur(params),

View File

@ -2777,6 +2777,56 @@ def km_grease_pencil_stroke_weight_draw(_params):
{"items": items},
)
items.extend([
("gpencil.weight_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
{"properties": [("wait_for_input", False)]}),
("gpencil.weight_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
{"properties": [("wait_for_input", False)]}),
])
return keymap
def km_grease_pencil_stroke_weight_blur(_params):
items = []
keymap = (
"Grease Pencil Stroke Weight (Blur)",
{"space_type": 'EMPTY', "region_type": 'WINDOW'},
{"items": items},
)
items.extend([
("gpencil.weight_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
{"properties": [("wait_for_input", False)]}),
])
return keymap
def km_grease_pencil_stroke_weight_average(_params):
items = []
keymap = (
"Grease Pencil Stroke Weight (Average)",
{"space_type": 'EMPTY', "region_type": 'WINDOW'},
{"items": items},
)
items.extend([
("gpencil.weight_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
{"properties": [("wait_for_input", False)]}),
])
return keymap
def km_grease_pencil_stroke_weight_smear(_params):
items = []
keymap = (
"Grease Pencil Stroke Weight (Smear)",
{"space_type": 'EMPTY', "region_type": 'WINDOW'},
{"items": items},
)
items.extend([
("gpencil.weight_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
{"properties": [("wait_for_input", False)]}),
@ -4195,6 +4245,9 @@ def generate_keymaps_impl(params=None):
km_grease_pencil_stroke_sculpt_clone(params),
km_grease_pencil_stroke_weight_mode(params),
km_grease_pencil_stroke_weight_draw(params),
km_grease_pencil_stroke_weight_blur(params),
km_grease_pencil_stroke_weight_average(params),
km_grease_pencil_stroke_weight_smear(params),
km_grease_pencil_stroke_vertex_mode(params),
km_grease_pencil_stroke_vertex_draw(params),
km_grease_pencil_stroke_vertex_blur(params),

View File

@ -1414,8 +1414,12 @@ def brush_basic_gpencil_weight_settings(layout, _context, brush, *, compact=Fals
row = layout.row(align=True)
row.prop(brush, "strength", slider=True)
row.prop(brush, "use_pressure_strength", text="")
layout.prop(brush, "weight", slider=True)
if brush.gpencil_weight_tool in {'WEIGHT'}:
layout.prop(brush, "weight", slider=True)
gp_settings = brush.gpencil_settings
filedescriptor marked this conversation as resolved
Review

I think in this case it's nicer to inline the if compact else.
layout.prop(gp_settings, "direction", expand=True, text="" if compact else "Direction")

I think in this case it's nicer to inline the `if compact else`. `layout.prop(gp_settings, "direction", expand=True, text="" if compact else "Direction")`
layout.prop(gp_settings, "direction", expand=True, text="" if compact else "Direction")
def brush_basic_gpencil_vertex_settings(layout, _context, brush, *, compact=False):

View File

@ -68,6 +68,7 @@ def generate_from_enum_ex(
dict(
idname=idname_prefix + name,
label=name,
description=enum.description,
icon=icon,
cursor=cursor,
data_block=idname,

View File

@ -8,6 +8,7 @@ from bpy.types import (
from bl_ui.properties_paint_common import (
UnifiedPaintPanel,
brush_basic_texpaint_settings,
brush_basic_gpencil_weight_settings,
)
from bl_ui.properties_grease_pencil_common import (
AnnotationDataPanel,
@ -413,11 +414,13 @@ class _draw_tool_settings_context_mode:
return False
paint = context.tool_settings.gpencil_weight_paint
brush = paint.brush
from bl_ui.properties_paint_common import (
brush_basic_gpencil_weight_settings,
)
layout.template_ID_preview(paint, "brush", rows=3, cols=8, hide_buttons=True)
brush_basic_gpencil_weight_settings(layout, context, brush, compact=True)
layout.popover("VIEW3D_PT_tools_grease_pencil_weight_options", text="Options")
layout.popover("VIEW3D_PT_tools_grease_pencil_brush_weight_falloff", text="Falloff")
return True
@ -7662,12 +7665,10 @@ class VIEW3D_PT_gpencil_weight_context_menu(Panel):
tool_settings = context.tool_settings
settings = tool_settings.gpencil_weight_paint
brush = settings.brush
layout = self.layout
layout.prop(brush, "size", slider=True)
layout.prop(brush, "strength")
layout.prop(brush, "weight")
# Weight settings
brush_basic_gpencil_weight_settings(layout, context, brush)
# Layers
draw_gpencil_layer_active(context, layout)

View File

@ -2021,6 +2021,9 @@ class VIEW3D_PT_tools_grease_pencil_weight_paint_settings(Panel, View3DPanel, Gr
bl_label = "Brush Settings"
def draw(self, context):
if self.is_popover:
return
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
@ -2029,15 +2032,15 @@ class VIEW3D_PT_tools_grease_pencil_weight_paint_settings(Panel, View3DPanel, Gr
settings = tool_settings.gpencil_weight_paint
brush = settings.brush
if not self.is_popover:
from bl_ui.properties_paint_common import (
brush_basic_gpencil_weight_settings,
)
brush_basic_gpencil_weight_settings(layout, context, brush)
from bl_ui.properties_paint_common import (
brush_basic_gpencil_weight_settings,
)
brush_basic_gpencil_weight_settings(layout, context, brush)
class VIEW3D_PT_tools_grease_pencil_brush_weight_falloff(GreasePencilBrushFalloff, Panel, View3DPaintPanel):
bl_context = ".greasepencil_weight"
bl_parent_id = 'VIEW3D_PT_tools_grease_pencil_weight_paint_settings'
bl_label = "Falloff"
bl_options = {'DEFAULT_CLOSED'}
@ -2049,6 +2052,20 @@ class VIEW3D_PT_tools_grease_pencil_brush_weight_falloff(GreasePencilBrushFallof
return (brush and brush.curve)
class VIEW3D_PT_tools_grease_pencil_weight_options(Panel, View3DPanel, GreasePencilWeightPanel):
bl_label = "Options"
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
tool_settings = context.scene.tool_settings
col = layout.column()
col.prop(tool_settings, "use_auto_normalize", text="Auto Normalize")
# Grease Pencil vertex painting tools
class GreasePencilVertexPanel:
bl_context = ".greasepencil_vertex"
@ -2425,6 +2442,7 @@ classes = (
VIEW3D_PT_tools_grease_pencil_sculpt_appearance,
VIEW3D_PT_tools_grease_pencil_weight_paint_select,
VIEW3D_PT_tools_grease_pencil_weight_paint_settings,
VIEW3D_PT_tools_grease_pencil_weight_options,
VIEW3D_PT_tools_grease_pencil_weight_appearance,
VIEW3D_PT_tools_grease_pencil_vertex_paint_select,
VIEW3D_PT_tools_grease_pencil_vertex_paint_settings,

View File

@ -1276,14 +1276,57 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
break;
}
case GP_BRUSH_PRESET_DRAW_WEIGHT: {
case GP_BRUSH_PRESET_WEIGHT_DRAW: {
brush->gpencil_settings->icon_id = GP_BRUSH_ICON_GPBRUSH_WEIGHT;
brush->gpencil_weight_tool = GPWEIGHT_TOOL_DRAW;
brush->size = 25.0f;
brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
brush->gpencil_settings->draw_strength = 0.8f;
brush->alpha = 0.3f;
brush->gpencil_settings->draw_strength = 0.3f;
brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
break;
}
case GP_BRUSH_PRESET_WEIGHT_BLUR: {
brush->gpencil_settings->icon_id = GP_BRUSH_ICON_VERTEX_BLUR;
brush->gpencil_weight_tool = GPWEIGHT_TOOL_BLUR;
brush->size = 50.0f;
brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
brush->alpha = 0.3f;
brush->gpencil_settings->draw_strength = 0.3f;
brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
break;
}
case GP_BRUSH_PRESET_WEIGHT_AVERAGE: {
brush->gpencil_settings->icon_id = GP_BRUSH_ICON_VERTEX_BLUR;
brush->gpencil_weight_tool = GPWEIGHT_TOOL_AVERAGE;
brush->size = 50.0f;
brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
brush->alpha = 0.3f;
brush->gpencil_settings->draw_strength = 0.3f;
brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
break;
}
case GP_BRUSH_PRESET_WEIGHT_SMEAR: {
brush->gpencil_settings->icon_id = GP_BRUSH_ICON_VERTEX_BLUR;
brush->gpencil_weight_tool = GPWEIGHT_TOOL_SMEAR;
brush->size = 50.0f;
brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
brush->alpha = 0.3f;
brush->gpencil_settings->draw_strength = 0.3f;
brush->gpencil_settings->flag |= GP_BRUSH_USE_STRENGTH_PRESSURE;
brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
@ -1569,13 +1612,32 @@ void BKE_brush_gpencil_weight_presets(Main *bmain, ToolSettings *ts, const bool
Paint *weightpaint = &ts->gp_weightpaint->paint;
Brush *brush_prev = weightpaint->brush;
Brush *brush, *deft_weight;
/* Vertex Draw brush. */
brush = gpencil_brush_ensure(bmain, ts, "Draw Weight", OB_MODE_WEIGHT_GPENCIL, &r_new);
/* Weight Draw brush. */
brush = gpencil_brush_ensure(bmain, ts, "Weight Draw", OB_MODE_WEIGHT_GPENCIL, &r_new);
if ((reset) || (r_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_DRAW_WEIGHT);
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_WEIGHT_DRAW);
}
deft_weight = brush; /* save default brush. */
/* Weight Blur brush. */
brush = gpencil_brush_ensure(bmain, ts, "Weight Blur", OB_MODE_WEIGHT_GPENCIL, &r_new);
if ((reset) || (r_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_WEIGHT_BLUR);
}
/* Weight Average brush. */
brush = gpencil_brush_ensure(bmain, ts, "Weight Average", OB_MODE_WEIGHT_GPENCIL, &r_new);
if ((reset) || (r_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_WEIGHT_AVERAGE);
}
/* Weight Smear brush. */
brush = gpencil_brush_ensure(bmain, ts, "Weight Smear", OB_MODE_WEIGHT_GPENCIL, &r_new);
if ((reset) || (r_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_WEIGHT_SMEAR);
}
/* Set default brush. */
if (reset || brush_prev == nullptr) {
BKE_paint_brush_set(weightpaint, deft_weight);

View File

@ -4305,6 +4305,9 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
ARRAY_SIZE(tool_replace_table));
}
}
/* Rename Grease Pencil weight draw brush. */
do_versions_rename_id(bmain, ID_BR, "Draw Weight", "Weight Draw");
}
/**

View File

@ -808,11 +808,14 @@ set_property(GLOBAL PROPERTY ICON_GEOM_NAMES
ops.gpencil.primitive_line
ops.gpencil.primitive_polyline
ops.gpencil.radius
ops.gpencil.sculpt_average
ops.gpencil.sculpt_blur
ops.gpencil.sculpt_clone
ops.gpencil.sculpt_grab
ops.gpencil.sculpt_pinch
ops.gpencil.sculpt_push
ops.gpencil.sculpt_randomize
ops.gpencil.sculpt_smear
ops.gpencil.sculpt_smooth
ops.gpencil.sculpt_strength
ops.gpencil.sculpt_thickness

View File

@ -2079,7 +2079,7 @@ static void gpencil_brush_delete_mode_brushes(Main *bmain,
}
if (mode == CTX_MODE_WEIGHT_GPENCIL) {
if (preset != GP_BRUSH_PRESET_DRAW_WEIGHT) {
if ((preset < GP_BRUSH_PRESET_WEIGHT_DRAW) || (preset > GP_BRUSH_PRESET_WEIGHT_SMEAR)) {
continue;
}
if ((brush_active) && (brush_active->gpencil_weight_tool != brush->gpencil_weight_tool)) {
@ -2666,58 +2666,67 @@ static int gpencil_vertex_group_normalize_all_exec(bContext *C, wmOperator *op)
continue;
}
/* look for tot value */
float *tot_values = MEM_callocN(gps->totpoints * sizeof(float), __func__);
/* Loop all points in stroke. */
for (int i = 0; i < gps->totpoints; i++) {
int v;
float sum = 0.0f;
float sum_lock = 0.0f;
float sum_unlock = 0.0f;
/* Get vertex groups and weights. */
dvert = &gps->dvert[i];
for (int v = 0; v < defbase_tot; v++) {
/* Sum weights. */
for (v = 0; v < defbase_tot; v++) {
/* Get vertex group. */
defgroup = BLI_findlink(&gpd->vertex_group_names, v);
/* skip NULL or locked groups */
if ((defgroup == NULL) || (defgroup->flag & DG_LOCK_WEIGHT)) {
continue;
}
/* skip current */
if ((lock_active) && (v == def_nr)) {
if (defgroup == NULL) {
continue;
}
/* Get weight in vertex group. */
dw = BKE_defvert_find_index(dvert, v);
if (dw != NULL) {
tot_values[i] += dw->weight;
if (dw == NULL) {
continue;
}
sum += dw->weight;
/* Vertex group locked or unlocked? */
if ((defgroup->flag & DG_LOCK_WEIGHT) || ((lock_active) && (v == def_nr))) {
sum_lock += dw->weight;
}
else {
sum_unlock += dw->weight;
}
}
}
/* normalize weights */
for (int i = 0; i < gps->totpoints; i++) {
if (tot_values[i] == 0.0f) {
if ((sum == 1.0f) || (sum_unlock == 0.0f)) {
continue;
}
dvert = &gps->dvert[i];
for (int v = 0; v < defbase_tot; v++) {
/* Normalize weights. */
float fac = MAX2(0, (1.0f - sum_lock) / sum_unlock);
for (v = 0; v < defbase_tot; v++) {
/* Get vertex group. */
defgroup = BLI_findlink(&gpd->vertex_group_names, v);
/* skip NULL or locked groups */
if ((defgroup == NULL) || (defgroup->flag & DG_LOCK_WEIGHT)) {
continue;
}
/* skip current */
if ((lock_active) && (v == def_nr)) {
if (defgroup == NULL) {
continue;
}
/* Get weight in vertex group. */
dw = BKE_defvert_find_index(dvert, v);
if (dw != NULL) {
dw->weight = dw->weight / tot_values[i];
if (dw == NULL) {
continue;
}
/* Normalize in unlocked vertex groups only. */
if (!((defgroup->flag & DG_LOCK_WEIGHT) || ((lock_active) && (v == def_nr)))) {
dw->weight *= fac;
CLAMP(dw->weight, 0.0f, 1.0f);
}
}
}
/* free temp array */
MEM_SAFE_FREE(tot_values);
}
CTX_DATA_END;

View File

@ -518,6 +518,8 @@ void GPENCIL_OT_stroke_editcurve_set_handle_type(struct wmOperatorType *ot);
*/
void GPENCIL_OT_sculpt_paint(struct wmOperatorType *ot);
void GPENCIL_OT_weight_paint(struct wmOperatorType *ot);
void GPENCIL_OT_weight_toggle_direction(struct wmOperatorType *ot);
void GPENCIL_OT_weight_sample(struct wmOperatorType *ot);
/* buttons editing --- */

View File

@ -292,6 +292,24 @@ static bool gpencil_stroke_weightmode_draw_poll(bContext *C)
return gpencil_stroke_weightmode_poll_with_tool(C, GPWEIGHT_TOOL_DRAW);
}
/* Poll callback for weight paint (Blur) */
static bool gpencil_stroke_weightmode_blur_poll(bContext *C)
{
return gpencil_stroke_weightmode_poll_with_tool(C, GPWEIGHT_TOOL_BLUR);
}
/* Poll callback for weight paint (Average) */
static bool gpencil_stroke_weightmode_average_poll(bContext *C)
{
return gpencil_stroke_weightmode_poll_with_tool(C, GPWEIGHT_TOOL_AVERAGE);
}
/* Poll callback for weight paint (Smear) */
static bool gpencil_stroke_weightmode_smear_poll(bContext *C)
{
return gpencil_stroke_weightmode_poll_with_tool(C, GPWEIGHT_TOOL_SMEAR);
}
/* Stroke Editing Keymap - Only when editmode is enabled */
static void ed_keymap_gpencil_editing(wmKeyConfig *keyconf)
{
@ -460,6 +478,24 @@ static void ed_keymap_gpencil_weightpainting_draw(wmKeyConfig *keyconf)
wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Grease Pencil Stroke Weight (Draw)", 0, 0);
keymap->poll = gpencil_stroke_weightmode_draw_poll;
}
/* keys for weight with a blur brush */
static void ed_keymap_gpencil_weightpainting_blur(wmKeyConfig *keyconf)
{
wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Grease Pencil Stroke Weight (Blur)", 0, 0);
keymap->poll = gpencil_stroke_weightmode_blur_poll;
}
/* keys for weight with a average brush */
static void ed_keymap_gpencil_weightpainting_average(wmKeyConfig *keyconf)
{
wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Grease Pencil Stroke Weight (Average)", 0, 0);
keymap->poll = gpencil_stroke_weightmode_average_poll;
}
/* keys for weight with a smear brush */
static void ed_keymap_gpencil_weightpainting_smear(wmKeyConfig *keyconf)
{
wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Grease Pencil Stroke Weight (Smear)", 0, 0);
keymap->poll = gpencil_stroke_weightmode_smear_poll;
}
/* ==================== */
@ -485,6 +521,9 @@ void ED_keymap_gpencil(wmKeyConfig *keyconf)
ed_keymap_gpencil_sculptpainting_clone(keyconf);
ed_keymap_gpencil_weightpainting(keyconf);
ed_keymap_gpencil_weightpainting_draw(keyconf);
ed_keymap_gpencil_weightpainting_blur(keyconf);
ed_keymap_gpencil_weightpainting_average(keyconf);
ed_keymap_gpencil_weightpainting_smear(keyconf);
ed_keymap_gpencil_vertexpainting(keyconf);
ed_keymap_gpencil_vertexpainting_draw(keyconf);
ed_keymap_gpencil_vertexpainting_blur(keyconf);
@ -564,6 +603,8 @@ void ED_operatortypes_gpencil(void)
WM_operatortype_append(GPENCIL_OT_sculpt_paint);
WM_operatortype_append(GPENCIL_OT_weight_paint);
WM_operatortype_append(GPENCIL_OT_weight_toggle_direction);
WM_operatortype_append(GPENCIL_OT_weight_sample);
/* Edit stroke editcurve */

File diff suppressed because it is too large Load Diff

View File

@ -2215,6 +2215,15 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
case GP_BRUSH_ICON_GPBRUSH_WEIGHT:
br->id.icon_id = ICON_GPBRUSH_WEIGHT;
break;
case GP_BRUSH_ICON_GPBRUSH_BLUR:
br->id.icon_id = ICON_BRUSH_BLUR;
break;
case GP_BRUSH_ICON_GPBRUSH_AVERAGE:
br->id.icon_id = ICON_BRUSH_BLUR;
break;
case GP_BRUSH_ICON_GPBRUSH_SMEAR:
br->id.icon_id = ICON_BRUSH_BLUR;
break;
default:
br->id.icon_id = ICON_GPBRUSH_PEN;
break;

View File

@ -1845,6 +1845,18 @@ static void ed_default_handlers(
wmKeyMap *keymap_weight_draw = WM_keymap_ensure(
wm->defaultconf, "Grease Pencil Stroke Weight (Draw)", 0, 0);
WM_event_add_keymap_handler(handlers, keymap_weight_draw);
wmKeyMap *keymap_weight_blur = WM_keymap_ensure(
wm->defaultconf, "Grease Pencil Stroke Weight (Blur)", 0, 0);
WM_event_add_keymap_handler(handlers, keymap_weight_blur);
wmKeyMap *keymap_weight_average = WM_keymap_ensure(
wm->defaultconf, "Grease Pencil Stroke Weight (Average)", 0, 0);
WM_event_add_keymap_handler(handlers, keymap_weight_average);
wmKeyMap *keymap_weight_smear = WM_keymap_ensure(
wm->defaultconf, "Grease Pencil Stroke Weight (Smear)", 0, 0);
WM_event_add_keymap_handler(handlers, keymap_weight_smear);
}
}

View File

@ -132,7 +132,19 @@ static eGPBrush_Presets gpencil_get_brush_preset_from_tool(bToolRef *tool,
break;
}
case CTX_MODE_WEIGHT_GPENCIL: {
return GP_BRUSH_PRESET_DRAW_WEIGHT;
if (STREQ(tool->runtime->data_block, "DRAW")) {
return GP_BRUSH_PRESET_WEIGHT_DRAW;
}
if (STREQ(tool->runtime->data_block, "BLUR")) {
return GP_BRUSH_PRESET_WEIGHT_BLUR;
}
if (STREQ(tool->runtime->data_block, "AVERAGE")) {
return GP_BRUSH_PRESET_WEIGHT_AVERAGE;
}
if (STREQ(tool->runtime->data_block, "SMEAR")) {
return GP_BRUSH_PRESET_WEIGHT_SMEAR;
}
break;
}
case CTX_MODE_VERTEX_GPENCIL: {
if (STREQ(tool->runtime->data_block, "DRAW")) {

View File

@ -3665,8 +3665,7 @@ static bool do_mesh_box_select(ViewContext *vc,
}
if (ts->selectmode & SCE_SELECT_EDGE) {
/* Does both use_zbuf and non-use_zbuf versions (need screen cos for both) */
struct BoxSelectUserData_ForMeshEdge cb_data {
};
struct BoxSelectUserData_ForMeshEdge cb_data {};
cb_data.data = &data;
cb_data.esel = use_zbuf ? esel : nullptr;
cb_data.backbuf_offset = use_zbuf ? DRW_select_buffer_context_offset_for_object_elem(

View File

@ -50,7 +50,10 @@ typedef enum eGPBrush_Presets {
GP_BRUSH_PRESET_CLONE_STROKE = 208,
/* Weight Paint 300-399. */
GP_BRUSH_PRESET_DRAW_WEIGHT = 300,
GP_BRUSH_PRESET_WEIGHT_DRAW = 300,
GP_BRUSH_PRESET_WEIGHT_BLUR = 301,
GP_BRUSH_PRESET_WEIGHT_AVERAGE = 302,
GP_BRUSH_PRESET_WEIGHT_SMEAR = 303,
} eGPBrush_Presets;
/* BrushGpencilSettings->flag */
@ -187,6 +190,9 @@ typedef enum eGP_BrushIcons {
GP_BRUSH_ICON_GPBRUSH_PINCH = 26,
GP_BRUSH_ICON_GPBRUSH_CLONE = 27,
GP_BRUSH_ICON_GPBRUSH_WEIGHT = 28,
GP_BRUSH_ICON_GPBRUSH_BLUR = 29,
GP_BRUSH_ICON_GPBRUSH_AVERAGE = 30,
GP_BRUSH_ICON_GPBRUSH_SMEAR = 31,
} eGP_BrushIcons;
typedef enum eBrushCurvePreset {
@ -607,6 +613,9 @@ typedef enum eBrushGPSculptTool {
/* BrushGpencilSettings->brush type */
typedef enum eBrushGPWeightTool {
GPWEIGHT_TOOL_DRAW = 0,
GPWEIGHT_TOOL_BLUR = 1,
GPWEIGHT_TOOL_AVERAGE = 2,
GPWEIGHT_TOOL_SMEAR = 3,
} eBrushGPWeightTool;
/* direction that the brush displaces along */

View File

@ -293,7 +293,18 @@ const EnumPropertyItem rna_enum_brush_gpencil_weight_types_items[] = {
"WEIGHT",
ICON_GPBRUSH_WEIGHT,
"Weight",
"Weight Paint for Vertex Groups"},
"Paint weight in active vertex group"},
{GPWEIGHT_TOOL_BLUR, "BLUR", ICON_BRUSH_BLUR, "Blur", "Blur weight in active vertex group"},
{GPWEIGHT_TOOL_AVERAGE,
"AVERAGE",
ICON_BRUSH_BLUR,
"Average",
"Average weight in active vertex group"},
{GPWEIGHT_TOOL_SMEAR,
"SMEAR",
ICON_BRUSH_SMEAR,
"Smear",
"Smear weight in active vertex group"},
{0, NULL, 0, NULL, NULL},
};
@ -401,6 +412,9 @@ static EnumPropertyItem rna_enum_gpencil_brush_sculpt_icons_items[] = {
static EnumPropertyItem rna_enum_gpencil_brush_weight_icons_items[] = {
{GP_BRUSH_ICON_GPBRUSH_WEIGHT, "DRAW", ICON_GPBRUSH_WEIGHT, "Draw", ""},
{GP_BRUSH_ICON_GPBRUSH_BLUR, "BLUR", ICON_BRUSH_BLUR, "Blur", ""},
{GP_BRUSH_ICON_GPBRUSH_AVERAGE, "AVERAGE", ICON_BRUSH_BLUR, "Average", ""},
{GP_BRUSH_ICON_GPBRUSH_SMEAR, "SMEAR", ICON_BRUSH_BLUR, "Smear", ""},
{0, NULL, 0, NULL, NULL},
};
static EnumPropertyItem rna_enum_gpencil_brush_vertex_icons_items[] = {