[Bf-blender-cvs] [a900b2d2a1a] greasepencil-object: Replace Random checkboxes by Factors

Antonio Vazquez noreply at git.blender.org
Fri Mar 16 18:07:13 CET 2018


Commit: a900b2d2a1a9370f2aea805c7a780824c24e175f
Author: Antonio Vazquez
Date:   Fri Mar 16 18:07:06 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rBa900b2d2a1a9370f2aea805c7a780824c24e175f

Replace Random checkboxes by Factors

As we have a new Random section in the stroke panel, it's not logic to have buttons in the main panel.

Now, these random parameters work equal to other random factors.

===================================================================

M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/blenkernel/intern/brush.c
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/makesdna/DNA_brush_types.h
M	source/blender/makesrna/intern/rna_brush.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index efc26644391..62c39059f75 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -2088,11 +2088,9 @@ class VIEW3D_PT_tools_grease_pencil_brush(Panel):
 
             if brush.gpencil_brush_type == 'DRAW':
                 row = layout.row(align=True)
-                row.prop(brush, "use_random_pressure", text="", icon='RNDCURVE')
                 row.prop(brush, "line_width", text="Radius")
                 row.prop(brush, "use_pressure", text="", icon='STYLUS_PRESSURE')
                 row = layout.row(align=True)
-                row.prop(brush, "use_random_strength", text="", icon='RNDCURVE')
                 row.prop(brush, "pen_strength", slider=True)
                 row.prop(brush, "use_strength_pressure", text="", icon='STYLUS_PRESSURE')
 
@@ -2172,12 +2170,15 @@ class VIEW3D_PT_tools_grease_pencil_brush_option(Panel):
 
             col.prop(brush, "enable_random", text="Random Settings")
             if brush.enable_random is True:
+                col.label(text="Settings:")
+                col.prop(brush, "random_pressure", text="Pressure", slider=True)
                 col.separator()
-                col.prop(brush, "uv_random", slider=True)
 
+                col.prop(brush, "random_strength", text="Strength", slider=True)
+                col.separator()
+
+                col.prop(brush, "uv_random", text="UV", slider=True)
                 col.separator()
-                col.label(text="Settings:")
-                col.prop(brush, "random_press", slider=True)
 
                 row = col.row(align=True)
                 row.prop(brush, "pen_jitter", slider=True)
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 62b6a8f5bd0..d3d7069133c 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -269,10 +269,9 @@ void BKE_brush_gpencil_presets(bContext *C)
 	/* Pencil brush */
 	brush = BKE_brush_add_gpencil(bmain, ts, "Draw Pencil");
 	brush->thickness = 25.0f;
-	brush->gp_flag |= (GP_BRUSH_USE_RANDOM_PRESSURE | GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR);
+	brush->gp_flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR);
 	brush->draw_sensitivity = 1.0f;
 
-	brush->gp_flag |= GP_BRUSH_USE_RANDOM_STRENGTH;
 	brush->draw_strength = 0.6f;
 	brush->gp_flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
 
@@ -301,14 +300,14 @@ void BKE_brush_gpencil_presets(bContext *C)
 	brush = BKE_brush_add_gpencil(bmain, ts, "Draw Pen");
 	deft = brush; /* save default brush */
 	brush->thickness = 30.0f;
-	brush->gp_flag |= (GP_BRUSH_USE_RANDOM_PRESSURE | GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR);
+	brush->gp_flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR);
 	brush->draw_sensitivity = 1.0f;
 
-	brush->gp_flag |= GP_BRUSH_USE_RANDOM_STRENGTH;
 	brush->draw_strength = 1.0f;
 	brush->gp_flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
 
 	brush->draw_random_press = 0.0f;
+	brush->draw_random_strength = 0.0f;
 
 	brush->draw_jitter = 0.0f;
 	brush->gp_flag |= GP_BRUSH_USE_JITTER_PRESSURE;
@@ -367,12 +366,14 @@ void BKE_brush_gpencil_presets(bContext *C)
 	/* Ink Noise brush */
 	brush = brush = BKE_brush_add_gpencil(bmain, ts, "Draw Noise");
 	brush->thickness = 60.0f;
-	brush->gp_flag |= (GP_BRUSH_USE_RANDOM_PRESSURE | GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR);
+	brush->gp_flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR);
 	brush->draw_sensitivity = 1.0f;
 
 	brush->draw_strength = 1.0f;
 
+	brush->gp_flag |= GP_BRUSH_GROUP_RANDOM;
 	brush->draw_random_press = 0.7f;
+	brush->draw_random_strength = 0.0f;
 
 	brush->draw_jitter = 0.0f;
 	brush->gp_flag |= GP_BRUSH_USE_JITTER_PRESSURE;
@@ -432,12 +433,14 @@ void BKE_brush_gpencil_presets(bContext *C)
 	/* Marker brush */
 	brush = brush = BKE_brush_add_gpencil(bmain, ts, "Draw Marker");
 	brush->thickness = 80.0f;
-	brush->gp_flag |= (GP_BRUSH_USE_RANDOM_PRESSURE | GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR);
+	brush->gp_flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR);
 	brush->draw_sensitivity = 1.0f;
 
 	brush->draw_strength = 1.0f;
 
+	brush->gp_flag |= GP_BRUSH_GROUP_RANDOM;
 	brush->draw_random_press = 0.374f;
