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:
authorPablo Dobarro <pablodp606>2020-10-08 01:00:36 +0300
committerPablo Dobarro <pablodp606@gmail.com>2020-10-15 20:00:51 +0300
commit0d5ec990a9844e639fa6ab989b14b2e051ac8c42 (patch)
tree4130069e315263bcef6d66f2939c02fea13a6550 /source/blender/editors/sculpt_paint/paint_stroke.c
parent6dda0779fcdef704a17ed3c0150073f77534d5e5 (diff)
Sculpt: Experimental Pen Tilt Support
This adds support for pen tilt in sculpt mode. For now, pen tilt is used by tweaking the tilt strength property, which controls how much the pen angle affects the sculpt normal. This is available in Draw, Draw Sharp, Flatten, Fill, Scrape and Clay Strips brushes, but it can be enabled in more tools later. The purpose of this patch is to have a usable implementation of pen tilt in a painting mode, so users can test and see in which hardware and platforms this feature is supported and how well it works. If it works ok, more tools and features that rely on pen tilt can be implemented, like brushes that blend between two deformations depending on the angle. Reviewed By: sergey Differential Revision: https://developer.blender.org/D8893
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_stroke.c')
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 21b33a4e2ab..da0a8dbd4b8 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -123,6 +123,10 @@ typedef struct PaintStroke {
float zoom_2d;
int pen_flip;
+ /* Tilt, as read from the event. */
+ float x_tilt;
+ float y_tilt;
+
/* line constraint */
bool constrain_line;
float constrained_pos[2];
@@ -620,6 +624,8 @@ static void paint_brush_stroke_add_step(bContext *C,
RNA_float_set_array(&itemptr, "mouse", mouse_out);
RNA_boolean_set(&itemptr, "pen_flip", stroke->pen_flip);
RNA_float_set(&itemptr, "pressure", pressure);
+ RNA_float_set(&itemptr, "x_tilt", stroke->x_tilt);
+ RNA_float_set(&itemptr, "y_tilt", stroke->y_tilt);
stroke->update_step(C, stroke, &itemptr);
@@ -1383,6 +1389,12 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
paint_stroke_add_sample(p, stroke, event->mval[0], event->mval[1], pressure);
paint_stroke_sample_average(stroke, &sample_average);
+ /* Tilt. */
+ if (WM_event_is_tablet(event)) {
+ stroke->x_tilt = event->tablet.x_tilt;
+ stroke->y_tilt = event->tablet.y_tilt;
+ }
+
#ifdef WITH_INPUT_NDOF
/* let NDOF motion pass through to the 3D view so we can paint and rotate simultaneously!
* this isn't perfect... even when an extra MOUSEMOVE is spoofed, the stroke discards it