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
This commit is contained in:
Philipp Oeser
2024-06-03 09:20:07 +02:00
committed by Philipp Oeser
parent 5bc71c8704
commit ba3fac92af

View File

@@ -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;