From ba3fac92af201814aec880aaabc36d5e1690378f Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Mon, 3 Jun 2024 09:20:07 +0200 Subject: [PATCH] Fix #122598: Curves Grow brush broken on curves with only two points Code was getting a direction (to grow in) from the last point in a curve and another point in the middle of the curve. On a curve with only two points, these points were the same, resulting in a zero delta and thus doing nothing. To resolve, take the root point instead in this scenario to get a valid direction. Pull Request: https://projects.blender.org/blender/blender/pulls/122644 --- .../blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc b/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc index ad87d68bf92..3632995f469 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc @@ -155,7 +155,8 @@ class ExtrapolateCurvesEffect : public CurvesEffect { const float3 old_last_pos_cu = positions_cu[points.last()]; /* Use some point within the curve rather than the end point to smooth out some random * variation. */ - const float3 direction_reference_point = positions_cu[points[points.size() / 2]]; + const float3 direction_reference_point = + positions_cu[points.size() > 2 ? points[points.size() / 2] : points.first()]; const float3 direction = math::normalize(old_last_pos_cu - direction_reference_point); const float3 new_last_pos_cu = old_last_pos_cu + direction * move_distance_cu;