[Bf-blender-cvs] [c55767b32ee] master: Fix T103632: Single point trim samples curve end point incorrectly

Mattias Fredriksson noreply at git.blender.org
Mon Jan 16 19:38:06 CET 2023


Commit: c55767b32ee15e9deead502f72ba067eb793ff0d
Author: Mattias Fredriksson
Date:   Mon Jan 16 12:22:20 2023 -0600
Branches: master
https://developer.blender.org/rBc55767b32ee15e9deead502f72ba067eb793ff0d

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

===================================================================

M	source/blender/geometry/intern/trim_curves.cc

===================================================================

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. */



More information about the Bf-blender-cvs mailing list