From c55767b32ee15e9deead502f72ba067eb793ff0d Mon Sep 17 00:00:00 2001 From: Mattias Fredriksson Date: Mon, 16 Jan 2023 12:22:20 -0600 Subject: [PATCH] Fix T103632: Single point trim samples curve end point incorrectly Trim erronously samples the next to last control point when it should sample the last control point on the curve. This only happens when reducing the curve to a single point. These changes should correct the behavior. Differential Revision: https://developer.blender.org/D17003 --- source/blender/geometry/intern/trim_curves.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/source/blender/geometry/intern/trim_curves.cc b/source/blender/geometry/intern/trim_curves.cc index 94bd212d70e..361415aa540 100644 --- a/source/blender/geometry/intern/trim_curves.cc +++ b/source/blender/geometry/intern/trim_curves.cc @@ -885,10 +885,15 @@ static void compute_curve_trim_parameters(const bke::CurvesGeometry &curves, if (end_length <= start_length) { /* Single point. */ dst_curve_size[curve_i] = 1; - src_ranges[curve_i] = bke::curves::IndexRangeCyclic::get_range_from_size( - start_points[curve_i].index, - start_points[curve_i].is_controlpoint(), /* Only iterate if control point. */ - point_count); + if (start_points[curve_i].is_controlpoint()) { + /* Only iterate if control point. */ + const int single_point_index = start_points[curve_i].parameter == 1.0f ? + start_points[curve_i].next_index : + start_points[curve_i].index; + src_ranges[curve_i] = bke::curves::IndexRangeCyclic::get_range_from_size( + single_point_index, 1, point_count); + } + /* else: leave empty range */ } else { /* Split. */