Fix #129853: Stroke Scene Spacing freezes with tablet size pressure

This lead to infinitely small return values from
`paint_space_stroke_spacing` (since the size can become so small) which
in turn causes an infinite loop in `paint_space_stroke`.

Was considering clamping to some other measure (e.g. based on bounding
box factors), but these might not work well in all circumstances
(dyntopo on a terrain-size mesh might still need tiny spacing), so
settled to clamp to the minimal numerical value.

Pull Request: https://projects.blender.org/blender/blender/pulls/129908
This commit is contained in:
Philipp Oeser
2024-11-06 16:34:52 +01:00
committed by Philipp Oeser
parent 496023691c
commit bccae832ae

View File

@@ -715,7 +715,9 @@ static float paint_space_stroke_spacing(bContext *C,
spacing *= stroke->zoom_2d;
if (paint_stroke_use_scene_spacing(brush, mode)) {
return size_clamp * spacing / 50.0f;
/* Low pressure on size (with tablets) can cause infinite recursion in paint_space_stroke(),
* see #129853. */
return max_ff(FLT_EPSILON, size_clamp * spacing / 50.0f);
}
return max_ff(stroke->zoom_2d, size_clamp * spacing / 50.0f);
}
@@ -850,6 +852,8 @@ static int paint_space_stroke(bContext *C,
while (length > 0.0f) {
float spacing = paint_space_stroke_spacing_variable(
C, scene, stroke, pressure, dpressure, length);
BLI_assert(spacing >= 0.0f);
float mouse[2];
if (length >= spacing) {