diff options
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc | 33 |
1 files changed, 21 insertions, 12 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 e879ec624c0..bf122bab613 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc @@ -138,19 +138,28 @@ static SplinePtr resample_spline(const Spline &input_spline, const int count) static std::unique_ptr<CurveEval> resample_curve(const CurveEval &input_curve, const SampleModeParam &mode_param) { - std::unique_ptr<CurveEval> output_curve = std::make_unique<CurveEval>(); + Span<SplinePtr> input_splines = input_curve.splines(); - for (const SplinePtr &spline : input_curve.splines()) { - if (mode_param.mode == GEO_NODE_CURVE_SAMPLE_COUNT) { - BLI_assert(mode_param.count); - output_curve->add_spline(resample_spline(*spline, *mode_param.count)); - } - else if (mode_param.mode == GEO_NODE_CURVE_SAMPLE_LENGTH) { - BLI_assert(mode_param.length); - const float length = spline->length(); - const int count = std::max(int(length / *mode_param.length), 1); - output_curve->add_spline(resample_spline(*spline, count)); - } + std::unique_ptr<CurveEval> output_curve = std::make_unique<CurveEval>(); + output_curve->resize(input_splines.size()); + MutableSpan<SplinePtr> output_splines = output_curve->splines(); + + if (mode_param.mode == GEO_NODE_CURVE_SAMPLE_COUNT) { + threading::parallel_for(input_splines.index_range(), 128, [&](IndexRange range) { + for (const int i : range) { + BLI_assert(mode_param.count); + output_splines[i] = resample_spline(*input_splines[i], *mode_param.count); + } + }); + } + else if (mode_param.mode == GEO_NODE_CURVE_SAMPLE_LENGTH) { + 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); + output_splines[i] = resample_spline(*input_splines[i], count); + } + }); } output_curve->attributes = input_curve.attributes; |