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
This commit is contained in:
Jacques Lucke
2021-09-07 16:06:25 +02:00
parent 08acbdc1ff
commit 73ef2fc2f4
2 changed files with 2 additions and 2 deletions

View File

@@ -169,7 +169,7 @@ static std::unique_ptr<CurveEval> 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);
}
});

View File

@@ -101,7 +101,7 @@ static Array<int> calculate_spline_point_offsets(GeoNodeExecParams &params,
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;