From a489d77c5be4e2f1e7e1fac3a3271bb7bca293af Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Sun, 1 Mar 2020 19:31:28 +0100 Subject: 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 --- source/blender/editors/sculpt_paint/paint_stroke.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source') 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); -- cgit v1.2.3