Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_curve_length.cc
| Show All 22 Lines | |||||
| { | { | ||||
| b.add_input<decl::Geometry>("Curve"); | b.add_input<decl::Geometry>("Curve"); | ||||
| b.add_output<decl::Float>("Length"); | b.add_output<decl::Float>("Length"); | ||||
| } | } | ||||
| static void geo_node_curve_length_exec(GeoNodeExecParams params) | static void geo_node_curve_length_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| GeometrySet curve_set = params.extract_input<GeometrySet>("Curve"); | GeometrySet curve_set = params.extract_input<GeometrySet>("Curve"); | ||||
| curve_set = bke::geometry_set_realize_instances(curve_set); | |||||
| if (!curve_set.has_curve()) { | if (!curve_set.has_curve()) { | ||||
| params.set_output("Length", 0.0f); | params.set_output("Length", 0.0f); | ||||
| return; | return; | ||||
| } | } | ||||
| const CurveEval &curve = *curve_set.get_curve_for_read(); | const CurveEval &curve = *curve_set.get_curve_for_read(); | ||||
| float length = 0.0f; | float length = 0.0f; | ||||
| for (const SplinePtr &spline : curve.splines()) { | for (const SplinePtr &spline : curve.splines()) { | ||||
| length += spline->length(); | length += spline->length(); | ||||
| Show All 15 Lines | |||||