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:
authorAlexander Gavrilov <angavrilov@gmail.com>2018-11-20 15:35:59 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2018-11-21 16:34:07 +0300
commit539b465b32102d90a6d356d8f94300e70338856e (patch)
treeafffb5a179ea2530033ff1eaeaa93a049d5e90d1 /source/blender/windowmanager
parentb93c81e0023624f62695b082e7e35a2b8c7b3b5a (diff)
Implement basic global tablet pressure curve options.
Grease Pencil already implements support for full-featured per-brush pressure curves, but it is useful to have some basic global settings that affect all brushes and tools. This adds two simple options: - Raw pressure required to achieve full brush intensity. - Softness control, using a gamma curve internally. The most important one is the max pressure setting, because it is critical for ergonomics, but the Linux Wacom driver lacks it. The softness option internally converts to gamma = 4^-softness. Reviewers: brecht, campbellbarton Differential Revision: https://developer.blender.org/D3967
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c18
-rw-r--r--source/blender/windowmanager/intern/wm_window.c2
-rw-r--r--source/blender/windowmanager/wm_event_system.h2
3 files changed, 20 insertions, 2 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index f82df000288..03a80ff240b 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -3662,6 +3662,22 @@ static void wm_eventemulation(wmEvent *event)
}
}
+/* applies the global tablet pressure correction curve */
+float wm_pressure_curve(float pressure)
+{
+ if (U.pressure_threshold_max != 0.0f) {
+ pressure /= U.pressure_threshold_max;
+ }
+
+ CLAMP(pressure, 0.0f, 1.0f);
+
+ if (U.pressure_softness != 0.0f) {
+ pressure = powf(pressure, powf(4.0f, -U.pressure_softness));
+ }
+
+ return pressure;
+}
+
/* adds customdata to event */
static void update_tablet_data(wmWindow *win, wmEvent *event)
{
@@ -3672,7 +3688,7 @@ static void update_tablet_data(wmWindow *win, wmEvent *event)
struct wmTabletData *wmtab = MEM_mallocN(sizeof(wmTabletData), "customdata tablet");
wmtab->Active = (int)td->Active;
- wmtab->Pressure = td->Pressure;
+ wmtab->Pressure = wm_pressure_curve(td->Pressure);
wmtab->Xtilt = td->Xtilt;
wmtab->Ytilt = td->Ytilt;
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index b84b851476a..df20dbd8055 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -2014,7 +2014,7 @@ float WM_cursor_pressure(const struct wmWindow *win)
const GHOST_TabletData *td = GHOST_GetTabletData(win->ghostwin);
/* if there's tablet data from an active tablet device then add it */
if ((td != NULL) && td->Active != GHOST_kTabletModeNone) {
- return td->Pressure;
+ return wm_pressure_curve(td->Pressure);
}
else {
return -1.0f;
diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h
index a0610ffcff3..fe28cbf9895 100644
--- a/source/blender/windowmanager/wm_event_system.h
+++ b/source/blender/windowmanager/wm_event_system.h
@@ -101,6 +101,8 @@ void wm_event_do_depsgraph(bContext *C);
void wm_event_do_refresh_wm_and_depsgraph(bContext *C);
void wm_event_do_notifiers(bContext *C);
+float wm_pressure_curve(float raw_pressure);
+
/* wm_keymap.c */
/* wm_dropbox.c */