[Bf-blender-cvs] [1d0a157614f] greasepencil-object: GPencil: Fix tablet errors after merge
Antonio Vazquez
noreply at git.blender.org
Sun Feb 2 22:21:40 CET 2020
Commit: 1d0a157614f47176e7a96c60ae1105e22354c5df
Author: Antonio Vazquez
Date: Sun Feb 2 22:06:48 2020 +0100
Branches: greasepencil-object
https://developer.blender.org/rB1d0a157614f47176e7a96c60ae1105e22354c5df
GPencil: Fix tablet errors after merge
===================================================================
M source/blender/editors/gpencil/gpencil_vertex_paint.c
M source/blender/editors/gpencil/gpencil_weight_paint.c
===================================================================
diff --git a/source/blender/editors/gpencil/gpencil_vertex_paint.c b/source/blender/editors/gpencil/gpencil_vertex_paint.c
index 028412799fb..a9fc9513b15 100644
--- a/source/blender/editors/gpencil/gpencil_vertex_paint.c
+++ b/source/blender/editors/gpencil/gpencil_vertex_paint.c
@@ -1189,7 +1189,6 @@ static void gp_vertexpaint_brush_apply_event(bContext *C, wmOperator *op, const
tGP_BrushVertexpaintData *gso = op->customdata;
PointerRNA itemptr;
float mouse[2];
- int tablet = 0;
mouse[0] = event->mval[0] + 1;
mouse[1] = event->mval[1] + 1;
@@ -1201,24 +1200,10 @@ static void gp_vertexpaint_brush_apply_event(bContext *C, wmOperator *op, const
RNA_boolean_set(&itemptr, "pen_flip", event->ctrl != false);
RNA_boolean_set(&itemptr, "is_start", gso->first);
- /* handle pressure sensitivity (which is supplied by tablets) */
- if (event->tablet_data) {
- const wmTabletData *wmtab = event->tablet_data;
- float pressure = wmtab->Pressure;
-
- tablet = (wmtab->Active != EVT_TABLET_NONE);
-
- /* special exception here for too high pressure values on first touch in
- * windows for some tablets: clamp the values to be sane
- */
- if (tablet && (pressure >= 0.99f)) {
- pressure = 1.0f;
- }
- RNA_float_set(&itemptr, "pressure", pressure);
- }
- else {
- RNA_float_set(&itemptr, "pressure", 1.0f);
- }
+ /* Handle pressure sensitivity (which is supplied by tablets). */
+ float pressure = event->tablet.pressure;
+ CLAMP(pressure, 0.0f, 1.0f);
+ RNA_float_set(&itemptr, "pressure", pressure);
/* apply */
gp_vertexpaint_brush_apply(C, op, &itemptr);
diff --git a/source/blender/editors/gpencil/gpencil_weight_paint.c b/source/blender/editors/gpencil/gpencil_weight_paint.c
index 1ca73f075a2..8a07af5c6f4 100644
--- a/source/blender/editors/gpencil/gpencil_weight_paint.c
+++ b/source/blender/editors/gpencil/gpencil_weight_paint.c
@@ -735,7 +735,6 @@ static void gp_weightpaint_brush_apply_event(bContext *C, wmOperator *op, const
tGP_BrushWeightpaintData *gso = op->customdata;
PointerRNA itemptr;
float mouse[2];
- int tablet = 0;
mouse[0] = event->mval[0] + 1;
mouse[1] = event->mval[1] + 1;
@@ -747,24 +746,10 @@ static void gp_weightpaint_brush_apply_event(bContext *C, wmOperator *op, const
RNA_boolean_set(&itemptr, "pen_flip", event->ctrl != false);
RNA_boolean_set(&itemptr, "is_start", gso->first);
- /* handle pressure sensitivity (which is supplied by tablets) */
- if (event->tablet_data) {
- const wmTabletData *wmtab = event->tablet_data;
- float pressure = wmtab->Pressure;
-
- tablet = (wmtab->Active != EVT_TABLET_NONE);
-
- /* special exception here for too high pressure values on first touch in
- * windows for some tablets: clamp the values to be sane
- */
- if (tablet && (pressure >= 0.99f)) {
- pressure = 1.0f;
- }
- RNA_float_set(&itemptr, "pressure", pressure);
- }
- else {
- RNA_float_set(&itemptr, "pressure", 1.0f);
- }
+ /* Handle pressure sensitivity (which is supplied by tablets). */
+ float pressure = event->tablet.pressure;
+ CLAMP(pressure, 0.0f, 1.0f);
+ RNA_float_set(&itemptr, "pressure", pressure);
/* apply */
gp_weightpaint_brush_apply(C, op, &itemptr);
More information about the Bf-blender-cvs
mailing list