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:
-rw-r--r--release/scripts/startup/bl_ui/properties_paint_common.py4
-rw-r--r--release/scripts/startup/bl_ui/space_userpref.py1
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c12
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c26
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h7
-rw-r--r--source/blender/makesdna/DNA_brush_types.h4
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h4
-rw-r--r--source/blender/makesrna/intern/rna_brush.c33
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c5
9 files changed, 94 insertions, 2 deletions
diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index e18651d8e8a..ca93f79df04 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -547,6 +547,10 @@ def brush_settings(layout, context, brush, popover=False):
# normal_radius_factor
layout.prop(brush, "normal_radius_factor", slider=True)
+ if context.preferences.experimental.use_sculpt_tools_tilt and capabilities.has_tilt:
+ layout.prop(brush, "tilt_strength_factor", slider=True)
+
+
row = layout.row(align=True)
row.prop(brush, "hardness", slider=True)
row.prop(brush, "invert_hardness_pressure", text="")
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 576e56c929f..604ec302b60 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -2187,6 +2187,7 @@ class USERPREF_PT_experimental_new_features(ExperimentalPanel, Panel):
({"property": "use_sculpt_vertex_colors"}, "T71947"),
({"property": "use_tools_missing_icons"}, "T80331"),
({"property": "use_switch_object_operator"}, "T80402"),
+ ({"property": "use_sculpt_tools_tilt"}, "T00000"),
),
)
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
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index c4c9db69dcd..6e99edcf682 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -2784,6 +2784,20 @@ static void calc_brush_local_mat(const Brush *brush, Object *ob, float local_mat
invert_m4_m4(local_mat, tmat);
}
+#define SCULPT_TILT_SENSITIVITY 0.7f
+void SCULPT_tilt_apply_to_normal(float r_normal[3], StrokeCache *cache, const float tilt_strength)
+{
+ if (!U.experimental.use_sculpt_tools_tilt) {
+ return;
+ }
+ const float rot_max = M_PI_2 * tilt_strength * SCULPT_TILT_SENSITIVITY;
+ mul_v3_mat3_m4v3(r_normal, cache->vc->obact->obmat, r_normal);
+ rotate_v3_v3v3fl(r_normal, r_normal, cache->vc->rv3d->viewinv[0], cache->y_tilt * rot_max);
+ rotate_v3_v3v3fl(r_normal, r_normal, cache->vc->rv3d->viewinv[1], cache->x_tilt * rot_max);
+ mul_v3_mat3_m4v3(r_normal, cache->vc->obact->imat, r_normal);
+ normalize_v3(r_normal);
+}
+
static void update_brush_local_mat(Sculpt *sd, Object *ob)
{
StrokeCache *cache = ob->sculpt->cache;
@@ -3094,6 +3108,7 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
/* Offset with as much as possible factored in already. */
mul_v3_v3fl(offset, ss->cache->sculpt_normal_symm, ss->cache->radius);
+ SCULPT_tilt_apply_to_normal(offset, ss->cache, brush->tilt_strength_factor);
mul_v3_v3(offset, ss->cache->scale);
mul_v3_fl(offset, bstrength);
@@ -3171,6 +3186,7 @@ static void do_draw_sharp_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
/* Offset with as much as possible factored in already. */
mul_v3_v3fl(offset, ss->cache->sculpt_normal_symm, ss->cache->radius);
+ SCULPT_tilt_apply_to_normal(offset, ss->cache, brush->tilt_strength_factor);
mul_v3_v3(offset, ss->cache->scale);
mul_v3_fl(offset, bstrength);
@@ -4693,6 +4709,8 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno
SCULPT_calc_brush_plane(sd, ob, nodes, totnode, area_no, area_co);
+ SCULPT_tilt_apply_to_normal(area_no, ss->cache, brush->tilt_strength_factor);
+
displace = radius * offset;
mul_v3_v3v3(temp, area_no, ss->cache->scale);
@@ -4977,6 +4995,7 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t
float tmat[4][4];
SCULPT_calc_brush_plane(sd, ob, nodes, totnode, area_no_sp, area_co);
+ SCULPT_tilt_apply_to_normal(area_no_sp, ss->cache, brush->tilt_strength_factor);
if (brush->sculpt_plane != SCULPT_DISP_DIR_AREA || (brush->flag & BRUSH_ORIGINAL_NORMAL)) {
SCULPT_calc_area_normal(sd, ob, nodes, totnode, area_no);
@@ -5120,6 +5139,8 @@ static void do_fill_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
SCULPT_calc_brush_plane(sd, ob, nodes, totnode, area_no, area_co);
+ SCULPT_tilt_apply_to_normal(area_no, ss->cache, brush->tilt_strength_factor);
+
displace = radius * offset;
mul_v3_v3v3(temp, area_no, ss->cache->scale);
@@ -5213,6 +5234,8 @@ static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
SCULPT_calc_brush_plane(sd, ob, nodes, totnode, area_no, area_co);
+ SCULPT_tilt_apply_to_normal(area_no, ss->cache, brush->tilt_strength_factor);
+
displace = -radius * offset;
mul_v3_v3v3(temp, area_no, ss->cache->scale);
@@ -6935,6 +6958,9 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, Po
cache->pressure = RNA_float_get(ptr, "pressure");
}
+ cache->x_tilt = RNA_float_get(ptr, "x_tilt");
+ cache->y_tilt = RNA_float_get(ptr, "y_tilt");
+
/* Truly temporary data that isn't stored in properties. */
if (SCULPT_stroke_is_first_brush_step_of_symmetry_pass(ss->cache)) {
if (!BKE_brush_use_locked_size(scene, brush)) {
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 41982a441ad..6cdaafb548c 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -799,6 +799,11 @@ float SCULPT_brush_strength_factor(struct SculptSession *ss,
const int vertex_index,
const int thread_id);
+/* Tilts a normal by the x and y tilt values using the view axis. */
+void SCULPT_tilt_apply_to_normal(float r_normal[3],
+ struct StrokeCache *cache,
+ const float tilt_strength);
+
/* just for vertex paint. */
bool SCULPT_pbvh_calc_area_normal(const struct Brush *brush,
Object *ob,
@@ -852,6 +857,8 @@ typedef struct StrokeCache {
float mouse[2];
float bstrength;
float normal_weight; /* from brush (with optional override) */
+ float x_tilt;
+ float y_tilt;
float (*prev_colors)[4];
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index 3acdbbb79fa..8437d782e98 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -568,10 +568,12 @@ typedef struct Brush {
char gpencil_sculpt_tool;
/** Active grease pencil weight tool. */
char gpencil_weight_tool;
- char _pad1[2];
+ char _pad1[6];
float autosmooth_factor;
+ float tilt_strength_factor;
+
float topology_rake_factor;
float crease_pinch_factor;
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index a20d939694d..954da51e3bf 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -635,7 +635,9 @@ typedef struct UserDef_Experimental {
char use_sculpt_vertex_colors;
char use_tools_missing_icons;
char use_switch_object_operator;
- char _pad[7];
+ char use_sculpt_tools_tilt;
+ char _pad[6];
+ /** `makesdna` does not allow empty structs. */
} UserDef_Experimental;
#define USER_EXPERIMENTAL_TEST(userdef, member) \
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 70d613f8b21..eed278c3980 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -557,6 +557,19 @@ static bool rna_BrushCapabilitiesSculpt_has_gravity_get(PointerRNA *ptr)
return !ELEM(br->sculpt_tool, SCULPT_TOOL_MASK, SCULPT_TOOL_SMOOTH);
}
+static bool rna_BrushCapabilitiesSculpt_has_tilt_get(PointerRNA *ptr)
+{
+ Brush *br = (Brush *)ptr->data;
+ return ELEM(br->sculpt_tool,
+ SCULPT_TOOL_DRAW,
+ SCULPT_TOOL_DRAW_SHARP,
+ SCULPT_TOOL_FLATTEN,
+ SCULPT_TOOL_FILL,
+ SCULPT_TOOL_SCRAPE,
+ SCULPT_TOOL_CLAY_STRIPS,
+ SCULPT_TOOL_CLAY_THUMB);
+}
+
static bool rna_TextureCapabilities_has_texture_angle_source_get(PointerRNA *ptr)
{
MTex *mtex = (MTex *)ptr->data;
@@ -1137,6 +1150,7 @@ static void rna_def_sculpt_capabilities(BlenderRNA *brna)
SCULPT_TOOL_CAPABILITY(has_strength_pressure, "Has Strength Pressure");
SCULPT_TOOL_CAPABILITY(has_direction, "Has Direction");
SCULPT_TOOL_CAPABILITY(has_gravity, "Has Gravity");
+ SCULPT_TOOL_CAPABILITY(has_tilt, "Has Tilt");
# undef SCULPT_CAPABILITY
}
@@ -2796,6 +2810,15 @@ static void rna_def_brush(BlenderRNA *brna)
"Best used on low-poly meshes as it has a performance impact");
RNA_def_property_update(prop, 0, "rna_Brush_update");
+ prop = RNA_def_property(srna, "tilt_strength_factor", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "tilt_strength_factor");
+ RNA_def_property_float_default(prop, 0);
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 3);
+ RNA_def_property_ui_text(
+ prop, "Tilt Strength", "How much the tilt of the pen will affect the brush");
+ RNA_def_property_update(prop, 0, "rna_Brush_update");
+
prop = RNA_def_property(srna, "normal_radius_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "normal_radius_factor");
RNA_def_property_range(prop, 0.0f, 2.0f);
@@ -3417,6 +3440,16 @@ static void rna_def_operator_stroke_element(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_IDPROPERTY);
RNA_def_property_ui_text(prop, "Flip", "");
+ prop = RNA_def_property(srna, "x_tilt", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_flag(prop, PROP_IDPROPERTY);
+ RNA_def_property_range(prop, -1.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Tilt X", "");
+
+ prop = RNA_def_property(srna, "y_tilt", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_flag(prop, PROP_IDPROPERTY);
+ RNA_def_property_range(prop, -1.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Tilt Y", "");
+
/* used in uv painting */
prop = RNA_def_property(srna, "time", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_flag(prop, PROP_IDPROPERTY);
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 633611b9e50..6698e0ff237 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -6178,6 +6178,11 @@ static void rna_def_userdef_experimental(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_tools_missing_icons", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "use_tools_missing_icons", 1);
RNA_def_property_ui_text(prop, "Tools with Missing Icons", "Show tools with missing icons");
+
+ prop = RNA_def_property(srna, "use_sculpt_tools_tilt", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "use_sculpt_tools_tilt", 1);
+ RNA_def_property_ui_text(
+ prop, "Sculpt Mode Tilt Support", "Support for pen tablet tilt events in Sculpt Mode");
}
static void rna_def_userdef_addon_collection(BlenderRNA *brna, PropertyRNA *cprop)