Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Vazquez <blendergit@gmail.com>2020-03-20 17:37:56 +0300
committerAntonio Vazquez <blendergit@gmail.com>2020-03-21 11:48:18 +0300
commitd924e31b421a51fed343fbd2a17291cfd289d9bc (patch)
tree674c93c2d214c027ebc1573858d673682533c746
parenta22cd6b6a95138d73e9e23f7ac0d40de17a5a25f (diff)
GPencil: New Hardeness mode for Opacity modifier
Add new option to change the stroke hardeness. This option works at stroke level, not at point level. Also replaced the "Both" name mode by "Stroke and Fill". Differential Revision: https://developer.blender.org/D7195
-rw-r--r--release/scripts/startup/bl_ui/properties_data_modifier.py21
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c9
-rw-r--r--source/blender/makesdna/DNA_gpencil_modifier_types.h3
-rw-r--r--source/blender/makesrna/intern/rna_brush.c2
-rw-r--r--source/blender/makesrna/intern/rna_gpencil_modifier.c20
5 files changed, 43 insertions, 12 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 7508b0e2321..277791a9f53 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1996,16 +1996,21 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
split = layout.split()
col = split.column()
- col.prop(md, "normalize_opacity")
- if md.normalize_opacity is True:
- text="Strength"
- else:
- text="Opacity Factor"
-
- col.prop(md, "factor", text=text)
col.prop(md, "modify_color")
- self.gpencil_masking(layout, ob, md, True, True)
+ if md.modify_color == 'HARDENESS':
+ col.prop(md, "hardeness")
+ show = False
+ else:
+ col.prop(md, "normalize_opacity")
+ if md.normalize_opacity is True:
+ text="Strength"
+ else:
+ text="Opacity Factor"
+
+ col.prop(md, "factor", text=text)
+ show = True
+ self.gpencil_masking(layout, ob, md, show, show)
def GP_ARRAY(self, layout, ob, md):
col = layout.column()
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
index 12576b3d27f..93f3776827b 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
@@ -51,6 +51,7 @@ static void initData(GpencilModifierData *md)
OpacityGpencilModifierData *gpmd = (OpacityGpencilModifierData *)md;
gpmd->pass_index = 0;
gpmd->factor = 1.0f;
+ gpmd->hardeness = 1.0f;
gpmd->layername[0] = '\0';
gpmd->materialname[0] = '\0';
gpmd->vgname[0] = '\0';
@@ -104,6 +105,14 @@ static void deformStroke(GpencilModifierData *md,
return;
}
+ /* Hardeness (at stroke level). */
+ if (mmd->modify_color == GP_MODIFY_COLOR_HARDENESS) {
+ gps->hardeness *= mmd->hardeness;
+ CLAMP(gps->hardeness, 0.0f, 1.0f);
+
+ return;
+ }
+
for (int i = 0; i < gps->totpoints; i++) {
bGPDspoint *pt = &gps->points[i];
MDeformVert *dvert = gps->dvert != NULL ? &gps->dvert[i] : NULL;
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h
index bc7873adb70..f98ec281011 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_types.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h
@@ -215,6 +215,7 @@ typedef enum eModifyColorGpencil_Flag {
GP_MODIFY_COLOR_BOTH = 0,
GP_MODIFY_COLOR_STROKE = 1,
GP_MODIFY_COLOR_FILL = 2,
+ GP_MODIFY_COLOR_HARDENESS = 3,
} eModifyColorGpencil_Flag;
typedef enum eOpacityModesGpencil_Flag {
@@ -272,7 +273,7 @@ typedef struct OpacityGpencilModifierData {
/** Custom index for passes. */
int layer_pass;
- char _pad1[4];
+ float hardeness;
struct CurveMapping *curve_intensity;
} OpacityGpencilModifierData;
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index b18f50e3837..a4091718487 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -1169,7 +1169,7 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
static EnumPropertyItem gppaint_mode_types_items[] = {
{GPPAINT_MODE_STROKE, "STROKE", 0, "Stroke", "Vertex Color affects to Stroke only"},
{GPPAINT_MODE_FILL, "FILL", 0, "Fill", "Vertex Color affects to Fill only"},
- {GPPAINT_MODE_BOTH, "BOTH", 0, "Both", "Vertex Color affects to Stroke and Fill"},
+ {GPPAINT_MODE_BOTH, "BOTH", 0, "Stroke and Fill", "Vertex Color affects to Stroke and Fill"},
{0, NULL, 0, NULL, NULL},
};
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index 34eee9415d9..31775a70af6 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -134,12 +134,20 @@ const EnumPropertyItem rna_enum_object_greasepencil_modifier_type_items[] = {
#ifndef RNA_RUNTIME
static const EnumPropertyItem modifier_modify_color_items[] = {
- {GP_MODIFY_COLOR_BOTH, "BOTH", 0, "Both", "Modify fill and stroke colors"},
+ {GP_MODIFY_COLOR_BOTH, "BOTH", 0, "Stroke and Fill", "Modify fill and stroke colors"},
{GP_MODIFY_COLOR_STROKE, "STROKE", 0, "Stroke", "Modify stroke color only"},
{GP_MODIFY_COLOR_FILL, "FILL", 0, "Fill", "Modify fill color only"},
{0, NULL, 0, NULL, NULL},
};
+static const EnumPropertyItem modifier_modify_opacity_items[] = {
+ {GP_MODIFY_COLOR_BOTH, "BOTH", 0, "Stroke and Fill", "Modify fill and stroke colors"},
+ {GP_MODIFY_COLOR_STROKE, "STROKE", 0, "Stroke", "Modify stroke color only"},
+ {GP_MODIFY_COLOR_FILL, "FILL", 0, "Fill", "Modify fill color only"},
+ {GP_MODIFY_COLOR_HARDENESS, "HARDENESS", 0, "Hardeness", "Modify stroke hardeness"},
+ {0, NULL, 0, NULL, NULL},
+};
+
static const EnumPropertyItem modifier_gphook_falloff_items[] = {
{eGPHook_Falloff_None, "NONE", 0, "No Falloff", ""},
{eGPHook_Falloff_Curve, "CURVE", 0, "Curve", ""},
@@ -1324,7 +1332,7 @@ static void rna_def_modifier_gpencilopacity(BlenderRNA *brna)
RNA_def_struct_ui_icon(srna, ICON_MOD_OPACITY);
prop = RNA_def_property(srna, "modify_color", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, modifier_modify_color_items); /* share the enum */
+ RNA_def_property_enum_items(prop, modifier_modify_opacity_items);
RNA_def_property_ui_text(prop, "Mode", "Set what colors of the stroke are affected");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
@@ -1352,6 +1360,14 @@ static void rna_def_modifier_gpencilopacity(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Opacity Factor", "Factor of Opacity");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+ prop = RNA_def_property(srna, "hardeness", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "hardeness");
+ RNA_def_property_range(prop, 0.0, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0.0, FLT_MAX, 0.1, 2);
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_ui_text(prop, "Hardeness", "Factor of stroke hardeness");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "pass_index");
RNA_def_property_range(prop, 0, 100);