From 73ef2fc2f4e43a56d4b6965845534cc4df76610a Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 7 Sep 2021 16:06:25 +0200 Subject: [PATCH] Fix T91093: off by one error in when resampling curve The bug existed in the Curve Resample and Curve to Points node. Differential Revision: https://developer.blender.org/D12416 --- source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc | 2 +- source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc index 0b71a8cb03a..1382efa025b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc @@ -169,7 +169,7 @@ static std::unique_ptr resample_curve(const CurveEval &input_curve, threading::parallel_for(input_splines.index_range(), 128, [&](IndexRange range) { for (const int i : range) { const float length = input_splines[i]->length(); - const int count = std::max(int(length / *mode_param.length), 1); + const int count = std::max(int(length / *mode_param.length) + 1, 1); output_splines[i] = resample_spline(*input_splines[i], count); } }); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc index 052eb92d269..17cd8e987a7 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc @@ -101,7 +101,7 @@ static Array calculate_spline_point_offsets(GeoNodeExecParams ¶ms, int offset = 0; for (const int i : IndexRange(size)) { offsets[i] = offset; - offset += splines[i]->length() / resolution; + offset += splines[i]->length() / resolution + 1; } offsets.last() = offset; return offsets;