diff options
author | Hans Goudey <h.goudey@me.com> | 2022-05-20 14:33:42 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-05-20 14:33:42 +0300 |
commit | cea37b3127636ac02e65c050513a3060ac6800ab (patch) | |
tree | 9575ce6ae89756902bb86ead7324c3c871f41ceb /source/blender/editors/sculpt_paint/curves_sculpt_ops.cc | |
parent | a89f829f12f56214b0e463b33f24edf27228db1f (diff) |
Curves: Support pressure in sculpt brushes
Multiply the radius and strength of sculpt brushes by the pressure
when "use pressure" is turned on. The brush system isn't responsible
for this, so the pressure needs to be stored in `StrokeExtension`.
Differential Revision: https://developer.blender.org/D14996
Diffstat (limited to 'source/blender/editors/sculpt_paint/curves_sculpt_ops.cc')
-rw-r--r-- | source/blender/editors/sculpt_paint/curves_sculpt_ops.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc index 776da37205c..66e67bd0d06 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc @@ -74,6 +74,28 @@ using blender::bke::CurvesGeometry; /** \name * SCULPT_CURVES_OT_brush_stroke * \{ */ +float brush_radius_get(const Scene &scene, + const Brush &brush, + const StrokeExtension &stroke_extension) +{ + const float initial_radius = BKE_brush_size_get(&scene, &brush); + if (BKE_brush_use_size_pressure(&brush)) { + return initial_radius * stroke_extension.pressure; + } + return initial_radius; +} + +float brush_strength_get(const Scene &scene, + const Brush &brush, + const StrokeExtension &stroke_extension) +{ + const float initial_radius = BKE_brush_alpha_get(&scene, &brush); + if (BKE_brush_use_alpha_pressure(&brush)) { + return initial_radius * stroke_extension.pressure; + } + return initial_radius; +} + static std::unique_ptr<CurvesSculptStrokeOperation> start_brush_operation(bContext &C, wmOperator &op) { @@ -128,6 +150,7 @@ static void stroke_update_step(bContext *C, StrokeExtension stroke_extension; RNA_float_get_array(stroke_element, "mouse", stroke_extension.mouse_position); + stroke_extension.pressure = RNA_float_get(stroke_element, "pressure"); if (!op_data->operation) { stroke_extension.is_first = true; |