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/makesrna/intern/rna_brush.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/makesrna/intern/rna_brush.c')
-rw-r--r--source/blender/makesrna/intern/rna_brush.c33
1 files changed, 33 insertions, 0 deletions
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);