[Bf-blender-cvs] [b74e90656eb] greasepencil-object: Reorganize Brush parameters panel
Antonio Vazquez
noreply at git.blender.org
Thu Mar 8 19:50:39 CET 2018
Commit: b74e90656ebc9a35d0d1bc6aff03cb0274cd5c30
Author: Antonio Vazquez
Date: Thu Mar 8 19:50:24 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rBb74e90656ebc9a35d0d1bc6aff03cb0274cd5c30
Reorganize Brush parameters panel
As we have a lot of options, the panel required a reorganization and clarify what parameters affect after the stroke is created.
Also added options to enable/disable effects like smooth without changing the values.
===================================================================
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
M source/blender/editors/gpencil/gpencil_paint.c
M source/blender/makesdna/DNA_gpencil_types.h
M source/blender/makesrna/intern/rna_scene.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index bcc9641f553..0a12a967ed0 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -2155,47 +2155,55 @@ class VIEW3D_PT_tools_grease_pencil_brush_option(Panel):
layout = self.layout
brush = context.active_gpencil_brush
if brush is not None:
- # XXX: Is this post-drawing, or while drawing?
col = layout.column(align=True)
- col.label(text="Stroke Quality:")
- col.prop(brush, "pen_smooth_factor")
- col.prop(brush, "pen_smooth_steps")
-
- col = layout.column(align=True)
- col.label(text="Thickness:")
- col.prop(brush, "pen_thick_smooth_factor")
- col.prop(brush, "pen_thick_smooth_steps")
-
+ row = col.row()
+ row.prop(brush, "input_samples")
+ row.prop(brush, "active_smooth_factor")
col.separator()
- row = col.row(align=False)
- row.prop(brush, "pen_subdivision_steps")
- row.prop(brush, "random_subdiv", text="Randomness", slider=True)
-
- col = layout.column(align=True)
- col.label(text="Settings:")
- col.prop(brush, "random_press", slider=True)
-
- row = layout.row(align=True)
- row.prop(brush, "jitter", slider=True)
- row.prop(brush, "use_jitter_pressure", text="", icon='STYLUS_PRESSURE')
- row = layout.row(align=True) # FIXME: When not aligned, they're too small, but looks ugly when aligned
- row.prop(brush, "angle", slider=True)
- row.prop(brush, "angle_factor", text="Factor", slider=True)
if brush.type == 'DRAW':
- row.separator()
- col = layout.column(align=True)
col.prop(brush, "use_stabilizer", text="Stabilizer")
if brush.use_stabilizer:
+ col.separator()
col.prop(brush, "lazy_radius", text="Distance")
col.prop(brush, "lazy_factor", slider=True)
+ col.separator()
- row = layout.row(align=True)
- row.prop(brush, "uv_random", slider=True)
+ col.prop(brush, "enable_random", text="Random Settings")
+ if brush.enable_random is True:
+ col.separator()
+ col.prop(brush, "uv_random", slider=True)
- row = layout.row()
- row.prop(brush, "input_samples")
- row.prop(brush, "active_smooth_factor")
+ col.separator()
+ col.label(text="Settings:")
+ col.prop(brush, "random_press", slider=True)
+
+ row = col.row(align=True)
+ row.prop(brush, "jitter", slider=True)
+ row.prop(brush, "use_jitter_pressure", text="", icon='STYLUS_PRESSURE')
+
+ row = col.row(align=True)
+ row.prop(brush, "angle", slider=True)
+ row.prop(brush, "angle_factor", text="Factor", slider=True)
+ col.separator()
+
+ col.prop(brush, "enable_smooth", text="Post-processing Smooth")
+ if brush.enable_smooth is True:
+ col.label(text="Stroke Quality:")
+ col.prop(brush, "pen_smooth_factor")
+ col.prop(brush, "pen_smooth_steps")
+
+ col = layout.column(align=True)
+ col.label(text="Thickness:")
+ col.prop(brush, "pen_thick_smooth_factor")
+ col.prop(brush, "pen_thick_smooth_steps")
+ col.separator()
+
+ col.prop(brush, "enable_subdiv", text="Post-processing Subdivide")
+ if brush.enable_subdiv is True:
+ col.separator()
+ col.prop(brush, "pen_subdivision_steps")
+ col.prop(brush, "random_subdiv", text="Randomness", slider=True)
# Grease Pencil drawing brushes mode
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 0a4659e9e94..0c942beaff0 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -616,7 +616,7 @@ static short gp_stroke_addpoint(
}
/* Apply jitter to position */
- if (brush->draw_jitter > 0.0f) {
+ if ((brush->flag_group & GP_BRUSH_GROUP_RANDOM) && (brush->draw_jitter > 0.0f)) {
int r_mval[2];
gp_brush_jitter(gpd, brush, pt, mval, r_mval);
copy_v2_v2_int(&pt->x, r_mval);
@@ -625,7 +625,10 @@ static short gp_stroke_addpoint(
copy_v2_v2_int(&pt->x, mval);
}
/* apply randomness to pressure */
- if ((brush->draw_random_press > 0.0f) && (brush->flag & GP_BRUSH_USE_RANDOM_PRESSURE)) {
+ if ((brush->flag_group & GP_BRUSH_GROUP_RANDOM) &&
+ (brush->draw_random_press > 0.0f) &&
+ (brush->flag & GP_BRUSH_USE_RANDOM_PRESSURE))
+ {
float curvef = curvemapping_evaluateF(brush->cur_sensitivity, 0, pressure);
float tmp_pressure = curvef * brush->draw_sensitivity;
if (BLI_frand() > 0.5f) {
@@ -638,7 +641,7 @@ static short gp_stroke_addpoint(
}
/* apply randomness to uv texture rotation */
- if (brush->uv_random > 0.0f) {
+ if ((brush->flag_group & GP_BRUSH_GROUP_RANDOM) && (brush->uv_random > 0.0f)) {
if (BLI_frand() > 0.5f) {
pt->uv_rot = (BLI_frand() * M_PI * -1) * brush->uv_random;
}
@@ -652,7 +655,7 @@ static short gp_stroke_addpoint(
}
/* apply angle of stroke to brush size */
- if (brush->draw_angle_factor > 0.0f) {
+ if ((brush->flag_group & GP_BRUSH_GROUP_RANDOM) && (brush->draw_angle_factor > 0.0f)) {
gp_brush_angle(gpd, brush, pt, mval);
}
@@ -669,7 +672,10 @@ static short gp_stroke_addpoint(
CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f);
/* apply randomness to color strength */
- if ((brush->draw_random_press > 0.0f) && (brush->flag & GP_BRUSH_USE_RANDOM_STRENGTH)) {
+ if ((brush->flag_group & GP_BRUSH_GROUP_RANDOM) &&
+ (brush->draw_random_press > 0.0f) &&
+ (brush->flag & GP_BRUSH_USE_RANDOM_STRENGTH))
+ {
if (BLI_frand() > 0.5f) {
pt->strength -= pt->strength * brush->draw_random_press * BLI_frand();
}
@@ -1090,11 +1096,11 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
}
/* subdivide and smooth the stroke */
- if (sublevel > 0) {
+ if ((brush->flag_group & GP_BRUSH_GROUP_SUBDIVIDE) && (sublevel > 0)) {
gp_subdivide_stroke(gps, sublevel);
}
/* apply randomness to stroke */
- if (brush->draw_random_sub > 0.0f) {
+ if ((brush->flag_group & GP_BRUSH_GROUP_RANDOM) && (brush->draw_random_sub > 0.0f)) {
gp_randomize_stroke(gps, brush);
}
@@ -1102,7 +1108,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
* for each iteration, the factor is reduced to get a better smoothing without changing too much
* the original stroke
*/
- if (brush->draw_smoothfac > 0.0f) {
+ if ((brush->flag_group & GP_BRUSH_GROUP_SMOOTH) && (brush->draw_smoothfac > 0.0f)) {
float reduce = 0.0f;
for (int r = 0; r < brush->draw_smoothlvl; r++) {
for (i = 0; i < gps->totpoints; i++) {
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index 85de40167fe..b889fc3b692 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -142,6 +142,9 @@ typedef struct bGPDbrush {
int type; /* type of brush (draw, fill, erase, etc..) */
int eraser_mode; /* soft, hard or stroke */
float active_smooth; /* smooth while drawing factor */
+
+ int flag_group; /* falg to enable/disable groups of options */
+ char pad[4];
} bGPDbrush;
/* bGPDbrush->flag */
@@ -174,6 +177,16 @@ typedef enum eGPDbrush_Flag {
GP_BRUSH_DEFAULT_ERASER = (1 << 13),
} eGPDbrush_Flag;
+/* bGPDbrush->flag_group */
+typedef enum eGPDbrush_FlagGroup {
+ /* smooth group */
+ GP_BRUSH_GROUP_SMOOTH = (1 << 0),
+ /* subdivide group */
+ GP_BRUSH_GROUP_SUBDIVIDE = (1 << 1),
+ /* Random settings group */
+ GP_BRUSH_GROUP_RANDOM = (1 << 2),
+} eGPDbrush_FlagGroup;
+
/* ***************************************** */
/* GP Palettes (Deprecated - 2.78 - 2.79 only) */
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 48f15b493b4..0fb6c46582a 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2530,6 +2530,18 @@ static void rna_def_gpencil_brush(BlenderRNA *brna)
RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1);
RNA_def_property_ui_text(prop, "Default Eraser", "Use this brush when enable eraser with fast switch key");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_brush_default_eraser");
+
+ prop = RNA_def_property(srna, "enable_smooth", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag_group", GP_BRUSH_GROUP_SMOOTH);
+ RNA_def_property_ui_text(prop, "Smooth", "Enable post smooth processing for new strokes");
+
+ prop = RNA_def_property(srna, "enable_subdiv", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag_group", GP_BRUSH_GROUP_SUBDIVIDE);
+ RNA_def_property_ui_text(prop, "Subdivide", "Enable post subdivide processing for new strokes");
+
+ prop = RNA_def_property(srna, "enable_random", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag_group", GP_BRUSH_GROUP_RANDOM);
+ RNA_def_property_ui_text(prop, "Random Settings", "Enable random settings for brush");
}
/* Grease Pencil Drawing Brushes API */
More information about the Bf-blender-cvs
mailing list