Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-03-30 04:17:35 +0300
committerHans Goudey <h.goudey@me.com>2022-03-30 04:17:35 +0300
commit62334c6ee4c9672067edb8e8aa6cd3a685e3fd17 (patch)
treea0b08332380a795bb90c8c133d255d52d1c11c18 /source/blender/nodes/geometry/nodes/node_geo_input_spline_length.cc
parentf4f89a76a8f4ca77bc59c9572cd2aab6da1e9023 (diff)
Curves: Port length node to the new data-block
Ref T95443
Diffstat (limited to 'source/blender/nodes/geometry/nodes/node_geo_input_spline_length.cc')
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_input_spline_length.cc22
1 files changed, 12 insertions, 10 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_spline_length.cc b/source/blender/nodes/geometry/nodes/node_geo_input_spline_length.cc
index ab6f6b40d5e..38bd79ff1a7 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_input_spline_length.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_input_spline_length.cc
@@ -3,7 +3,6 @@
#include "node_geometry_util.hh"
#include "BKE_curves.hh"
-#include "BKE_spline.hh"
namespace blender::nodes::node_geo_input_spline_length_cc {
@@ -23,21 +22,24 @@ static VArray<float> construct_spline_length_gvarray(const CurveComponent &compo
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();
- Array<float> spline_lenghts(splines.size());
- for (const int i : splines.index_range()) {
- spline_lenghts[i] = splines[i]->length();
- }
+ curves.ensure_evaluated_lengths();
+
+ VArray<bool> cyclic = curves.cyclic();
+ VArray<float> lengths = VArray<float>::ForFunc(
+ curves.curves_num(), [&curves, cyclic = std::move(cyclic)](int64_t index) {
+ return curves.evaluated_length_total_for_curve(index, cyclic[index]);
+ });
if (domain == ATTR_DOMAIN_CURVE) {
- return VArray<float>::ForContainer(std::move(spline_lenghts));
+ return lengths;
}
+
if (domain == ATTR_DOMAIN_POINT) {
- VArray<float> length = VArray<float>::ForContainer(std::move(spline_lenghts));
return component.attribute_try_adapt_domain<float>(
- std::move(length), ATTR_DOMAIN_CURVE, ATTR_DOMAIN_POINT);
+ std::move(lengths), ATTR_DOMAIN_CURVE, ATTR_DOMAIN_POINT);
}
return {};