[Bf-blender-cvs] [a489d77c5be] master: Fix T74074: Strokes with timer events don't get pressure values

Pablo Dobarro noreply at git.blender.org
Sun Mar 1 19:32:30 CET 2020


Commit: a489d77c5be4e2f1e7e1fac3a3271bb7bca293af
Author: Pablo Dobarro
Date:   Sun Mar 1 19:31:28 2020 +0100
Branches: master
https://developer.blender.org/rBa489d77c5be4e2f1e7e1fac3a3271bb7bca293af

Fix T74074: Strokes with timer events don't get pressure values

When processing a timer event WM_event_tablet_data returns 0 instead of
the last valid pressure value from the tablet. This always stores the
last pressure value and uses it in case a timer event is being
processed.

Reviewed By: brecht

Maniphest Tasks: T74074

Differential Revision: https://developer.blender.org/D6950

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

M	source/blender/editors/sculpt_paint/paint_stroke.c

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

diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 4abeb937758..2fb89a49016 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -118,6 +118,8 @@ typedef struct PaintStroke {
   float last_pressure;
   int stroke_mode;
 
+  float last_tablet_event_pressure;
+
   float zoom_2d;
   int pen_flip;
 
@@ -1355,6 +1357,15 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
                   1.0f :
                   WM_event_tablet_data(event, &stroke->pen_flip, NULL));
 
+  /* When processing a timer event the pressure from the event is 0, so use the last valid
+   * pressure. */
+  if (event->type == TIMER) {
+    pressure = stroke->last_tablet_event_pressure;
+  }
+  else {
+    stroke->last_tablet_event_pressure = pressure;
+  }
+
   paint_stroke_add_sample(p, stroke, event->mval[0], event->mval[1], pressure);
   paint_stroke_sample_average(stroke, &sample_average);



More information about the Bf-blender-cvs mailing list