diff options
author | Jeroen Bakker <jeroen@blender.org> | 2022-02-28 11:03:47 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2022-02-28 11:03:47 +0300 |
commit | 540fd10b4fda80eb9c806aae29363daefd2f990e (patch) | |
tree | 3976d7b9f288a6496415ead9de6dd5402d7c9b3d /source/blender/editors/sculpt_paint | |
parent | 2a644deaa7b2a94c3c6b73c5fdac59b524337c80 (diff) |
Fix T95992: Crash Ancored strokes 2d texture painting.
When using ancored stroked the diameter of the stroke can be 0 what
leads to a division by zero that on certain platforms wrap to a large
negative number that cannot be looked up. This fix will clamp the size
of the brush to 1.
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image_2d_curve_mask.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d_curve_mask.cc b/source/blender/editors/sculpt_paint/paint_image_2d_curve_mask.cc index 8d57a3d9152..5133b5fc982 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d_curve_mask.cc +++ b/source/blender/editors/sculpt_paint/paint_image_2d_curve_mask.cc @@ -69,6 +69,7 @@ static void update_curve_mask(CurveMaskCache *curve_mask_cache, { BLI_assert(curve_mask_cache->curve_mask != nullptr); int offset = (int)floorf(diameter / 2.0f); + int clamped_radius = max_ff(radius, 1.0); unsigned short *m = curve_mask_cache->curve_mask; @@ -92,7 +93,7 @@ static void update_curve_mask(CurveMaskCache *curve_mask_cache, pixel_xy[1] = static_cast<float>(y) + aa_offset; for (int j = 0; j < aa_samples; j++) { const float len = len_v2v2(pixel_xy, bpos); - const int sample_index = min_ii((len / radius) * CurveSamplesBaseLen, + const int sample_index = min_ii((len / clamped_radius) * CurveSamplesBaseLen, CurveSamplesLen - 1); const float sample_weight = curve_mask_cache->sampled_curve[sample_index]; |