[Bf-blender-cvs] [7f8e1e16690] greasepencil-refactor: GPencil: Fix tablet code error after merge

Antonio Vazquez noreply at git.blender.org
Tue Jan 21 19:30:08 CET 2020


Commit: 7f8e1e1669053000cb53e7f0db82b8b87fc20a57
Author: Antonio Vazquez
Date:   Tue Jan 21 19:30:01 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB7f8e1e1669053000cb53e7f0db82b8b87fc20a57

GPencil: Fix tablet code error 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 c3c716772fd..505429b9850 100644
--- a/source/blender/editors/gpencil/gpencil_vertex_paint.c
+++ b/source/blender/editors/gpencil/gpencil_vertex_paint.c
@@ -1191,7 +1191,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;
@@ -1203,24 +1202,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 b3379073240..05d59c08cc6 100644
--- a/source/blender/editors/gpencil/gpencil_weight_paint.c
+++ b/source/blender/editors/gpencil/gpencil_weight_paint.c
@@ -730,7 +730,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;
@@ -742,24 +741,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