Blender  V3.3
node_geo_curve_length.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include "BKE_curves.hh"
4 
5 #include "node_geometry_util.hh"
6 
8 
10 {
11  b.add_input<decl::Geometry>(N_("Curve")).supported_type(GEO_COMPONENT_TYPE_CURVE);
12  b.add_output<decl::Float>(N_("Length"));
13 }
14 
16 {
17  GeometrySet curve_set = params.extract_input<GeometrySet>("Curve");
18  if (!curve_set.has_curves()) {
19  params.set_default_remaining_outputs();
20  return;
21  }
22 
23  const Curves &curves_id = *curve_set.get_curves_for_read();
25  const VArray<bool> cyclic = curves.cyclic();
26 
27  curves.ensure_evaluated_lengths();
28 
29  float length = 0.0f;
30  for (const int i : curves.curves_range()) {
31  length += curves.evaluated_length_total_for_curve(i, cyclic[i]);
32  }
33 
34  params.set_output("Length", length);
35 }
36 
37 } // namespace blender::nodes::node_geo_curve_length_cc
38 
40 {
41  namespace file_ns = blender::nodes::node_geo_curve_length_cc;
42 
43  static bNodeType ntype;
44 
48  nodeRegisterType(&ntype);
49 }
Low-level operations for curves.
@ GEO_COMPONENT_TYPE_CURVE
#define NODE_CLASS_GEOMETRY
Definition: BKE_node.h:359
#define GEO_NODE_CURVE_LENGTH
Definition: BKE_node.h:1405
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1357
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to curves
static CurvesGeometry & wrap(::CurvesGeometry &dna_struct)
Definition: BKE_curves.hh:138
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
T length(const vec_base< T, Size > &a)
static void node_declare(NodeDeclarationBuilder &b)
static void node_geo_exec(GeoNodeExecParams params)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
void register_node_type_geo_curve_length()
void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
CurvesGeometry geometry
const Curves * get_curves_for_read() const
bool has_curves() const
Defines a node type.
Definition: BKE_node.h:226
NodeGeometryExecFunction geometry_node_execute
Definition: BKE_node.h:316
NodeDeclareFunction declare
Definition: BKE_node.h:324
#define N_(msgid)