From fd3d9f2fa2b55df971ec004e276a4690a18f95ab Mon Sep 17 00:00:00 2001 From: Sean Kim Date: Thu, 16 Oct 2025 22:43:32 +0200 Subject: [PATCH] Fix #148064: Crash when using grease pencil fill tool The recently introduced size, strength, and jitter pressure curves affect most paint code. This exposed further odd behavior inside `paint_brush_update` where the size pressure curve was being evaluated even if the brush's size did not vary with pressure. To fix this issue, this commit clarifies a few comments and updates the code flow such that cached input values and evaluated pressure values are used more consistently. Pull Request: https://projects.blender.org/blender/blender/pulls/148077 --- source/blender/blenkernel/BKE_paint_types.hh | 2 +- .../blender/editors/sculpt_paint/paint_stroke.cc | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/source/blender/blenkernel/BKE_paint_types.hh b/source/blender/blenkernel/BKE_paint_types.hh index 0c0cdf6e02f..5f1c1a12021 100644 --- a/source/blender/blenkernel/BKE_paint_types.hh +++ b/source/blender/blenkernel/BKE_paint_types.hh @@ -95,7 +95,7 @@ struct PaintRuntime : NonCopyable, NonMovable { float initial_pixel_radius = 0.0f; float start_pixel_radius = 0.0f; - /** Drawing pressure. */ + /** Evaluated size pressure value */ float size_pressure_value = 0.0f; /** Position of mouse, used to sample the texture. */ diff --git a/source/blender/editors/sculpt_paint/paint_stroke.cc b/source/blender/editors/sculpt_paint/paint_stroke.cc index 51480dd502b..520e090997b 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.cc +++ b/source/blender/editors/sculpt_paint/paint_stroke.cc @@ -350,21 +350,23 @@ bool paint_brush_update(bContext *C, if (paint_supports_dynamic_size(brush, mode)) { copy_v2_v2(paint_runtime.tex_mouse, mouse); copy_v2_v2(paint_runtime.mask_tex_mouse, mouse); - stroke->cached_size_pressure = BKE_curvemapping_evaluateF(brush.curve_size, 0, pressure); } /* Truly temporary data that isn't stored in properties */ paint_runtime.stroke_active = true; - paint_runtime.size_pressure_value = stroke->cached_size_pressure; + const float pressure_to_evaluate = paint_supports_dynamic_size(brush, mode) ? + pressure : + stroke->cached_size_pressure; + paint_runtime.size_pressure_value = BKE_brush_use_size_pressure(&brush) ? + BKE_curvemapping_evaluateF( + brush.curve_size, 0, pressure_to_evaluate) : + 1.0f; - paint_runtime.pixel_radius = BKE_brush_radius_get(paint, &brush); + paint_runtime.pixel_radius = BKE_brush_radius_get(paint, &brush) * + paint_runtime.size_pressure_value; paint_runtime.initial_pixel_radius = BKE_brush_radius_get(paint, &brush); - if (BKE_brush_use_size_pressure(&brush) && paint_supports_dynamic_size(brush, mode)) { - paint_runtime.pixel_radius *= stroke->cached_size_pressure; - } - if (paint_supports_dynamic_tex_coords(brush, mode)) { if (ELEM(brush.mtex.brush_map_mode,