[Bf-blender-cvs] [5819ab66fab] greasepencil-object: WIP: Check minimum tablet pressure
Antonio Vazquez
noreply at git.blender.org
Mon Nov 13 16:45:41 CET 2017
Commit: 5819ab66fabbb86fed31dff6417401ae9ee2b254
Author: Antonio Vazquez
Date: Mon Nov 13 16:45:33 2017 +0100
Branches: greasepencil-object
https://developer.blender.org/rB5819ab66fabbb86fed31dff6417401ae9ee2b254
WIP: Check minimum tablet pressure
In some tablets when the user ends the stroke the tablet send several events with a pressure of 0 or with very low values. These low pressure values produce weird lines at the end of the stroke.
===================================================================
M release/scripts/startup/bl_ui/properties_grease_pencil_common.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/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index d45c42f0f05..df125cc2ec7 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -417,7 +417,11 @@ class GreasePencilBrushOptionsPanel:
col.label(text="Stroke Quality:")
col.prop(brush, "pen_smooth_factor")
col.prop(brush, "pen_smooth_steps")
- col.prop(brush, "pen_stabilize_factor")
+
+ row = col.row(align=True)
+ row.prop(brush, "pen_stabilize_factor")
+ row.prop(brush, "pen_pressure_threshold")
+
row = col.row(align=True)
row.prop(brush, "pen_density")
row.prop(brush, "pen_noise_factor")
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index b44a88da903..ea3042dcc01 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -279,11 +279,15 @@ static bool gp_stroke_filtermval(tGPsdata *p, const int mval[2], int pmval[2])
{
int dx = abs(mval[0] - pmval[0]);
int dy = abs(mval[1] - pmval[1]);
-
+
+ /* check a minimum amount of pressure (some tablets send very low values at the end of stroke) */
+ if (p->pressure < p->brush->draw_threshold)
+ return false;
+
/* if buffer is empty, just let this go through (i.e. so that dots will work) */
if (p->gpd->sbuffer_size == 0)
return true;
-
+
/* check if mouse moved at least certain distance on both axes (best case)
* - aims to eliminate some jitter-noise from input when trying to draw straight lines freehand
*/
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index 0d9111cee0e..972ec658c63 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -130,6 +130,8 @@ typedef struct bGPDbrush {
float draw_stabangle; /* factor to determine if the point is noise or not */
float draw_thicknesfac; /* factor to smooth thickness */
float draw_strengthfac; /* factor to smooth strength (alpha) */
+ float draw_threshold; /* minimum pressure to consider is drawing */
+ char pad[4];
} bGPDbrush;
/* bGPDbrush->flag */
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 59a4d09e4a1..0d37af14875 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2367,6 +2367,15 @@ static void rna_def_gpencil_brush(BlenderRNA *brna)
"Amount of smoothing while drawing for strength");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+ /* Minimum amount of pressure in tablets while drawing */
+ prop = RNA_def_property(srna, "pen_pressure_threshold", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "draw_threshold");
+ RNA_def_property_range(prop, 0.0, 1.0f);
+ RNA_def_property_float_default(prop, 0.0f);
+ RNA_def_property_ui_text(prop, "Threshold",
+ "Minimum tablet pressure to consider the pencil is drawing");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
/* Subdivision level for new strokes */
prop = RNA_def_property(srna, "pen_subdivision_steps", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "sublevel");
More information about the Bf-blender-cvs
mailing list