[Bf-blender-cvs] [73ef2fc2f4e] master: Fix T91093: off by one error in when resampling curve

Jacques Lucke noreply at git.blender.org
Tue Sep 7 16:08:36 CEST 2021


Commit: 73ef2fc2f4e43a56d4b6965845534cc4df76610a
Author: Jacques Lucke
Date:   Tue Sep 7 16:06:25 2021 +0200
Branches: master
https://developer.blender.org/rB73ef2fc2f4e43a56d4b6965845534cc4df76610a

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

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

M	source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc

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

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<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);
       }
     });
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<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;



More information about the Bf-blender-cvs mailing list