Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2020-01-10 18:54:17 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2020-01-21 14:22:24 +0300
commitca4e8b423e81f2a72cd5409d1c2c0450e12afc78 (patch)
treef6bcd8f872cb0e9845ef1efc7973ee62ca7d5713 /source/blender/editors/gpencil/gpencil_paint.c
parentf10d190240a135f4e26058eb49a787f9178ceb71 (diff)
Cleanup: simplify wmEvent tablet data storage and naming
Removing meaningless distinction between NULL pointer and EVT_TABLET_NONE, and initialize pressure and tilt to 1.0 and 0.0 respectively when no tablet is used.
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_paint.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c41
1 files changed, 13 insertions, 28 deletions
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 6a91417e7f3..09ff24f05fc 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -2553,12 +2553,7 @@ static void gpencil_draw_toggle_eraser_cursor(bContext *C, tGPsdata *p, short en
/* Check if tablet eraser is being used (when processing events) */
static bool gpencil_is_tablet_eraser_active(const wmEvent *event)
{
- if (event->tablet_data) {
- const wmTabletData *wmtab = event->tablet_data;
- return (wmtab->Active == EVT_TABLET_ERASER);
- }
-
- return false;
+ return (event->tablet.active == EVT_TABLET_ERASER);
}
/* ------------------------------- */
@@ -3020,7 +3015,6 @@ static void gpencil_draw_apply_event(bContext *C,
GP_Sculpt_Guide *guide = &p->scene->toolsettings->gp_sculpt.guide;
PointerRNA itemptr;
float mousef[2];
- int tablet = 0;
bool is_speed_guide = ((guide->use_guide) &&
(p->brush && (p->brush->gpencil_tool == GPAINT_TOOL_DRAW)));
@@ -3055,29 +3049,20 @@ static void gpencil_draw_apply_event(bContext *C,
p->curtime = PIL_check_seconds_timer();
- /* handle pressure sensitivity (which is supplied by tablets) */
- if (event->tablet_data) {
- const wmTabletData *wmtab = event->tablet_data;
+ /* handle pressure sensitivity (which is supplied by tablets or otherwise 1.0) */
+ p->pressure = event->tablet.pressure;
- tablet = (wmtab->Active != EVT_TABLET_NONE);
- p->pressure = wmtab->Pressure;
-
- /* Hack for pressure sensitive eraser on D+RMB when using a tablet:
- * The pen has to float over the tablet surface, resulting in
- * zero pressure (T47101). Ignore pressure values if floating
- * (i.e. "effectively zero" pressure), and only when the "active"
- * end is the stylus (i.e. the default when not eraser)
- */
- if (p->paintmode == GP_PAINTMODE_ERASER) {
- if ((wmtab->Active != EVT_TABLET_ERASER) && (p->pressure < 0.001f)) {
- p->pressure = 1.0f;
- }
+ /* Hack for pressure sensitive eraser on D+RMB when using a tablet:
+ * The pen has to float over the tablet surface, resulting in
+ * zero pressure (T47101). Ignore pressure values if floating
+ * (i.e. "effectively zero" pressure), and only when the "active"
+ * end is the stylus (i.e. the default when not eraser)
+ */
+ if (p->paintmode == GP_PAINTMODE_ERASER) {
+ if ((event->tablet.active != EVT_TABLET_ERASER) && (p->pressure < 0.001f)) {
+ p->pressure = 1.0f;
}
}
- else {
- /* No tablet data -> No pressure info is available */
- p->pressure = 1.0f;
- }
/* special eraser modes */
if (p->paintmode == GP_PAINTMODE_ERASER) {
@@ -3101,7 +3086,7 @@ static void gpencil_draw_apply_event(bContext *C,
/* special exception here for too high pressure values on first touch in
* windows for some tablets, then we just skip first touch...
*/
- if (tablet && (p->pressure >= 0.99f)) {
+ if ((event->tablet.active != EVT_TABLET_NONE) && (p->pressure >= 0.99f)) {
return;
}