Fix: Grease Pencil: Crash in curves_merge_by_distance for cyclic curves

The issue was that the size of `distances_along_curve` was wrong for
cyclic curves. The fix increases the size by one for cyclic curves to
account for the last segment length.
This commit is contained in:
Falk David
2024-11-28 11:41:56 +01:00
parent 76f9a08963
commit 8b233f36db

View File

@@ -233,7 +233,7 @@ blender::bke::CurvesGeometry curves_merge_by_distance(const bke::CurvesGeometry
const IndexRange points = points_by_curve[curve_i];
merge_indices_per_curve[curve_i].reinitialize(points.size());
Array<float> distances_along_curve(points.size());
Array<float> distances_along_curve(points.size() + int(cyclic[curve_i]));
distances_along_curve.first() = 0.0f;
const Span<float> lengths = src_curves.evaluated_lengths_for_curve(curve_i, cyclic[curve_i]);
distances_along_curve.as_mutable_span().drop_front(1).copy_from(lengths);