diff options
author | Hans Goudey <h.goudey@me.com> | 2022-03-30 04:24:41 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-03-30 04:24:41 +0300 |
commit | 400ea40dca7a9be5fd2c1974c1c542d896621d67 (patch) | |
tree | 972b83b5013d5f2df731ed87bcbf9fe55495eea8 /source/blender/nodes | |
parent | 62334c6ee4c9672067edb8e8aa6cd3a685e3fd17 (diff) |
Curves: Port curves total length node to the new data-block
Ref T95443
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_curve_length.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_length.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_length.cc index d5769c691c8..11eb472a6e2 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_length.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_length.cc @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ -#include "BKE_spline.hh" +#include "BKE_curves.hh" + #include "node_geometry_util.hh" namespace blender::nodes::node_geo_curve_length_cc { @@ -18,11 +19,18 @@ static void node_geo_exec(GeoNodeExecParams params) params.set_default_remaining_outputs(); return; } - const std::unique_ptr<CurveEval> curve = curves_to_curve_eval(*curve_set.get_curves_for_read()); + + const Curves &curves_id = *curve_set.get_curves_for_read(); + const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); + const VArray<bool> cyclic = curves.cyclic(); + + curves.ensure_evaluated_lengths(); + float length = 0.0f; - for (const SplinePtr &spline : curve->splines()) { - length += spline->length(); + for (const int i : curves.curves_range()) { + length += curves.evaluated_length_total_for_curve(i, cyclic[i]); } + params.set_output("Length", length); } |