diff options
author | Hans Goudey <h.goudey@me.com> | 2022-05-23 10:44:12 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-05-23 10:44:12 +0300 |
commit | 8f3847aef3f21d9c2cc549c783ea2ce708ec3161 (patch) | |
tree | c5da9af3865a4d90c1466c47e0f3787edb2e4d3a /source/blender/editors/sculpt_paint/curves_sculpt_ops.cc | |
parent | f93b2371942b3da34a9e827b163e2324e254c625 (diff) |
Fix: Sample pressure properly for 3D curves sculpt brushes
For the "Sphere" 3D brushes, the depth and radius are only sampled at
the beginning of the stroke. This didn't work when tablet pressure is
used as a factor for the brush radius. Now the 3D brush depth is found
with the max radius (as if the pressure was 1.0), but the pressure
factor is used afterwards.
Restructuring the way the brush executors stored the radius made
the change a bit clearer, which is where most of the diff comes from.
Differential Revision: https://developer.blender.org/D15002
Diffstat (limited to 'source/blender/editors/sculpt_paint/curves_sculpt_ops.cc')
-rw-r--r-- | source/blender/editors/sculpt_paint/curves_sculpt_ops.cc | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc index 66e67bd0d06..15d0f73592d 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc @@ -74,26 +74,34 @@ using blender::bke::CurvesGeometry; /** \name * SCULPT_CURVES_OT_brush_stroke * \{ */ +float brush_radius_factor(const Brush &brush, const StrokeExtension &stroke_extension) +{ + if (BKE_brush_use_size_pressure(&brush)) { + return stroke_extension.pressure; + } + return 1.0f; +} + 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 BKE_brush_size_get(&scene, &brush) * brush_radius_factor(brush, stroke_extension); +} + +float brush_strength_factor(const Brush &brush, const StrokeExtension &stroke_extension) +{ + if (BKE_brush_use_alpha_pressure(&brush)) { + return stroke_extension.pressure; } - return initial_radius; + return 1.0f; } 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; + return BKE_brush_alpha_get(&scene, &brush) * brush_strength_factor(brush, stroke_extension); } static std::unique_ptr<CurvesSculptStrokeOperation> start_brush_operation(bContext &C, |