[Bf-blender-cvs] [540fd10b4fd] blender-v3.1-release: Fix T95992: Crash Ancored strokes 2d texture painting.
Jeroen Bakker
noreply at git.blender.org
Mon Feb 28 09:05:55 CET 2022
Commit: 540fd10b4fda80eb9c806aae29363daefd2f990e
Author: Jeroen Bakker
Date: Mon Feb 28 09:03:47 2022 +0100
Branches: blender-v3.1-release
https://developer.blender.org/rB540fd10b4fda80eb9c806aae29363daefd2f990e
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.
===================================================================
M source/blender/editors/sculpt_paint/paint_image_2d_curve_mask.cc
===================================================================
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];
More information about the Bf-blender-cvs
mailing list