GP: Refactor target weight paint
Now, the target weight is defined as the final maximum value with a new property and all fields have be moved to brush struct.
This commit is contained in:
parent
e63c947204
commit
a4a9123c33
|
@ -405,15 +405,14 @@ class _draw_left_context_mode:
|
|||
layout.prop(brush, "size", slider=True)
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(settings, "use_fix_weight", text="", icon='WPAINT_HLT')
|
||||
if settings.use_fix_weight is False:
|
||||
row.prop(brush, "strength", slider=True)
|
||||
else:
|
||||
row.prop(brush, "strength", text="Weight", slider=True)
|
||||
row.prop(brush, "strength", slider=True)
|
||||
row.prop(brush, "use_pressure_strength", text="")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(brush, "use_target_weight", text="", icon='WPAINT_HLT')
|
||||
sub = row.row(align=True)
|
||||
sub.enabled = not settings.use_fix_weight
|
||||
sub.prop(brush, "use_pressure_strength", text="")
|
||||
sub.enabled = brush.use_target_weight
|
||||
sub.prop(brush, "target_weight", slider=True)
|
||||
|
||||
@staticmethod
|
||||
def PARTICLE(context, layout, tool):
|
||||
|
|
|
@ -903,21 +903,16 @@ static bool gp_brush_weight_apply(
|
|||
|
||||
if (gp_brush_invert_check(gso)) {
|
||||
/* reduce weight */
|
||||
if (gso->settings->flag & GP_SCULPT_SETT_FLAG_PAINT_WEIGHT) {
|
||||
curweight = 0.0f;
|
||||
}
|
||||
else {
|
||||
curweight -= inf;
|
||||
}
|
||||
curweight -= inf;
|
||||
}
|
||||
else {
|
||||
/* increase weight */
|
||||
if (gso->settings->flag & GP_SCULPT_SETT_FLAG_PAINT_WEIGHT) {
|
||||
curweight = gso->gp_brush->strength;
|
||||
}
|
||||
else {
|
||||
curweight += inf;
|
||||
}
|
||||
curweight += inf;
|
||||
}
|
||||
|
||||
/* verify target weight */
|
||||
if (gso->gp_brush->flag & GP_SCULPT_FLAG_TARGET_WEIGHT) {
|
||||
CLAMP_MAX(curweight, gso->gp_brush->target_weight);
|
||||
}
|
||||
|
||||
CLAMP(curweight, 0.0f, 1.0f);
|
||||
|
|
|
@ -995,6 +995,8 @@ typedef struct GP_Sculpt_Data {
|
|||
float strength; /* strength of effect */
|
||||
float curcolor_add[3]; /* cursor color for add */
|
||||
float curcolor_sub[3]; /* cursor color for sub */
|
||||
float target_weight; /* target weight */
|
||||
char pad_[4];
|
||||
} GP_Sculpt_Data;
|
||||
|
||||
/* GP_Sculpt_Data.flag */
|
||||
|
@ -1015,6 +1017,8 @@ typedef enum eGP_Sculpt_Flag {
|
|||
GP_SCULPT_FLAG_TMP_INVERT = (1 << 5),
|
||||
/* adjust radius using pen pressure */
|
||||
GP_SCULPT_FLAG_PRESSURE_RADIUS = (1 << 6),
|
||||
/* paint weight, define a target */
|
||||
GP_SCULPT_FLAG_TARGET_WEIGHT = (1 << 7),
|
||||
} eGP_Sculpt_Flag;
|
||||
|
||||
/* GPencil Stroke Sculpting Settings */
|
||||
|
@ -1051,8 +1055,6 @@ typedef enum eGP_Sculpt_SettingsFlag {
|
|||
GP_SCULPT_SETT_FLAG_FRAME_FALLOFF = (1 << 5),
|
||||
/* apply brush to uv data */
|
||||
GP_SCULPT_SETT_FLAG_APPLY_UV = (1 << 6),
|
||||
/* paint weight, not add/substract */
|
||||
GP_SCULPT_SETT_FLAG_PAINT_WEIGHT = (1 << 7),
|
||||
} eGP_Sculpt_SettingsFlag;
|
||||
|
||||
/* Settings for GP Interpolation Operators */
|
||||
|
|
|
@ -1244,13 +1244,6 @@ static void rna_def_gpencil_sculpt(BlenderRNA *brna)
|
|||
RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "use_fix_weight", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_SETT_FLAG_PAINT_WEIGHT);
|
||||
RNA_def_property_ui_text(prop, "Fix Weight",
|
||||
"Set the predefined weight to any point affected by the brush");
|
||||
RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "use_multiframe_falloff", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_SETT_FLAG_FRAME_FALLOFF);
|
||||
RNA_def_property_ui_text(prop, "Use Falloff", "Use falloff effect when edit in multiframe mode to compute brush effect by frame");
|
||||
|
@ -1294,6 +1287,19 @@ static void rna_def_gpencil_sculpt(BlenderRNA *brna)
|
|||
RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "target_weight", PROP_FLOAT, PROP_FACTOR);
|
||||
RNA_def_property_range(prop, 0.0, 1.0);
|
||||
RNA_def_property_ui_text(prop, "Weight", "Target weight");
|
||||
RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "use_target_weight", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_FLAG_TARGET_WEIGHT);
|
||||
RNA_def_property_ui_text(prop, "Target",
|
||||
"Use predefined target weight to any point affected by the brush");
|
||||
RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "use_pressure_strength", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SCULPT_FLAG_USE_PRESSURE);
|
||||
RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
|
||||
|
|
Loading…
Reference in New Issue