+	brush->draw_random_strength = 0.0f;
 
 	brush->draw_jitter = 0.0f;
 	brush->gp_flag |= GP_BRUSH_USE_JITTER_PRESSURE;
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 7975ebe3a9e..5785a5eb3a4 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -627,8 +627,7 @@ static short gp_stroke_addpoint(
 		}
 		/* apply randomness to pressure */
 		if ((brush->gp_flag & GP_BRUSH_GROUP_RANDOM) && 
-			(brush->draw_random_press > 0.0f) && 
-			(brush->gp_flag & GP_BRUSH_USE_RANDOM_PRESSURE)) 
+			(brush->draw_random_press > 0.0f)) 
 		{
 			float curvef = curvemapping_evaluateF(brush->cur_sensitivity, 0, pressure);
 			float tmp_pressure = curvef * brush->draw_sensitivity;
@@ -674,14 +673,13 @@ static short gp_stroke_addpoint(
 
 		/* apply randomness to color strength */
 		if ((brush->gp_flag & GP_BRUSH_GROUP_RANDOM) && 
-			(brush->draw_random_press > 0.0f) && 
-			(brush->gp_flag & GP_BRUSH_USE_RANDOM_STRENGTH)) 
+			(brush->draw_random_strength > 0.0f)) 
 		{
 			if (BLI_frand() > 0.5f) {
-				pt->strength -= pt->strength * brush->draw_random_press * BLI_frand();
+				pt->strength -= pt->strength * brush->draw_random_strength * BLI_frand();
 			}
 			else {
-				pt->strength += pt->strength * brush->draw_random_press * BLI_frand();
+				pt->strength += pt->strength * brush->draw_random_strength * BLI_frand();
 			}
 			CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f);
 		}
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index 533a08b1bb5..79071298449 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -154,8 +154,10 @@ typedef struct Brush {
 	float draw_jitter;        /* amount of jitter to apply to newly created strokes */
 	float draw_angle;         /* angle when the brush has full thickness */
 	float draw_angle_factor;  /* factor to apply when angle change (only 90 degrees) */
-	float draw_random_press;  /* factor of randomness for sensitivity and strength */
+	float draw_random_press;  /* factor of randomness for pressure */
+	float draw_random_strength;  /* factor of strength for strength */
 	float draw_random_sub;    /* factor of randomness for subdivision */
+	char pad2[4];
 
 	struct CurveMapping *cur_sensitivity;
 	struct CurveMapping *cur_strength;
@@ -193,10 +195,6 @@ typedef enum eGPDbrush_Flag {
 	GP_BRUSH_USE_STENGTH_PRESSURE = (1 << 1),
 	/* brush use pressure for alpha factor */
 	GP_BRUSH_USE_JITTER_PRESSURE = (1 << 2),
-	/* brush use random for pressure */
-	GP_BRUSH_USE_RANDOM_PRESSURE = (1 << 3),
-	/* brush use random for strength */
-	GP_BRUSH_USE_RANDOM_STRENGTH = (1 << 4),
 	/* enable screen cursor */
 	GP_BRUSH_ENABLE_CURSOR = (1 << 5),
 	/* fill hide transparent */
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 33cab129637..24333af45e1 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -1621,11 +1621,18 @@ static void rna_def_brush(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Jitter", "Jitter factor for new strokes");
 	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
 
-	/* Randomnes factor for sensitivity and strength */
-	prop = RNA_def_property(srna, "random_press", PROP_FLOAT, PROP_NONE);
+	/* Randomnes factor for pressure */
+	prop = RNA_def_property(srna, "random_pressure", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "draw_random_press");
 	RNA_def_property_range(prop, 0.0f, 1.0f);
-	RNA_def_property_ui_text(prop, "Randomness", "Randomness factor for pressure and strength in new strokes");
+	RNA_def_property_ui_text(prop, "Pressure Randomness", "Randomness factor for pressure in new strokes");
+	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
+	/* Randomnes factor for strength */
+	prop = RNA_def_property(srna, "random_strength", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "draw_random_strength");
+	RNA_def_property_range(prop, 0.0f, 1.0f);
+	RNA_def_property_ui_text(prop, "Strength Randomness", "Randomness factor strength in new strokes");
 	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
 
 	/* Randomnes factor for subdivision */
@@ -1792,18 +1799,6 @@ static void rna_def_brush(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Use Pressure Jitter", "Use tablet pressure for jitter");
 	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
 
-	prop = RNA_def_property(srna, "use_random_pressure", PROP_BOOLEAN, PROP_NONE);
-	RNA_def_property_boolean_sdna(prop, NULL, "gp_flag", GP_BRUSH_USE_RANDOM_PRESSURE);
-	RNA_def_property_ui_icon(prop, ICON_PARTICLES, 0);
-	RNA_def_property_ui_text(prop, "Random Pressure", "Use random value for pressure");
-	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
-
-	prop = RNA_def_property(srna, "use_random_strength", PROP_BOOLEAN, PROP_NONE);
-	RNA_def_property_boolean_sdna(prop, NULL, "gp_flag", GP_BRUSH_USE_RANDOM_STRENGTH);
-	RNA_def_property_ui_icon(prop, ICON_PARTICLES, 0);
-	RNA_def_property_ui_text(prop, "Random Strength", "Use random value for strength");
-	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
-
 	prop = RNA_def_property(srna, "use_stabilizer", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "gp_flag", GP_BRUSH_STABILIZE_MOUSE);
 	RNA_def_property_boolean_default(prop, true);



More information about the Bf-blender-cvs mailing list