Curves: Port count spline length output to new data-block

This fixes T96487 in a similar way to 5791835678,
and also removes the conversion to old curve type for the
"Point Count" output.
This commit is contained in:
Hans Goudey 2022-03-15 16:22:36 -05:00
parent d8e3bcf770
commit 379bd6d50c
Notes: blender-bot 2023-02-14 11:01:33 +01:00
Referenced by issue #96487, Crash when dynamically resampling splines using Spline Length (Point Count) + 1
1 changed files with 6 additions and 5 deletions

View File

@ -2,6 +2,7 @@
#include "node_geometry_util.hh"
#include "BKE_curves.hh"
#include "BKE_spline.hh"
namespace blender::nodes::node_geo_input_spline_length_cc {
@ -82,16 +83,16 @@ static VArray<int> construct_spline_count_gvarray(const CurveComponent &componen
if (!component.has_curves()) {
return {};
}
const std::unique_ptr<CurveEval> curve = curves_to_curve_eval(*component.get_for_read());
const Curves &curves_id = *component.get_for_read();
const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry);
Span<SplinePtr> splines = curve->splines();
auto count_fn = [splines](int i) { return splines[i]->size(); };
auto count_fn = [curves](int64_t i) { return curves.range_for_curve(i).size(); };
if (domain == ATTR_DOMAIN_CURVE) {
return VArray<int>::ForFunc(splines.size(), count_fn);
return VArray<int>::ForFunc(curves.curves_size(), count_fn);
}
if (domain == ATTR_DOMAIN_POINT) {
VArray<int> count = VArray<int>::ForFunc(splines.size(), count_fn);
VArray<int> count = VArray<int>::ForFunc(curves.curves_size(), count_fn);
return component.attribute_try_adapt_domain<int>(
std::move(count), ATTR_DOMAIN_CURVE, ATTR_DOMAIN_POINT);
}